Export charts to image/PDF |
All charts in the FusionCharts 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 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'll 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, 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 sends the 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 & Client-side Handler. Server-side Export Handlers The server-side export handlers help you export FusionCharts 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 (over HTTP or HTTPS) and convert the same into images/PDFs. Post conversion, you've two options:
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 would typically use client-side export when your server doesn't support any of the technologies mentioned in server-side exporting or you don’t 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 & 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 export feature of the chart you need to add export settings in chart data (XML/JSON). You need to set exportEnabled XML chart attribute or JSON chart property to 1. You also need to set whether to use client or server side export using exportAtClient attribute and finally set the exportHandler. |
How to setup chart data for export ? |
<chart exportEnabled='1' exportAtClient='0' exportHandler='FCExporter.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":"FCExporter.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're using the server-side Export Handler (FCExporter.php) to assist FusionCharts 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 Exporting as Image/PDF section. |