Open igordata opened 8 months ago
I feel stuck. Any ideas? 😅
Hi, This appears to be a bug in chartjs-plugin-datalabels. In the code - there is a function getPositioner() which returns the positioned depending on the class of the element. However - the code imports chart.js - and the element was created by another part of the code which imported chart.cjs - Javascript thinks the two are different classes - and this causes the code to fail.
You can troubleshoot this in the browser by setting a breakpoint in getPositioner(). Compare Object.getPrototypeOf(el) with chart_js.ArcElement - the constructor shows the source files are different.
Assuming you are using ESM (import/export), change your import from
import ChartJSDataLabel from 'chartjs-plugin-datalabels';
to
import ChartJSDataLabel from 'chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.esm.js';
Note: You must change this in all files that import chartjs-plugin-datalabels.
A stacked bar chart works though. Which is weird.
Hello,
I'm trying to make it work with Chart.js server side, node.js 19 and chartjs-plugin-datalabels version 2.2.0
Chart.js 4.4.1 or 4.4.0 - same error
here is the log:
Node.js v19.9.0
Just in case:
Any help will be appreciated!