Rama Rao Report post Posted February 23, 2012 Hi all, My fusion chart giving error while applying setXMLData() : #25081843:IECompatibility() Chart Id is same as a JavaScript variable name. Variable naming error.Please use unique name for chart JS variable, chart-id and container id. I have searched in online, where I see one solution like JS variable and ChartId should not be same. But in my case,those two are unique .But still I'm getting the error. could please any one tel me the solution... Here is my code... <!DOCTYPE HTML> <html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <script type="text/javascript" src="FusionCharts.js"></script> <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript" src="highcharts.js"></script> </head> <body> <div id="PieChartContainer" style="border:1px solid black;"> FusionCharts will load here! </div> <button onClick="setData()"> Change Data</button> </body> <script> var chartRef = new FusionCharts("Pie3D.swf","NetValPieChart","400","400","0","1"); var strXML = '<graph caption="Net Amount Per City" animation="1" formatNumberScale="0" numberPrefix="$" pieSliceDepth="30" decimalPrecision="0" shownames="1" ><set name="Leverling" value="100524" color="AFD8F8"/><set name="Fuller" value="87790" color="F6BD0F"/><set name="Davolio" value="81898" color="8BBA00" /><set name="Peacock" value="76438" color="FF8E46" /><set name="King" value="57430" color="008E8E" /><set name="Callahan" value="55091" color="D64646" /><set name="Dodsworth" value="43962" color="8E468E"/><set name="Suyama" value="22474" color="588526" /><set name="Buchanan" value="21637" color="B3AA00"/></graph>'; chartRef.setXMLData(strXML); chartRef.render("PieChartContainer"); function setData() { strXML = '<graph caption="Net Amount Per City" animation="1" formatNumberScale="0" numberPrefix="$" pieSliceDepth="30" decimalPrecision="0" shownames="1" ><set name="Leverling" value="100524" color="AFD8F8"/><set name="Fuller" value="87790" color="F6BD0F"/><set name="Davolio" value="98" color="8BBA00" /><set name="Peacock" value="76438" color="FF8E46" /><set name="King" value="5430" color="008E8E" /><set name="Callahan" value="5091" color="D64646" /><set name="Dodsworth" value="3962" color="8E468E"/><set name="Suyama" value="22474" color="5826" /><set name="Buchanan" value="21637" color="B3AA00"/></graph>'; // chartRef.dispose(); chartRef = FusionCharts.items["NetValPieChart"]; chartRef.setXMLData(strXML); chartRef.render("PieChartContainer"); } </script> </html> Share this post Link to post Share on other sites
Guest Sumedh Report post Posted February 24, 2012 Greetings, This error occurs when you have a JavaScript variable in the global window scope with the same name as that of the chart's Id. Could you please try giving a unique "chart id", "div id" and "variable name" for each chart that is to be rendered? Looking forward to your reply. Share this post Link to post Share on other sites
Rama Rao Report post Posted February 24, 2012 Hi Sumedh, Thanks for reply... No.. I did not use same variables for all.. Check my code once.. div id is :PieChartContainer chart id is :NetValPieChart and js variable is :chartRef... Those three are unique... !!!! Looking forward for your reply..... Greetings, This error occurs when you have a JavaScript variable in the global window scope with the same name as that of the chart's Id. Could you please try giving a unique "chart id", "div id" and "variable name" for each chart that is to be rendered? Looking forward to your reply. Share this post Link to post Share on other sites
Guest Sumedh Report post Posted February 24, 2012 Hi, Apologies for the miscommunication. When you click on the "change data" button, it creates new instance of chart. So, it generates an error, since your are using FusionCharts v3.2.1. You would need to use "dispose()" method, it will remove the chart instance from the memory. Ref. code: FusionCharts("myChartId").dispose(); Hope this helps. Share this post Link to post Share on other sites
Rama Rao Report post Posted February 24, 2012 Hi, I did as you suggested..Now I am getting new error... I had added the dispose() method line before the line of getting chart reference... FusionCharts("NetValPieChart").dispose(); chartRef = FusionCharts.items["NetValPieChart"]; chartRef.setXMLData(strXML); chartRef.render("PieChartContainer"); Now its giving error at 3rd line : Unable to get value of the property 'setXMLData' : Object is null or undefined. So, I must create that Object again using the following line? var chartRef = new FusionCharts("Pie3D.swf","NetValPieChart","400","400","0","1"); Looking forward for your reply.. Hi, Apologies for the miscommunication. When you click on the "change data" button, it creates new instance of chart. So, it generates an error, since your are using FusionCharts v3.2.1. You would need to use "dispose()" method, it will remove the chart instance from the memory. Ref. code: FusionCharts("myChartId").dispose(); Hope this helps. Share this post Link to post Share on other sites
Guest Sumedh Report post Posted February 24, 2012 Hi, The chart is re-renders as you click on the button. "chartRef.render("PieChartContainer");" statement again renders the chart. and its generating an error once again. Could you please, modify your code as following: function setData() { //chartRef.dispose(); ---------------------------------------------------------------------------> comment this statement. var strXML1 = '<chart caption="Net Amount Per City" animation="1" formatNumberScale="0" numberPrefix="{:content:}quot; pieSliceDepth="30" decimalPrecision="0" shownames="1" ><set name="Leverling" value="100524" color="AFD8F8"/><set name="Fuller" value="87790" color="F6BD0F"/><set name="Davolio" value="98" color="8BBA00" /><set name="Peacock" value="76438" color="FF8E46" /><set name="King" value="5430" color="008E8E" /><set name="Callahan" value="5091" color="D64646" /><set name="Dodsworth" value="3962" color="8E468E"/><set name="Suyama" value="22474" color="5826" /><set name="Buchanan" value="21637" color="B3AA00"/></chart>'; chartRef = FusionCharts.items["NetValPieChart"]; chartRef.setXMLData(strXML1); //chartRef.render("PieChartContainer"); --------------------------------------------------> comment this statement. } Hope this helps. Share this post Link to post Share on other sites
Rama Rao Report post Posted February 24, 2012 Thank you... Its working fine.. Appreciate your time and help.. Happy FusionCharting.... Hi, The chart is re-renders as you click on the button. "chartRef.render("PieChartContainer");" statement again renders the chart. and its generating an error once again. Could you please, modify your code as following: function setData() { //chartRef.dispose(); ---------------------------------------------------------------------------> comment this statement. var strXML1 = '<chart caption="Net Amount Per City" animation="1" formatNumberScale="0" numberPrefix="{:content:}quot; pieSliceDepth="30" decimalPrecision="0" shownames="1" ><set name="Leverling" value="100524" color="AFD8F8"/><set name="Fuller" value="87790" color="F6BD0F"/><set name="Davolio" value="98" color="8BBA00" /><set name="Peacock" value="76438" color="FF8E46" /><set name="King" value="5430" color="008E8E" /><set name="Callahan" value="5091" color="D64646" /><set name="Dodsworth" value="3962" color="8E468E"/><set name="Suyama" value="22474" color="5826" /><set name="Buchanan" value="21637" color="B3AA00"/></chart>'; chartRef = FusionCharts.items["NetValPieChart"]; chartRef.setXMLData(strXML1); //chartRef.render("PieChartContainer"); --------------------------------------------------> comment this statement. } Hope this helps. Share this post Link to post Share on other sites