canvas_exporting
Controller action to allow export of CanvasJS chart to png/jpg file.
Installation
Add this line to your application's Gemfile:
gem 'canvas_exporting'
And then execute:
$ bundle
Or install it yourself as:
$ gem install canvas_exporting
Usage
Add canvas_controller.rb
and add route post 'canvas/export'
.
class CanvasController < ApplicationController
include CanvasExporting::Exporter
end
Config url /canvas/export
for canvas exporting.
OR
Using curl:
Curl::Easy.http_post("http://localhost:3000/canvas/export",
Curl::PostField.content('options', options_JSON.to_s),
Curl::PostField.content('type', 'image/png'),
Curl::PostField.content('callback', cb_js_filename),
Curl::PostField.content('width', '400'),
Curl::PostField.content('outputpath', path_to_image_file),
Curl::PostField.content('filename', image_filename)
)
References
https://github.com/bastengao/highcharts_exporting
Contributing
- Fork it ( https://github.com/notch8/canvas_exporting/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request