FusionCharts export handler for Ruby on Rails.
2.0
Add this line to your application's Gemfile:
gem 'fusioncharts_exporter'
And then execute:
$ bundle
FusionCharts Suite XT uses JavaScript to generate charts in the browser, using SVG and VML (for older IE). If you need to export the charts as images or PDF, you need a server-side helper library to convert the SVG to image/PDF. These export handlers allow you to take the SVG from FusionCharts charts and convert to image/PDF.
- A chart is generated in the browser. When the export to image or PDF button is clicked, the chart generates the SVG string to represent the current state and sends to the export handler. The export handler URL is configured via chart attributes.
- The export handler accepts the SVG string along with chart configuration like chart type, width, height etc., and uses RMagick library to convert to image or PDF.
- The export handler either writes the image or PDF to disk, based on the configuration provided by chart, or streams it back to the browser.
You will have to install the following applications without which the exporter will fail to run.
Dependencies to run the this controller
- rmagick
- json
Installing rmagick in ubuntu
-
First, check that the universe repository is enabled by inspecting '/etc/apt/sources.list' with your favourite editor.
-
You will need to use sudo to ensure that you have permissions to edit the file.
-
If universe is not included then modify the file so that it does.
-
deb http://us.archive.ubuntu.com/ubuntu precise main universe
-
After any changes you should run this command to update your system.
-
sudo apt-get update
-
You can now install the package like this.
-
Install librmagick-ruby sudo apt-get install librmagick-ruby
-
Add this line to your application’s gemfile
-
gem "rmagick", "~> 2.13.1"
The following are the configurables to be modified as required in the app/controllerfc_exporter_controller.rb
:
Location on the server where the image will be saved.
save_path
You will have to specify the end point of the export server. In order to do this, you will have to mount the export handler to your rails application. Add the following lines in config/routes.rb
.
For eg., if you want your export server hosted at http://<my-website>/export
, then add the following lines:
post 'fc_exporter/init'
get 'fc_exporter/init'
- Clone the repository:
TODO
- Run
bundle install
- Run
rails server