Skip to content

Samples

PawelDalek edited this page Jan 21, 2025 · 3 revisions

Samples

If you are looking for samples for all available export methods, you can find them in the ./samples folder. They are divided into five categories (Batch, CLI, HTTP, Node.js Module, and Resources), each in a separate folder. Below is a list of commands to run all the samples for quick usage:

Batch

The batch example allows exporting more than one chart using the CLI. To make this work, files must be separated as shown below.

  • batch{1-3}.json: highcharts-export-server --batch "./samples/batch/batch1.json=./samples/batch/batch1.png;./samples/batch/batch2.json=./samples/batch/batch2.png;./samples/batch/batch3.json=./samples/batch/batch3.png;"

CLI

The CLI examples use the --infile and --loadConfig options to load chart JSON configuration or SVG representation.

  • infileJson.json: highcharts-export-server --infile ./samples/cli/infileJson.json --outfile ./samples/cli/infileJson.png
  • infileNotJson.json: highcharts-export-server --infile ./samples/cli/infileNotJson.json --outfile ./samples/cli/infileNotJson.png
  • svgBasic.svg: highcharts-export-server --infile ./samples/cli/svgBasic.svg --outfile ./samples/cli/svgBasic.png
  • svgBigger.svg: highcharts-export-server --infile ./samples/cli/svgBigger.svg --outfile ./samples/cli/svgBigger.png
  • svgForeignObject.svg: highcharts-export-server --infile ./samples/cli/svgForeignObject.svg --outfile ./samples/cli/svgForeignObject.png

HTTP

The HTTP request examples require the server to be enabled. This can be done with the highcharts-export-server --enableServer true command. Below examples use Curl as a method to send the request.

  • requestInfile.json: curl -H "Content-Type: application/json" -X POST --data-binary "@samples/http/requestInfile.json" 127.0.0.1:7801 -o samples/http/requestInfile.png
  • requestSvg.json: curl -H "Content-Type: application/json" -X POST --data-binary "@samples/http/requestSvg.json" 127.0.0.1:7801 -o samples/http/requestSvg.png

Node.js module

The Node.js module examples show how to export charts using the available API.

  • optionsPhantom.js: node ./samples/module/optionsPhantom.js
  • optionsPuppeteer.js: node ./samples/module/optionsPuppeteer.js
  • promises.js: node ./samples/module/promises.js
  • svg.js: node ./samples/module/svg.js

Resources

The Resources category contains resources such as callback, custom code, custom options, global and theme options, resources file, etc., which are used throughout all samples and tests.

Clone this wiki locally