chartjs-node-plugin-colorschemes

Nodejs compatible fork of chartjs-plugin-colorschemes

Usage no npm install needed!

<script type="module">
  import chartjsNodePluginColorschemes from 'https://cdn.skypack.dev/chartjs-node-plugin-colorschemes';
</script>

README

chartjs-node-plugin-colorschemes

This is a nodejs compatible fork of chartjs-plugin-colorschemes, which basically just converts the ES6 modules to CommonJS modules, and changes the API somewhat, so that it can be used server-side with packages like chartjs-node.

Usage

To register the plugin to chartjs-node, use the following:

const colorschemes = require('chartjs-node-plugin-colorschemes');

const chart = new ChartjsNode(parsed.dimensions.width, parsed.dimensions.height);

chart.on('beforeDraw', (instance) => {
    colorschemes(instance);
});

You can then pass the desired color scheme in the chartjs configuration like so:

{
    "options": {
        "plugins": {
            "colorschemes": {
                "scheme": "brewer.Spectral11"
            }
        }
    }
}

See the chartjs-plugin-colorschemes website for more usage information and a list of available color schemes.

License

chartjs-plugin-colorschemes is available under the MIT license.