使用phantomjs从cmdline导出高图

时间:2014-05-21 19:16:55

标签: highcharts

我正在尝试从命令行导出高图图表,按照高图网站在此处提供的步骤进行操作:http://www.highcharts.com/docs/export-module/render-charts-serverside

此错误始终失败:

ReferenceError: Can't find variable: Highcharts

更详细地说,他们给出的步骤就是:

  1. 下载并安装phantomjs
  2. 将这些文件全部保存到一个位置:highcharts-convert.js,highcharts.js,highcharts-more.js,jquery
  3. 很高兴。
  4. 所以,我按照上面显示的步骤进行了操作:

    首先,安装phantomjs:

    >npm install -g phantomjs
    

    验证安装:

    >phantomjs -v
    1.9.7
    

    其次,将指示文件保存在一个位置,正如您在此处所见,我有:

    >ls
    
    data.js  highcharts-convert.js  highcharts.js    map.js options.json
    highcharts-3d.js    highcharts-more.js  jquery.1.9.1.min.js readme.md
    

    第三,我应该好好去,但是......:

    一个。他们的示例命令需要一个“options.json”文件来提供选项。我在他们的网站上找不到这方面的文档,但谷歌搜索它,我的options.json文件看起来像这样:

    >more options.json
    
    {
        "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]
        }]
    }
    

    B中。运行在highcharts页面上提供的示例命令行:

    >phantomjs highcharts-convert.js -infile options.json -outfile chart.png -scale 2.5 -width 300
    
    ReferenceError: Can't find variable: Highcharts
    
     highcharts-more.js:51
    ReferenceError: Can't find variable: Highcharts
    
      data.js:16
    ReferenceError: Can't find variable: Highcharts
    
    phantomjs://webpage.evaluate():81
    phantomjs://webpage.evaluate():150
    phantomjs://webpage.evaluate():150
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    waiting
    ERROR: While rendering, there's is a timeout reached
    

    请注意,我还尝试编辑highcharts-convert.js脚本以提供highcharts和jquery文件的完整路径,但这没有帮助。

1 个答案:

答案 0 :(得分:0)

在highcharts-convert.js中,您有服务器加载的所有文件的列表,如果您丢失了更多的高图,而其他文件则会收到错误。我建议你评论你不使用的文件。