Phantomjs export server on tall charts cannot parse json string

I cannot get the highcharts export server to work when running phantomjs as a server.

I can get the Highcharts export server when I use the first method they offer:

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:

Rendering failed: SyntaxError: unable to parse JSON string

I tried using the sample Highcharts line and found here

my query would look like this:

curl -X POST -H "Content-Type: application / json" -d '{infile: {xAxis: {categories: ["Jan", "Feb", "Mar", "Apr", "May" "June" , “July”, “August”, “September”, “October”, “November”, “December”]}, series: [{data: [29.9,71.5,106.4,129.2,144,176,135.6,148.5, 21 6.4,194.1 , 95.6,54.4]}]}, constr: "Chart", outfile: "//tmp//chart.png"} 'localhost: 3003

+4
source share
1 answer

You need to avoid 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 is useless here. Running phantomjs as a server always displays the image as a 64-bit string representation.

+4
source

Source: https://habr.com/ru/post/1495814/


All Articles