~jstys-z/helioviewer.org/timeline

« back to all changes in this revision

Viewing changes to timeline/Highstock-1.3.10/exporting-server/phantomjs/readme.md

  • Committer: Jeff Stys
  • Date: 2014-04-21 12:46:26 UTC
  • Revision ID: jstys@sesda3.com-20140421124626-2332pb2dyjc33jxi
Proof-of-concept version of Data Coverage Timeline using Highchart/Highstock javascript library.  Changes to getDataCoverage API in order to feed the necessary data to the Timeline

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#The Highcharts image convert script#
 
2
The file highcharts-convert.js is a [PhantomJS](http://phantomjs.org/) script to convert SVG or Highcharts JSON options objects to chart images. It is ideal for batch processing Highcharts configurations for attaching to emails or reports. It is also used in the featured (Java based) export server. An online demo with a GUI can be viewed at [export.highcharts.com/demo](http://export.highcharts.com/demo).
 
3
 
 
4
#Example usage#
 
5
        for commandline use.
 
6
        phantomjs highcharts-convert.js -infile options1.json -outfile chart1.png -scale 2.5 -width 300 -constr Chart -callback callback.js
 
7
 
 
8
        Run Phantomjs as Http-server.
 
9
        phantomjs highcharts-convert.js -host 127.0.0.1 -port 3003
 
10
 
 
11
 
 
12
#Description of command line parameters#
 
13
 
 
14
**-infile:** The file to convert, assumes it's either a JSON file, the script checks for the input file to have the extension '.json', or otherwise it assumes it to be an svg file.
 
15
 
 
16
**-outfile:** The file to output. Must be a filename with the extension .jpg, .png .pdf or .svg.
 
17
 
 
18
**-scale:** To set the zoomFactor of the page rendered by PhantomJs. For example, if the _chart.width_ option in the chart configuration is set to 600 and the scale is set to 2, the output raster image will have a pixel width of 1200. So this is a convenient way of increasing the resolution without decreasing the font size and line widths in the chart. This is ignored if the _-width_ parameter is set.
 
19
 
 
20
**-width:** Set the exact pixel width of the exported image or pdf. This overrides the _-scale_ parameter.
 
21
 
 
22
**-constr:** The constructor name. Can be one of _Chart_ or _StockChart_. This depends on whether you want to generate Highstock or basic Highcharts.
 
23
 
 
24
**-callback:** Filename of the _callback_. The _callback_ is a function which will be called in the constructor of Highcharts to be executed on chart load. All code of the callback must be enclosed by a function. See this example of contents of the callback file:
 
25
 
 
26
        function(chart) {
 
27
            chart.renderer.arc(200, 150, 100, 50, -Math.PI, 0).attr({
 
28
                fill : '#FCFFC5',
 
29
                stroke : 'black',
 
30
                'stroke-width' : 1
 
31
             }).add();
 
32
        }
 
33
 
 
34
**-host** The hostname Phantomjs is listening to for POST-requests. If this parameter is specified, phantomjs startsup as Http-server.
 
35
 
 
36
**-port** The portnumber Phantomjs is listening to for POST-requests.
 
37
 
 
38
#Running the script as Httpserver
 
39
Start the Phantomjs as a server. You can use the same script as for commandline usage. Start the server like this.
 
40
        phantomjs highcharts-convert.js -host 127.0.0.1 -port 3003
 
41
You can ofcourse change the host and port to your needs. The server listens only to a POST-request. You can use the the same parameters as for commandline usage, but wrap them in a JSON structure.
 
42
 
 
43
Example of an POST request
 
44
 
 
45
        "{"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"}"
 
46
 
 
47
#Installation of Phantomjs#
 
48
See http://phantomjs.org/download.html