回调函数不起作用Highcharts PhantomJS

时间:2015-02-27 20:38:47

标签: highcharts callback phantomjs

我正在使用PhantomJS将图表保存在我的服务器中,但回调函数不起作用。

phantomjs JS/highcharts-convert.js -infile temp/test.js -outfile temp/chart.png -globaloptions temp/test2.js -callback temp/call.js

call.js中的内容是:

function() {
    console.log('kamehameha');
}

一切都很好,除了回调。

1 个答案:

答案 0 :(得分:0)

使用最新版本的导出服务器和Highstock进行测试。文件:

  • call.js:

    function(chart) {chart.renderer.arc(200, 150, 100, 50, -Math.PI, 0).attr({fill : '#FCFFC5',stroke : 'black','stroke-width' : 1}).add();}
    
  • test.js:

    {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]}]}
    
  • test2.js:

    { legend: { enabled: false } }
    

工作正常,从控制台输出:

Highcharts.options.parsed
Highcharts.cb.parsed
Highcharts.globalOptions.parsed
Highcharts.customCode.parsed
temp/chart.png

生成的图片: enter image description here

编辑:
使用该回调进行测试:

 function(chart) {console.log("kamehameha"); chart.renderer.arc(200, 150, 100, 50, -Math.PI, 0).attr({fill : '#FCFFC5',stroke : 'black','stroke-width' : 1}).add();}

输出:

Highcharts.options.parsed
Highcharts.cb.parsed
Highcharts.globalOptions.parsed
Highcharts.customCode.parsed
kamehameha
temp/chart.png
相关问题