zales33 Report post Posted May 26, 2012 Hello, I'm trying to configure a 3D stacked column chart and was wondering if it's possible to declare a java script variable then use that variable in the set value syntax. I've pasted my example below. Thank you for your help <!--Define Java variables to use in the chart --> var AnnualForecast=10000; var chart = new FusionCharts("<%[[WEBBRIDGE]]%>?LongviewIdentifier=<%[[WEBVARIABLE,LongviewIdentifier]]%>&LongviewAction=GetFile&LongviewContentType='image/swf'&LongviewFileName='Optix/StackedColumn3DLineDY.swf'", "3DStkColLin", "100%", "350", "0", "0"); chart.setDataXML("<chart palette='1' caption='Forecast vs Budget' shownames='1' showvalues='0' numberPrefix='$' connectNullData='0' PYAxisName='Dollars' numDivLines='4' formatNumberScale='1' decimals='1' forceDecimals='1' >\ <categories>\ <category label='Forecast' />\ <category label='Budget' />\ </categories>\ <dataset seriesName='Actuals YTD' color='AFD8F8' showValues='0'>\ <set value='5000' />\ <set value='' />\ </dataset>\ <dataset seriesName='Forecast 12 Month' color='F6BD0F' showValues='0'>\ <set value='AnnualForecast' />\ <set value='' />\ </dataset>\ <dataset seriesName='Budget YTD' color='8BBA00' showValues='0' >\ <set value='' />\ <set value='14835' />\ </dataset>\ <dataset seriesName='Budget 12 Month' color='000000' showValues='0' >\ <set value='' />\ <set value='30872' />\ </dataset>\ \ Share this post Link to post Share on other sites
Guest Sashibhusan Report post Posted May 28, 2012 Hi, Yes, you can use JavaScript variable inside the XML data while building the XML string, using JavaScript string concatenation operator "+". Ref. Code: <script type="text/javascript"><!-- var AnnualForecast=7000; var myChart = new FusionCharts( "charts/Column2D.swf", "myChartId", "800", "600", "0", "1" ); myChart.setXMLData("<chart ><set label='Oct' value='" + AnnualForecast + "' /><set label='Nov' value='2000' /></chart>"); myChart.render("chartContainer"); // --> </script> Please note that it is recommended to use "setXMLData();" instead of "setDataXML();", since "setDataXML();" is the deprecated method. Hope this helps. Share this post Link to post Share on other sites
zales33 Report post Posted May 28, 2012 Thank you SO much for your response. It worked perfectly and I'm so excited to know that we can use variables, this has just made everything 1000% easier!!! Hi, Yes, you can use JavaScript variable inside the XML data while building the XML string, using JavaScript string concatenation operator "+". Ref. Code: <script type="text/javascript"><!-- var AnnualForecast=7000; var myChart = new FusionCharts( "charts/Column2D.swf", "myChartId", "800", "600", "0", "1" ); myChart.setXMLData("<chart ><set label='Oct' value='" + AnnualForecast + "' /><set label='Nov' value='2000' /></chart>"); myChart.render("chartContainer"); // --> </script> Please note that it is recommended to use "setXMLData();" instead of "setDataXML();", since "setDataXML();" is the deprecated method. Hope this helps. Share this post Link to post Share on other sites
Guest Sumedh Report post Posted May 29, 2012 Thank you SO much for your response. It worked perfectly and I'm so excited to know that we can use variables, this has just made everything 1000% easier!!! Hi, Its good to know that your issue has been resolved. Share this post Link to post Share on other sites