1.0.2 • Published 4 years ago

chart-service v1.0.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
4 years ago

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
}
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago