Linux Tutorials, Guides & Latest Tech Stuffs

How to install Highcharts export server on ubuntu

Highcharts is a javascript based charting library, that is used for creating interactive charts for webpages. This post will share experience of installing highcharts.js export server on Ubuntu 18.04.

Highcharts Exporter is a Node.js application that converts Highcharts.JS charts to static image files. It supports PNG, JPEG, SVG and pdf outputs. Export server can accept input in either SVG or JSON format.

Use Cases for Highcharts export server

  • Particularly used for headless conversion of charts.
  • Automatic report generation, static caching etc.
  • Export charts in image, svg and pdf formats that can be included in presentation and documents.

Export server can be integrated with the application in  a way that the export button on charts route to your own export server.

For Highcharts export server routing following configuration can be added

{
  exporting: {
    url: "<IP of self hosted export server"
  }
}

How to install Highcharts Export Server on Ubuntu 18.04

Step 1: SSH to your ubuntu server or login to local ubuntu machine.

Step 2: Install Node.JS and NPM

Step 3: Installing Highcharts Export Server

Once node.js  and npm are installed, run following command on terminal to install export server.

npm install highcharts-export-server -g

here -g means npm package will be globally installed and can be accessible from any directory path.

It can also be installed using its github repository

git clone https://github.com/highcharts/node-export-server
npm install
npm link

After completion of installation you can start highchart export server by simply running following command on terminal.

Step-4: Starting Highcharts Export server

highcharts-export-server enableServer 1

Default port of Highcharts export server

By Default  Highcharts export server runs on Port 7801

How to test highcharts-export server installation

Run following curl command, that will generate a example chart and save it as mychart.png

# Generate a chart and save it to mychart.png
curl -H "Content-Type: application/json" -X POST -d '{"infile":{"title": {"text": "Steep Chart"}, "xAxis": {"categories": ["Jan", "Feb", "Mar"]}, "series": [{"data": [29.9, 71.5, 106.4]}]}}' 127.0.0.1:7801 -o mychart.png

mychart.png should successfully downloaded, it means highcharts export server installation is completed.

Running Highcharts.JS export server with Forever

Directly running export server on terminal will not keep it running for long, As long terminal is connected export server will be up. For continuous running of export server we required to use daemon service. One such popular daemon service is forever.

forever start --killSignal SIGINT /usr/local/lib/node_modules/highcharts-export-server/bin/cli.js --enableServer 1 --tmpDir /tmp/tmp --logLevel 1

Verifying if export server is successfully running wit forever, running forever list command will show all running forever processes. As shown in image below

Forever list

install-highcharts-export-server

 

 

Pranav K

Pranav K is a software engineer and all-round computer geek. His interests include AWS, Ubuntu and Wordpress

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.