ndaumalle

Unable to export charts to images using FCExporter (PHP)

Recommended Posts

Hello,

 

We are currently using FusionCharts in our php web application, it works well and we really like it.

But we need to save the charts as images as they are rendered in the page to later on create a pdf with these images.

 

We are using the php-wrapper to render the charts and i am trying to use the php-export-handler lib provided with the fusioncharts package.

I use this script to export a chart to image: 

<script type="text/javascript">
    function ExportMyChart() {
         var chartObject = FusionCharts('chartResumenCompletoID');
         if( chartObject.hasRendered() ) chartObject.exportChart(); 
   }
</script>   

My PHP code is as:

$arrDataResumenCompleto = array(
        "chart" => array(
            "caption" => "",
            "theme" => "fint",
            "paletteColors" => "#989830",
            "yAxisName" => "Porcentaje Logro (%)",
            "xAxisName" => "",
            "yAxisMaxValue" => "100",
            "yAxisMinValue" => "0",
            "plotSpacePercent" => "40",
            "numberSuffix" => "%",
            "labelDisplay" => "auto",
            "useEllipsesWhenOverflow" => "0",
            "xAxisNameFontSize" => "13",
            "yAxisNameFontSize" => "13",
			"exportEnabled" => "1",
			"exportAtClient" => "0",
			"exportHandler" => WP_PLUGIN_URL . '/wp-aprendo/lib/fusioncharts/export-handlers/php-export-handler/FCExporter.php',
			"exportAction" => "save",
			"exportShowMenuItem"=>'0',
			"exportFormat" => "png",
			"animation" => "0"
        ),
        "data" => array()
    );

/**
*More code to fill the data array with values.
*/

<div class="apChart" id="<?php echo "chartResumenCompleto"; ?>"></div>
<input type="button" value="Export My Chart" onclick="ExportMyChart()" />

    /* JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. */

    $jsonEncodedData = json_encode($arrDataResumenCompleto);

    /* Create an object for the column chart using the FusionCharts PHP class constructor. Syntax for the constructor is ` FusionCharts("type of chart", "unique chart id", width of the chart, height of the chart, "div id to render the chart", "data format", "data source")`. Because we are using JSON data to render the chart, the data format will be `json`. The variable `$jsonEncodeData` holds all the JSON data for the chart, and will be passed as the value for the data source parameter of the constructor. */

    $columnChart = new FusionCharts("bar2d", "chartResumenCompletoID", "100%", "300", "chartResumenCompleto", "json", $jsonEncodedData);

    // Render the chart
    $columnChart->render(); 

The chart is well rendered.

 

My first problem, when i click on the button to export, is that I see in firebug the following message:

 

&DOMId=&height=0&width=0&fileName=&statusMessage= Export Resource not found.&statusCode=0

After digging in the code of FCExporter.php, we see that $exporterResource = "FCExporter_IMAGE-DATA2PNG.php". We don't know why.

 

After hardcoding in FCExporter.php $exporterResource = "FCExporter_RLE2IMG.php" for purposes of testing. It saves an image in server with only light blue background.

 

Can you please help us with this? It is really urgent...

 

Greetings,

Nicolas Daumalle.

Share this post


Link to post
Share on other sites
Hello,

 

Thanks for the query.

 

Your requirement is achievable. 

 

I have tried to create a sample as per your requirement. 

 

Please find the absolute path of "index.php" file which is inside the php-export-handler folder provided with the fusioncharts package in your server, and then set that path as the value of the exportHandler attribute .


 

Please visit the link for further reference about the setup of private export server using php.


 

Kindly refer the link below for your implementation.


 

 

Hope this helps,

Thanks,

Share this post


Link to post
Share on other sites

 

Hello,
 
Thanks for the query.
 
Your requirement is achievable. 
 
I have tried to create a sample as per your requirement. 
 
Please find the absolute path of "index.php" file which is inside the php-export-handler folder provided with the fusioncharts package in your server, and then set that path as the value of the exportHandler attribute .
 
Please visit the link for further reference about the setup of private export server using php.
 
Kindly refer the link below for your implementation.
 
 
Hope this helps,
Thanks,

 

 

We got the same error; . And this solution is not working, the exporter is looking for the file: FCExporter_IMAGE-DATA2PNG.php

 

Can you please help

Share this post


Link to post
Share on other sites

Hello,

 
Thanks for your query.
 
Kindly send us the scaledown sample so that we can replicate the issue at our end.
 
However you can visit the link for further reference about the setup of private export server using php http://www.fusioncharts.com/dev/exporting-charts/server-side-export/setup-private-export-server-php.html#_ga=1.133969100.379321021.1469940518
 
Hope this will 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