Reputation: 43
I can't get the highcharts export server to work when running phantomjs as a server.
I am able to get the Highcharts export server working when I use the first method they suggest:
phantomjs highcharts-convert.js -infile options1.json -outfile chart1.png -scale 2.5 -width 300 -constr Chart -callback callback.js
But when I try to use phantomjs as a server I always get:
Failed rendering: SyntaxError: Unable to parse JSON string
I have tried using the sample string Highcharts provided and the one found here
my post request looks like this:
curl -X POST -H "Content-Type: application/json" -d '{infile:{xAxis:{categories:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},series:[{data:[29.9,71.5,106.4,129.2,144,176,135.6,148.5,216.4,194.1,95.6,54.4]}]},constr:"Chart",outfile:"//tmp//chart.png"}' localhost:3003
Upvotes: 4
Views: 2035
Reputation: 988
You have to escape the double quotes. This works for me.
curl -H "Content-Type: application/json" -X POST -d '{"infile":"{xAxis: {categories: [\"Jan\", \"Feb\", \"Mar\"]},series: [{data: [29.9, 71.5, 106.4]}]}"}' 127.0.0.1:3005
Note: The 'outfile' parameter has no use here. Running phantomjs as a server, outputs always a image as a 64bit string representation.
Upvotes: 4