Hito_kun

Render HTML5 charts with the PHP API?

Recommended Posts

I want to display charts in mobile devices and browsers using the HTML5 charts.

 

Doing my tests, with the javascript API it correctly fallbacks to HTML5 when flash is not available, but when trying to generate the charts from the PHP API, it never loads, not even the examples.

 

So, is it possible using PHP or I have to use straight javascript to draw the charts?

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

To configure the charts to exclusively render in JavaScript (HTML5) mode, enabling your chart in browsers/devices where Flash is not supported like that of iPhone, iPad, etc, you would need to call  "FC_SetRenderer()" function in PHP before you render your chart. Using this function you need to set the current chart renderer to javascript.

 

Ref. Code Snippet:

FC_SetRenderer( "javascript" );
  ...
echo renderChart("../../FusionCharts/Column2D.swf", "Data/Data.xml", "", "chart1", 600, 300, false, true); 

For more information on this, please visit the link: http://docs.fusioncharts.com/charts/contents/guide-for-web-developers/php/PHP_BasicExample.html

 

Hope this helps!

Share this post


Link to post
Share on other sites

Hi,

 

You may try like this:

 

<script language="JavaScript" src="FusionCharts/FusionCharts.js"></script>
    <div class="gen-chart-render">
            <center>
                <div id="customerAgingContainer1">Customer Aging Pie Chart will load here</div>
                <script type="text/javascript"><!--
                    
                    FusionCharts.setCurrentRenderer('JavaScript');
                    var Chart1 = new FusionCharts("chart/Charts/Pie3D.swf", "myChartId", "100%", "45%", "0", "0");
                    Chart1.setXMLUrl("chart/sd/sd_customer_aging_div_01_data.xml");
                    Chart1.render("customerAgingContainer1");
                </script>
            </center>
    </div>

 

Thanks
 

Edited by Julhas Sujan

Share this post


Link to post
Share on other sites

Hi,

 

The way Sashibhushan had mentioned is used to generate the charts from the PHP API and the way you have mentioned is used to render charts through FusionCharts constructor.  :) 

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