Chartjs-Using Datalabels and ChartJS with Chartjs-node-canvas

3👍

This is how to activate plugins with ChartJs-niode-canvas:

const chartJsFactory = () => {
const Chart = require('chart.js');
require('chartjs-plugin-datalabels');
delete require.cache[require.resolve('chart.js')];
delete require.cache[require.resolve('chartjs-plugin-datalabels')];
return Chart;
}

// ...

const canvasRenderService = new CanvasRenderService(
  chartWidth,
  chartHeight,
  chartCallback,
  undefined,
  chartJsFactory
);

Leave a comment