Export charts to image/PDF |
All charts in the FusionCharts XT pack can be configured to be exported as image (JPEG or PNG) or PDF. The export can be handled either at client-side or at server-side. Exported image/PDF can be saved at client-side or stored on the server. The image (below) shows how the chart export is initiated at client-side from the chart's context menu. The initiation can also be done using JavaScript APIs. By default, these menu items do not appear in the chart. You will need to configure the export options and handlers to make the chart ready for exporting. In this section, we briefly explain all export options. FusionCharts XT, by itself, cannot directly export the charts as images. It needs assistance either from server-side scripts, or other client side Flash movies (in Flash Player 10). FusionCharts XT sends the bitmap snapshot of its chart to these objects, which in turn convert them into an image or PDF. These objects are called FusionCharts Export Handlers. The export handlers come in two flavors: Server-side Handlers and Client-side Handler. Server-side Export Handlers The server-side export handlers help you export FusionCharts XT as images/PDF with the help of scripts that are placed on your servers. We provide ready-to-use scripts for ASP.NET, PHP (uses GD and zlib library), Ruby on Rails (uses RMagick and zlib) and Java. These scripts accept compressed bitmap data from FusionCharts XT (over HTTP or HTTPS) and convert the same into images/PDFs. Post conversion, you have two options:
Note: Starting FusionCharts XT v3.3.0, JavaScript charts can be exported and saved to a server disk. To do so, you need to configure your own server. The sever should support PHP and JAVA (1.3 or above). Also, you need to place the FusionCharts PHP export handler and Apache Batik SVG Rasterizer library in your server. Client-side Export Handlers The client-side FusionCharts Export Component, as the name suggests, helps you bypass all server scripts and save the charts as images/PDFs at the client side. You will typically use client-side export when your server does not support any of the technologies mentioned in server-side exporting or you do not want to transfer data between your client and server (which in turn will make the export process faster). Client-side exporting is done using FusionCharts Export Component SWF file (needs Flash Player 10) and FusionCharts Export Javascript class. In both client and server side exports, you can configure the output formats (PDF/JPEG/PNG) that you wish to make available from your context menu along with the cosmetics of the export dialog box itself. You can also make your own custom export panels (with custom buttons, look and feel) that are displayed along with the chart in a <DIV>, and then connect the same to the chart's export handlers. Batch Export You can also use the client side Export handler to export all the charts present in a Web page upon a single click. This is called batch exporting. The exported files for each chart can then either be saved individually, or all the exported charts can be saved as a single file: |
Setting up chart for export |
To enable the export feature of the chart you need to add export settings in chart data (XML/JSON). You need to set the exportEnabled XML chart attribute or JSON chart property to 1. You also need to set whether to use client or server side export using the exportAtClient attribute and finally set the exportHandler. |
How to setup chart data for export ? |
<chart exportEnabled='1' exportAtClient='0' exportHandler='index.php' yAxisName='Sales Figure' caption='Top 5 Sales Person' numberPrefix='$'> <set label='Alex' value='25000' /> <set label='Mark' value='35000' /> <set label='David' value='42300' /> <set label='Graham' value='35300' /> <set label='John' value='31300' /> </chart> { "chart":{ "exportenabled":"1", "exportatclient":"0", "exporthandler":"index.php", "yaxisname":"Sales Figure", "caption":"Top 5 Sales Person", "numberprefix":"$" }, "data":[ { "label":"Alex", "value":"25000" }, { "label":"Mark", "value":"35000" }, { "label":"David", "value":"42300" }, { "label":"Graham", "value":"35300" }, { "label":"John", "value":"31300" } ] } |
In this example, we are using the server-side Export Handler (index.php) to assist FusionCharts XT in export of chart. |
Features provided in export |
Export feature provides a wide range of export options to explore. You can :
For more details on each export feature, please go through the Exporting as Image/PDF section. Please note that there are a few limitations of exporting pure JavaScript charts as listed below:
When rendered using JavaScript (HTML5), there is only one mode of export - at server-side. By default, JavaScript (HTML5) charts use FusionCharts server to get exported image. However you can place the PHP and JAR files on your servers and then over-ride the URL. |