Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgwalker/chartjs-node
Wrapper for creating Chart.js charts from Node
https://github.com/mgwalker/chartjs-node
chart chartjs node nodejs
Last synced: about 1 month ago
JSON representation
Wrapper for creating Chart.js charts from Node
- Host: GitHub
- URL: https://github.com/mgwalker/chartjs-node
- Owner: mgwalker
- Created: 2021-09-05T03:35:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-19T04:03:28.000Z (over 1 year ago)
- Last Synced: 2024-11-19T05:05:12.089Z (about 2 months ago)
- Topics: chart, chartjs, node, nodejs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@mgwalker/chartjs-node
- Size: 2.94 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![snapshot test status badge](https://github.com/mgwalker/chartjs-node/actions/workflows/test.yaml/badge.svg)](https://github.com/mgwalker/chartjs-node/actions/workflows/test.yaml)
# Chart.js-node
Build static [Chart.js](https://www.chartjs.org) 3.x charts in Node. It's a lot
like using Chart.js directly, but with a few tweaks.### Getting started
```shell
npm install @mgwalker/chartjs-node
```And then to use it:
```javascript
import Chart from "@mgwalker/chartjs-node";const myChart = new Chart([width, height], config);
```The `config` option is a complete [Chart.js configuration](https://www.chartjs.org/docs/latest/configuration/)
object, including datasets, options, etc. Note that `options.animations` is
always set to `false` since the rendered image is static.chartjs-node includes [chartjs-adapter-luxon](https://github.com/chartjs/chartjs-adapter-luxon),
[chartjs-plugin-annotation](https://github.com/chartjs/chartjs-plugin-annotation), and
[chartjs-plugin-datalabels](https://github.com/chartjs/chartjs-plugin-datalabels),
so you can also use any configuration for those. Please note that the datalabels
plugin is disabled unless you provide configuration for it.> Other plugins are not included because they don't work with Chart.js 3.x.
The `config` can also include some options that are specific to chartjs-node:
| path | description | default |
| ------------------------- | -------------------------------------------------------------------------------------------------- | ------- |
| `deviceScaleFactor` | When rendering the image, what device scale factor to use. Set larger to get clearer antialiasing. | 1 |
| `options.backgroundColor` | The background color of the generated chart. | `white` |To save your chart:
```javascript
await myChart.save([path]);
```If `path` is provided, the chart will be saved as a PNG to the provided path. If
`path` is omitted, `save()` will resolve with a buffer containing the PNG.