2👍
✅
Apparently version 3.X.X has several bugs to add a plugin, I finished solving by following this Issues
import { ChartJSNodeCanvas } from 'chartjs-node-canvas';
const canvas = new ChartJSNodeCanvas({
width: 700,
height: 400,
chartCallback: (ChartJS) => {
/** Add plugins here **/
ChartJS.register(require('chartjs-plugin-datalabels'))
}
});
0👍
In version 4.x.x
, it is safest to connect new plugins as:
const canvas = new ChartJSNodeCanvas({
width: 400,
height: 400,
backgroundColour: "white",
plugins: {
/** Add plugins here **/
modern: ["chartjs-plugin-datalabels"],
}
})
because the method via ChartJS.register(require('plugin-name'))
is unsafe and cand lead to various errors, as happened in my case. Developers are talking about it
Source:stackexchange.com