Vedmack

How To Dispose Of A Chart?

Recommended Posts

Hi

 

After figuring out that its not a good idea to retrieve an existing chart using jquery I temporary moved to js

 

But now it seems that js got some issue too

 

Here how I check if chart already exists

 

var chartReference = FusionCharts("my_chart_id");

 

if(chartReference){

FusionCharts("my_chart_id").dispose();

}

 

but sometimes i'm getting "getting Uncaught TypeError: Cannot call method 'destroy' of undefined " in my chrome console pointing me to the FusionCharts("my_chart_id").dispose(); line...

 

How can it be fixed?

 

cause the fact i;m entering the if condition means that chartReference object is not null ---> the chart exists

 

so how should I get rid of it ?

 

Regards,

 

Daniel.

Share this post


Link to post
Share on other sites
Guest Sumedh

Hi,

 

Could you please try following piece of code?

 


var chartRef = FusionCharts("my_chart_id");

if(chartRef == "myChartId"){
       FusionCharts("my_chart_id ").dispose();
}else{				
              var myChart = new FusionCharts("Column3D.swf","my_chart_id ","500","350","0","1");
              myChart.setXMLUrl("data.xml");
              myChart.render("chartContainer");
              FusionCharts.addEventListener ( "Rendered", function(e,p) { alert(e.sender.id + " chart has rendered!" ); } )
}

 

Share this post


Link to post
Share on other sites

if(chartRef == "myChartId"){

 

?

 

shouldn't it be

 

if(chartRef == "my_chart_id"){

 

 

I mean , where does the myChartId came from ?

 

Thanks..

Share this post


Link to post
Share on other sites
Guest Sumedh

Apologies for the typo.

 

It is my_chart_id.

 

 

var chartRef = FusionCharts("my_chart_id ");

if(chartRef == "my_chart_id "){
	FusionCharts("my_chart_id ").dispose();
}else{				
	var myChart = new FusionCharts("Column3D.swf","my_chart_id ","500","350","0","1");
	myChart.setXMLUrl("data.xml");
	myChart.render("chartContainer");
	FusionCharts.addEventListener ( "Rendered", function(e,p) { alert(e.sender.id + " chart has rendered!" ); } )
}

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