Sign in to follow this  
Nate23VT

Converting PHP Charts to Javascript

Recommended Posts

I have some old legacy FusionCharts that use the FusionCharts.php class that I am trying to convert to Javascript.  My existing charts were rendered using the renderChartHTML function which appears to have been deprecated.  I have converted this to the renderChart function and added the  "FC_SetRenderer( "javascript" );" code.  Now my charts do not render, and instead just output 'Chart' text.

 

Here is my PHP code:

 

include "FusionCharts.php";

FC_SetRenderer( "javascript" );

            $strXML  = "<chart caption='Time to Create Brief,{br} minutes' palette='3' animation='1' formatNumberScale='0' pieSliceDepth='30' showLegend='1' showLabels='0'>";
            $strXML .= "<set label='0-4m' value='".$LessThan4."' link='javascript:TimetoSub04();'/>";
            $strXML .= "<set label='5-15m' value='".$LessThan15."' link='javascript:TimetoSub515();;'/>";
            $strXML .= "<set label='16-30m' value='".$LessThan30."' link='javascript:TimetoSub1630();'/>";
            $strXML .= "<set label='>30m' value='".$GreaterThan30."' link='javascript:TimetoSub30up();'/>";
            $strXML .= "</chart>";

 

            echo renderChart("/Fusion/Charts/Charts/Pie2D.swf", "", $strXML, "TimeChart", 200, 200, false, true);
 

I am not sure if it matters, but this page renders 8 different Pie charts, all with a unique ID.

 

I have also tried using the jQuery code to convert it to Javascript and that also did not work.  I am really scratching my head on this one but I feel liek it has to be something simple.  Help!

Share this post


Link to post
Share on other sites

Hi,

 

Could you please confirm which version of FusionCharts Suite you have been using to render the charts.

 

If you are using any of our latest JavsScript version (starting 3.4.0) we would like to give a clear view of a few points.

 

Since the latest versions render charts as pure JavaScript  charts, "FC_SetRenderer( "javascript" );" is no longer required. All the charts server side scripting is similar as done with the previous. Only thing required is that the .SWF files are no longer required, instead only the chart type is required to be mentioned.

 

We have a demo sample of how to render chart using PHP. Please download it from the drop box link below.

https://www.dropbox.com/s/xvr2kysfo902zf7/Forum_16267.zip?dl=0

 

Since our latest documentation does not yet have a section for server side scripting languages, you can refer to the documentation link below.

http://docs.fusioncharts.com/charts/contents/guide-for-web-developers/php/PHP_Array.html

 

Please note that the sample uses the latest JS files (3.5.0 version). We would also like to suggest that if you are using any earlier versions, please do upgrade to our latest version and explore the possibilities.

To download the Evaluation version of FusionCharts Suite XT v3.5.0, please visit the link: http://www.fusioncharts.com/download/
 
Hope this will resolve your issue.

Share this post


Link to post
Share on other sites

Moonmi - thank you for the response.

 

I am using 3.5 of the javascript file and 3.2.2 of the PHP class.  The PHP file I am referencing is in a different folder as the latest version did not include it in the code.  The dropbox link referenced above does not appear to be working.

 

I removed the SWF reference from the rendercharts function but I was not exactly sure what to use for the chart type.  I tried Pie2D but that did not work.  The end result is still just a Div with the word 'Chart' in it.

Share this post


Link to post
Share on other sites

I was able to download and verify that the dropbox file worked on my web instance.  I investigated my issue some more and I have narrowed the issue down to the fact that the chart is loaded in an AJAX call.  In fact, i found a similar discussion topic that does not appear to be answered:

 

http://forum.fusioncharts.com/topic/13635-php-with-ajax/

 

 

If fusionCharts does not work after the content is rendered in AJAX then I will likely have to rework the page to remove the AJAX call.

 

Thanks again for your help.

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