This is a node.js application/service that converts Highcharts.JS charts to static image files. It supports PNG, JPEG, SVG, and PDF output; and the input can be either SVG, or JSON-formatted chart options.
The application can be used either as a CLI (Command Line Interface), as an HTTP server, or as a node.js module.

First, make sure you have node.js installed. If you dont have node.js installed, kindly go this link

Hope node.js is installed,now we will install the export server

git clone https://github.com/highcharts/node-export-server
cd node-export-server/

Now install the dependent packages

yum install fontconfig freetype freetype-devel fontconfig-devel libstdc++ tar gzip unzip zip bzip2

Create log folder for highchartExport

mkdir -p /home/techrunnr/highchartsExport/logs

Now clean the npm and install phantomjs-prebuilt package

npm cache clean -f

npm install -g phantomjs-prebuilt

cd ..
npm install



[techrunnr@node-server ~]$ cd node-export-server/
[techrunnr@node-server node-export-server]$ ls
bin  build.js  CHANGELOG.md  lib  LICENSE  msg  mychart.png  node_modules  package.json  package-lock.json  phantom  post.build.js  pre.build.js  README.md  testcharts  tests
[techrunnr@node-server node-export-server]$ npm install

> highcharts-export-server@2.0.25 preinstall /home/techrunnr/node-export-server
> node ./pre.build.js

Preinstall: no tasks to be done, skipping

> highcharts-export-server@2.0.25 install /home/techrunnr/node-export-server
> node ./build.js


Highcharts Export Server

https://github.com/highcharts/node-export-server

In order to use this application, Highcharts needs to be downloaded and 
embedded. A license is required to use Highcharts if you're a 
for-profit, commercial, outfit. 

The license can be viewed here: https://shop.highsoft.com/media/highsoft/Standard-License-Agreement-6.0.pdf


IF THE DOWNLOAD FAILS:
----------------------

Are you behind a proxy?
See https://github.com/request/request#controlling-proxy-behaviour-using-environment-variables

Are you behind a company firewall?
Try running "npm config set strict-ssl=false" before installing

Agree to the license terms? y/n:  (no) y
Select your Highcharts version (e.g. 4.2.2)::  (latest) 7.0.1
Include Maps? (requires Maps license):  (no) y
Include Gantt? (requires Gantt license, and >V6.2):  (no) n
Enable styled mode? (requires Highcharts/Highstock 5+ license):  (no) n
Include moment.js for date/time handling?:  (no) y
Which CDN would you like to use?:  (https://code.highcharts.com/) 
Enable wordcloud support? y/n:  (no) y
Enable annotations support? y/n:  (no) y
Including maps support
Including moment.js support
Pulling Highcharts from CDN (7.0.1)..
   https://code.highcharts.com/stock/7.0.1/highstock.js
   https://code.highcharts.com/7.0.1/highcharts-more.js
   https://code.highcharts.com/7.0.1/modules/exporting.js
   https://code.highcharts.com/7.0.1/highcharts-3d.js
   https://code.highcharts.com/7.0.1/modules/data.js
   https://code.highcharts.com/7.0.1/modules/funnel.js
   https://code.highcharts.com/7.0.1/modules/solid-gauge.js
   https://code.highcharts.com/7.0.1/modules/heatmap.js
   https://code.highcharts.com/7.0.1/modules/treemap.js
   https://code.highcharts.com/7.0.1/modules/sunburst.js
   https://code.highcharts.com/7.0.1/modules/xrange.js
   https://code.highcharts.com/7.0.1/modules/streamgraph.js
   https://code.highcharts.com/7.0.1/modules/sankey.js
   https://code.highcharts.com/7.0.1/modules/tilemap.js
   https://code.highcharts.com/7.0.1/modules/histogram-bellcurve.js
   https://code.highcharts.com/7.0.1/modules/bullet.js
   https://code.highcharts.com/7.0.1/modules/organization.js
   organization.js is not available for v7.0.1, skipped..
   https://code.highcharts.com/7.0.1/modules/funnel3d.js
   funnel3d.js is not available for v7.0.1, skipped..
   https://code.highcharts.com/7.0.1/modules/pyramid3d.js
   pyramid3d.js is not available for v7.0.1, skipped..
   https://code.highcharts.com/7.0.1/modules/dependency-wheel.js
   dependency-wheel.js is not available for v7.0.1, skipped..
   https://code.highcharts.com/7.0.1/modules/item-series.js
   https://code.highcharts.com/7.0.1/modules/timeline.js
   https://code.highcharts.com/7.0.1/modules/pareto.js
   https://code.highcharts.com/7.0.1/modules/wordcloud.js
   https://code.highcharts.com/7.0.1/modules/annotations.js
   https://code.highcharts.com/maps/7.0.1/modules/map.js
Creating export template export..
All done! Happy charting!
For documentation, see https://github.com/highcharts/node-export-server

> highcharts-export-server@2.0.25 postinstall /home/techrunnr/node-export-server
> node ./post.build.js

[techrunnr@node-server node-export-server]$ 

[root@node-server node-export-server]# npm link
npm WARN lifecycle highcharts-export-server@2.0.25~preinstall: cannot run in wd %s %s (wd=%s) highcharts-export-server@2.0.25 node ./pre.build.js /home/techrunnr/node-export-server
npm WARN lifecycle highcharts-export-server@2.0.25~install: cannot run in wd %s %s (wd=%s) highcharts-export-server@2.0.25 node ./build.js /home/techrunnr/node-export-server
npm WARN lifecycle highcharts-export-server@2.0.25~postinstall: cannot run in wd %s %s (wd=%s) highcharts-export-server@2.0.25 node ./post.build.js /home/techrunnr/node-export-server
/usr/bin/highcharts-export-server -> /usr/lib/node_modules/highcharts-export-server/bin/cli.js
/usr/lib/node_modules/highcharts-export-server -> /home/techrunnr/node-export-server
[root@node-server node-export-server]#

Lets create to start script for the highchart export server

cd scripts/
vim start_highstart.sh
/usr/lib/node_modules/highcharts-export-server/bin/cli.js --enableServer 1 --tmpDir /home/techrunnr/highchartsExport --logDest /home/techrunnr/highchartsExport/logs --logLevel 4 &

Stop script for highchart export server

vim stop_highstart.sh
pkill -9 -f node

Give execute permission for both the scripts.

chmod 755 stop_highstart.sh
chmod 755 start_highstart.sh

We can test highchart export through one curl command

[root@node-server ~]# 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
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14571  100 14435  100   136  14435    136  0:00:01 --:--:--  0:00:01 54984

Now we have setted up high Chart Exporter.

© 2019, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

0 Comments

Leave a Reply

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.