2

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 Answers1

0

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

LeeLenalee
  • 27,463
  • 6
  • 45
  • 69
  • 1
    Thanks. I want only use mdb 5. This is part of mdb 5 modules that I got error. I don't want change anything's. I use Laravel-mix to get single js file. – Masoud Malek Jan 19 '22 at 17:46
  • 2
    Than you can't use chart.js V3, you will need to use version 2.9.4 max and version 1.0.0 of the datalabels plugin – LeeLenalee Jan 19 '22 at 18:22