非常感谢。
我想设置 phantomjs Highcharts 导出服务器。它应该接受 json 选项作为输入和输出 jpeg 图像文件。
这是我所做的:
- 我从此存储库下载服务器端 js 代码:https://github.com/highslide-software/highcharts.com/tree/master/exporting-server/phantomjs https://github.com/highslide-software/highcharts.com/tree/master/exporting-server/phantomjs
- 我下载的是phantomjs 1.6.0
-
跑步
phantomjs highcharts-convert.js -host 127.0.0.1 -port 3001
然后我尝试在此站点中使用客户端代码:http://export.highcharts.com/demo http://export.highcharts.com/demo发送请求。我更改了表单操作网址:
<form id="exportForm" action="./" method="POST">
to this:
<form id="exportForm" action="http://0.0.0.0:3001" method="POST">
并单击“Highcharts 配置对象 (JSON)”。我收到的只是这条消息:
渲染失败:
语法错误:无法解析 JSON 字符串
由于相同的请求可以在 Highcharts 服务器中正确处理,因此错误一定是在我正在使用的 Highcharts 服务器端 js 代码中。我还尝试了以下命令:
phantomjs highcharts-convert.js -infile options.js \
-outfile chart.png -scale 2.5 -width 300
有了这段代码options.js
:
{
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.0,176.0,135.6,148.5,
216.4,194.1,95.6,54.4]
}]
},
callback: function(chart){
chart.renderer
.arc(200,150,100,50,-Math.PI,0)
.attr({fill:'#FCFFC5',stroke:'black','stroke-width':1})
.add();
},
constr: "Chart",
outfile: "//tmp//chart.png"
}
并且成功生成了png。
我猜想 Highchart 并没有在导出函数上做太多工作,而且我在 highcharts-convert.js 文件中发现了一些拼写错误。谁可以帮我这个事?多谢。