Rama Rao

Iecompatiblity() Javascript Error

Recommended Posts

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

Greetings, smile.gif

 

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

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, smile.gif

 

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

Hi, smile.gif

 

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. smile.gif

Share this post


Link to post
Share on other sites

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, smile.gif

 

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. smile.gif

Share this post


Link to post
Share on other sites
Guest Sumedh

Hi, smile.gif

 

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. smile.gif

Share this post


Link to post
Share on other sites

Thank you...

Its working fine..

Appreciate your time and help..

 

Happy FusionCharting.... smile.gif

 

Hi, smile.gif

 

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. smile.gif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now