Accepted answer

I have the exact same problem, although my command looks a bit different:

phantomjs  highcharts-convert.js -infile delete_this.json -outfile /home/max/BLA.png -width 300 -constr Chart -resources highcharts.js,jquery.js

as you see i included the needed files using the -resources option of phantom js, but i still get the 'Can't find variable: Highcharts' Error.

Maybe the resources part helps you?

EDIT: I solved my issue, and yours as well i think.

If you use the command like i described it, it doesn't give you the Highcharts error, BUT it breaks when trying to parse the resources. That is due to a grave error in the current version of the highcharts-convert.js script.

In line 682 they split the arguments, but they use an undefined parameter resources.

fileList = resources.split('\,');

You need to change that to:

fileList = params.resources.split('\,');

It works for me now, i hope it helps you.


Solution number 2

Create a file called resources.js with the following contents and place it in the same folder as options.js. Now you don't need to edit highcharts-convert.js and it will still work.

    "files": "highcharts.js"


Hopefully, this might help others. If you're using https for then make sure you're including the highcharts library with https too. Otherwise you would get "ReferenceError: Can't find variable: Highcharts" in Safari console(not very helpful). In chrome console, you get a clear message. "Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure script ''. This request has been blocked; the content must be served over HTTPS.

For https make sure you have the following in the html window of jsfiddle:

<script src=""></script>


Thank you for the solution @max-uppenkamp. The Highcharts team should integrate this into their code without delay! EDIT: I see you have already notified them:

I note that a command-line as minimal as this will still work:

phantomjs highcharts-convert.js -infile options.json -outfile chart.png -resources highcharts.js

Also, I only need highcharts.js, highcharts-convert.js and options.js in my folder. Seems that I don't need highcharts-more or jquery.

NB. My options.json file looks like this:

{ chart: { type: 'bar' }, title: { text: 'Fruit Consumption' }, xAxis: { categories: ['Apples', 'Bananas', 'Oranges'] }, yAxis: { title: { text: 'Fruit eaten' } }, series: [{ name: 'Jane', data: [1, 0, 4] }, { name: 'John', data: [5, 7, 3] }] }

Related Query

More Query from same tag