Ana Tag

Setchartattribute Not Updating The Chart

Recommended Posts

Hi,

 

I am trying to set caption for chart using setChartAttribute javascript method but chart caption is not changing. My code is as follows (this is based on the sample I got from this site):

 

<html>  
<head>    <title>Update Chart data</title>    
<script type="text/javascript" src="FusionCharts.js">    
</script>  
</head>  
<body>    
<center>    
<div id="chartContainer">Chart will load here!</div>    
<script type="text/javascript"><!--

var myChart = new FusionCharts( 'Column2D.swf', 'MyChart', '300', '240', '0', '1' );      

myChart.setXMLData("<chart caption='Issues' showValues='0' yAxisName='Issues' xAxisName='Month' > <set label='Dec 2011' value='3' /><set label='Jan 2012' value='18' /><set label='Feb 2012' value='21' /><set label='Mar 2012' value='19' /><set label='Apr 2012' value='55' /><set label='May 2012' value='23' /></chart>"); 
myChart.render("chartContainer");  

function changeAttribute()          {           
// get chart reference                  
var chartReference = FusionCharts( 'MyChart' );  
chartReference.setChartAttribute({"caption" : "Issues opened"}); 
}    

// -->
</script>    
<input type="button" onClick="changeAttribute();" value="Change Caption" >    
</center>  
</body>
</html>

 

When I click on 'Change Caption' button chart is not being updated with new caption. I added alerts after the call setChartAttribute, it gives the new caption but chart is not updated. I tried adding render after it and it still not picking up the new caption. Could anyone please help me? btw, I am using v3.2.1.

 

Thank you,

Ana

Share this post


Link to post
Share on other sites

Hi Ana,

 

If your rendering the charts from a local machine, to enable communication between charts and JavaScript (like updating data, retrieving data, printing, exporting, event handling etc.), you need to setup Flash Player Global Security settings.

 

For more information on "Flash Player Global Security settings", please refer the following link:

http://docs.fusioncharts.com/charts/Tools/FlashPlayerSecuritySetup/HowToSetup.html#offline

 

Hope this helps.

Share this post


Link to post
Share on other sites

Hi Ana,

 

If your rendering the charts from a local machine, to enable communication between charts and JavaScript (like updating data, retrieving data, printing, exporting, event handling etc.), you need to setup Flash Player Global Security settings.

 

For more information on "Flash Player Global Security settings", please refer the following link:

http://docs.fusionch...up.html#offline

 

Hope this helps.

 

 

Thank you Swarnam! Yes, I was testing it locally and the setting up Global Secruity settings did work.

 

Also, I want to change sub-caption font size. I found on this site how to change it by using style tag in XML chart data but how can I acheive the samething using javascript?

 

Thanks,

Ana

Edited by Ana Tag

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