xjrad

About Jquery Api Updatefusioncharts

Recommended Posts

I was using this:

 

$("#chartContainer").updateFusionCharts( {"dataSource": NewMSXMLAsString, "dataFormat": "xml", "swfUrl" : "xx.swf"})

 

to update chart.But it's always refresh current chart and then update.How could this happen?

Share this post


Link to post
Share on other sites

I was using this:

 

$("#chartContainer").updateFusionCharts( {"dataSource": NewMSXMLAsString, "dataFormat": "xml", "swfUrl" : "xx.swf"})

 

to update chart.But it's always refresh current chart and then update.How could this happen?

 

Drop the swfUrl parameter while updating.

Share this post


Link to post
Share on other sites

I am having the same problem. except my dataFormat is "xmlurl". What is the best way to change swfUrl or chartType without recreate the chart? Thanks!

Drop the swfUrl parameter while updating.

Share this post


Link to post
Share on other sites
Guest Sumedh

Hi,

 

You can use cloneFusionCharts method, this method allows you to duplicate a FusionCharts JavaScript object and uses its settings to create another chart.

 

Please refer the following URL's for more information:

http://docs.fusioncharts.com/charts/contents/?jQuery/AdvancedRendering.html#clone

 

http://docs.fusioncharts.com/charts/contents/?JavaScript/API/Methods.html

 

You can also disable the chart's animation by setting animation attribute as "0" in the chart element.

 

Please find attached illustration for your reference.

FusionCharts_Demo.zip

Share this post


Link to post
Share on other sites

The clone function works well. But I am wondering is it going to create a memory leak if I do the clone many times, since it keeps on create new charts, but old charts never get disposed?

Currently, my solution is dispose the old chart, and create a new one at the same place with new type and data. It works fine for me. But it would be better if there is a way to just update the original chart instead of creating a new one.

 

Hi,

 

You can use cloneFusionCharts method, this method allows you to duplicate a FusionCharts JavaScript object and uses its settings to create another chart.

 

Please refer the following URL's for more information:

http://docs.fusionch...ring.html#clone

 

http://docs.fusionch...PI/Methods.html

 

You can also disable the chart's animation by setting animation attribute as "0" in the chart element.

 

Please find attached illustration for your reference.

Share this post


Link to post
Share on other sites
Guest Sumedh

The clone function works well. But I am wondering is it going to create a memory leak if I do the clone many times, since it keeps on create new charts, but old charts never get disposed?

Currently, my solution is dispose the old chart, and create a new one at the same place with new type and data. It works fine for me. But it would be better if there is a way to just update the original chart instead of creating a new one.

 

 

 

Hi,

 

If you want to avoid memory leak issue, then you can simply render the charts without using clone method.

 

Also, if you don't want to refresh the chart div while changing the chart, you can disable the chart's animation by setting the animation attribute as "0".

 

Please refer the following code:

 

<html>
<head>
<title>Sample chart to get data</title>

<script language="JavaScript" src="Charts/jquery.min.js"></script>
<script language="JavaScript" src="Charts/FusionCharts.js"></script>
<script language="JavaScript" src="Charts/FusionCharts.jqueryplugin.js"></script>
</head>
<body bgcolor="#ffffff">
<!-- Start Code for FusionCharts chart -->
<div id="chartdiv" align="center">FusionCharts</div>
<div align="center" >
<input type="button"onClick="javascript: alert(myChart.getXMLData());" value="Get Chart Data">
<input type="button" onClick="changeChart();" value="Change Chart"/>
</div>
<script type="text/javascript">
FusionCharts.setCurrentRenderer("javascript");
var myChart = new FusionCharts("Charts/Column2D.swf", "chartID1", "600", "400", "0", "1");
myChart.setXMLUrl("Sample.xml");
myChart.render("chartdiv");

function changeChart() {
$("#chartdiv").attrFusionCharts({"animate":"0"});
$("#chartdiv").updateFusionCharts({"swfUrl":"Charts/Pie3D.swf"});
}


</script>
<!-- End Code for FusionCharts chart -->
</body>
</html>

 

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