1.0.27 • Published 4 years ago
charts-rendering v1.0.27
Charts Rendering
Module for charts rendering on server-side using front-end libraries(e.g. highcharts, chart.js). It uses Puppeteer, modular and written in TypeScript.
Supported charts libraries
Right now it supports Highcharts and Chart.js out-of-box.
Installation
npm install charts-rendering
Usage
const { render, exporters } = require('charts-rendering');
render(exporters.highcharts, {
init: {
// viewport of Puppeteer instance, it's better to be bigger than supposed chart size
width: 500,
height: 500,
// charts-rendering supports injecting javascript code
// in the form of script tags into rendering environment
// that could be other libraries for formatting, styles, dates etc
jsInject: [{
path: 'path/to/js/file',
}],
},
// You can specify more than one chart config for bunch rendering
// (with single Puppeteer instance)
charts: [{
file: {
// where to save chart
path: './output.png',
},
// this is simply highcharts creation config
config: {
chart: {
width: 300,
height: 100,
},
title: {
text: 'My Chart'
},
yAxis: {
labels: {
// call injected code
formatter: ({ value }) => { return injectedCode(value) },
},
},
xAxis: {
categories: ["Jan", "Feb", "Mar", "Apr", "Mar", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
},
series: [
{
type: 'line',
data: [1, 3, 2, 4]
},
{
type: 'line',
data: [5, 3, 4, 2]
}
]
}
}]
});
Adding support for other chart libraries
You can check src/exporters/highcharts.ts for example. TBD
1.0.22
4 years ago
1.0.21
4 years ago
1.0.26
4 years ago
1.0.25
4 years ago
1.0.24
4 years ago
1.0.23
4 years ago
1.0.27
4 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.2
5 years ago
1.0.3
5 years ago
1.0.1
5 years ago