Reputation: 496
I've searched on the web for my problem and I found some solutions talking about phantomjs or batik. I tried to use these methods but i failed. I think it's because i didn't understand very well what I have to do.
Can someone please explain me clearly and step by step what do I have to do ?
Upvotes: 3
Views: 6267
Reputation: 290
There is an easier option if you don't mind calling a third party server (i.e. you have to be ok with your data being passed unprotected across the internet). Highcharts has their own export server that you can just call with your highcharts config object.
Check out their demo at http://export.highcharts.com/. You can use chrome inspection's network tab to see what the call looks like and duplicate it yourself. Basically you just do the following:
Pass an x-www-form-urlencoded body where you change the options key to the highcharts config object that matches your chart. Here's an example:
async:true
content:options
type:image/png
width:
scale:
constr:Chart
callback:
options: {{Your config Object here}}
Their server will respond with a string like 'files/somename.png' which you can then retrieve by calling http://export.highcharts.com/files/somename.png
I would suggest saving that image immediately on your server as I'm not sure how long they keep it alive for.
Their service is explained on their FAQ page at http://www.highcharts.com/docs/getting-started/frequently-asked-questions
And they give an explanation of the arguments you can pass to the server at http://www.highcharts.com/component/content/article/2-news/52-serverside-generated-charts#post-param
If you do still need to run your own export server then take a look at this post. Highcharts has good instructions on how to do it with example code: http://www.highcharts.com/component/content/article/2-news/52-serverside-generated-charts
Upvotes: 4