chart-service
v1.0.2
Published
Chart.js as service
Downloads
2
Readme
chart-service
Chart.js as express service
Date 2021-03-16 Version 1.0.2
A globally installed Node CLI to start a HTTP Server listen on port 3400. The server convert JSON script in chart.js format into PNG image.
It is a service like QuickChart.io, but simplified to render charts only.
Installation
Install service globally.
npm install chart-service -g
Start
To start the service, type into console:
chart-service
To run the service on port 3333, type:
chart-service 3333
If module canvas
throws an error, try this:
npm rebuild chart-service canvas -g --force --update-binary
Configuration
Edit file config.js
. Here are the defaults
{
port: 3400, // service port
imageWidth: 800,
imageHeight: 600,
resultType: 'binary', // png
// resultType: 'dataURL', // alternative data:image/png,base64
colorScheme: 'tableau.ColorBlind10',
}
Port can be changed by command line argument.
You can pick a scheme from Color Chart.
API
POST a JSON script in body and get a PNG image
POST http://localhost:3400/chart
body
{
"chart": {"type": "bar", "data": ...} // required
"resultType": "binary" // optional dataURL
}