Sign in to follow this  
allomart

Problem In Getting Chart Attributes

Recommended Posts

Hello everybody,

we have been using fusioncharts for 1 year. We Use the zoomline graph to display historic values of some phisical magnitudes, and we obtain them from a mysql database.

To do that we use the setDataURL method, and in the php file that provide the data we use the PHP class library.

We set the params of the chart using $FC->setChartParams and finally print out the data with print $FC->getXML();

Everything is ok, but now we'd like to be able to modify the attributes of the chart, and before doing that we would need to get some of the attributes of an already printed graph.

To do this we use the getChartAttribute() function. For example(in javascript):

 

var ymax = FusionCharts('myChartId').getChartAttribute('yAxisMaxValue');

 

The problem is that after the call the variable value remains 'undefined'.

If we pass the data using setXMLData("<chart caption='Sales Chart'><set label='A' value='10' /><set label='B' value='11' />......... like in the example in the documentation it works fine.

Can we do what we want to? Are we doing something wrong?

Thank you in advance

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Welcome to FusionCharts Forum! smile.gif

 

Please make sure you are using the latest JS files.

 

Please find the sample code below for your reference.

 

You would need to edit the path of JS and swf file in the code.

 

<html>
 <head>        
   <title>Getting chart attributes from chart</title>  
   <script type="text/javascript" src="../FusionCharts/FusionCharts.js">
   </script>
 </head>   
 <body> 	
   <div id="chartContainer">FusionCharts will load here!</div>          
   <script type="text/javascript">     	

     var myChart = new FusionCharts( "../FusionCharts/Column3D.swf", "myChartId", "400", "300", "0", "1" );
     myChart.setXMLData("<chart caption='Sales Chart' yAxisMinValue='0' yAxisMaxValue='20'><set label='A' value='10' /><set label='B' value='11' /></chart>");
     myChart.render("chartContainer");


   </script>      
   <input onclick = "alert(FusionCharts('myChartId').getChartAttribute('yAxisMaxValue'))" type="button" value="Read Max Value from chart">
 </body> 
</html>

 

 

Hope this helps.

Share this post


Link to post
Share on other sites

I've finally solved the problem.

It was because of something wrong on the start of the text sent back from the php file:

 

header('Content-type: text/xml');

echo pack ( "C3" , 0xef, 0xbb, 0xbf );

print $FC->getXML();

 

I removed that 2 first lines and then it was able to get the attributes from the chart. I don't even remember what were tohse lines for.

Thank you very much.

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Glad to know that you have managed to resolve your problem.

 

Happy FusionCharting!!! biggrin.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
Sign in to follow this