score:7

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.

score:0

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"
}

score:0

Hopefully, this might help others. If you're using https for jsfiddle.net 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 'https://jsfiddle.net/' was loaded over HTTPS, but requested an insecure script 'http://code.jquery.com/jquery-migrate-1.1.0.js'. 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="https://code.highcharts.com/highcharts.js"></script>

score:2

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: https://github.com/highcharts/highcharts-export-server/issues/18

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