Demos

Beginner's Guide

Charts / Gauges / Maps Guide

Customizing Charts

API

Integrating With Your Stack

Help

Loading

Introduction

To setup a private export server in PHP, you will need the official PHP export handler provided in the FusionCharts package. The export handler will provide the necessary files to configure the export server. It will handle all requests sent by the user for exporting and generate the chart in the requested format.
The PHP export handler is dependent on two external modules, namely, Inkscape and ImageMagick. These two need to be downloaded and installed separately on the same server.

How does it work?

  • A chart is rendered in the browser.

  • When the export to image/PDF option is selected, the chart generates the SVG string that represents the current state and sends to the export server.

  • The export server captures the SVG string.

  • The export server invokes a system call, triggering Inkscape to convert FusionCharts generated SVG string (which is passed to the server side script over AJAX) to PDF, PNG and SVG. However, Inkscape still has a limitation of generating a JPG file. Hence, ImageMagick is used to create the JPG files.

  • The export handler either writes the image or PDF to disk, based on the configuration provided by chart, or streams it back to the user as a download.

Installation

  • Setup a Linux-based server with administrative access to install the export handler. This is particularly important, if you are using a shared hosting service for your web server.

  • Install both Inkscape and ImageMagick as they are necessary dependencies for the PHP export handler to work.

  • Copy files from the FusionCharts PHP Export Handler to the Linux server.

  • The folders named tmp and ExportedImages should be placed at the same folder level as the index.php.

  • Both the folders should have write access, as the temporary and saved image files will be written to them.

Inkscape:

Inkscape is an open source vector graphics editor. What sets Inkscape apart is its use of Scalable Vector Graphics (SVG), an open XML-based W3C standard, as the native format. Inkscape has a powerful command line interface and can be used in scripts for a variety of tasks, such as exporting and format conversions. For more details, click here.

ImageMagick:

ImageMagick is a free and open-source software suite for displaying, converting, and editing raster image and vector image files. The software mainly consists of a number of command-line interface utilities for manipulating images.
For further details, click here.

Configuring the export server

To use the private export server, the following attributes need to be configured correctly in the chart.

Attribute Name Description

exportEnabled

Set value to 1 to enable exporting for the chart.

exportAtClient

Set value to 0 to enable export via a Private Export Server.

exportHandler

Set to absolute path of the export handler e.g. http://www.example.com/fcExportHandler/index.php.

exportAction

Set value to save to store the exported file on the private export server itself. Set to download to send the file back to the user (client) for download.

Top