[Chartjs]-Code doesn't work after updating chart.js versioning

3👍

For a start next time might be a good idea to read the documentation and the migration guide.

Few things that are at least wrong:

  • Link name has changed to lower case so 2.9.4/Chart.js -> 3.5.0/chart.js
  • Scales have changed from 2 arrays to objects for each scale:
options: {
 scales: {
   x: {
     // config for default x scale
   },
   x2: {
     // config for second x scale
   },
   y: {
     // config for default y scale
   },
 }
}
  • title and legend config have been moved to the plugins section so options.title -> options.plugins.title and options.legend -> options.plugins.legend.

Alternativly you could also just use an older release of the datalabels plugin that has been written for V2

<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/1.0.0/chartjs-plugin-datalabels.js"></script>

Leave a comment