Chartjs and ChartDataLabels does not work in mdb5 pro version 2

Viewed 131

I trying to use Mdbootstrap 5 versions 2 in my project and I install different packages for it. it needs to 'chart.js' and 'chartjs-plugin-datalabels' package and I install them via npm but I got some errors that can see in the below figure. I use these version "chart.js": "^3.7.0", "chartjs-plugin-datalabels": "^2.0.0". I also use laravel-mix for creating mix version for css and js files.

enter image description here

1 Answers

Chart.js V3 has a lot of major breaking changes. For one Chart.plugins does not exist anymore, you just register and unregister things on the Chart instance directly.

Although I dont know why you would want to globally unregister a plugin. A better option is to not register it at all then. Or register it only on a per chart basis.

Changing Chartjs.plugins.unregister(ChartDataLabels) to Chartjs.unregister(ChartDataLabels) will fix your error

Related