chartjs / chartjs-plugin-datalabels

Chart.js plugin to display labels on data elements
https://chartjs-plugin-datalabels.netlify.app
MIT License
863 stars 460 forks source link

Not working with chartjs 3.6.2 #302

Closed martinjankov closed 2 years ago

martinjankov commented 2 years ago

https://jsfiddle.net/th4z9cfL/

stockiNail commented 2 years ago

@martinjankov if I'm not wrong, you are using Datalabels version 0.4.0.

For Chartjs 3.x, you need Datalabels 2.0.

Furthermore, please have a look to the plugin registration: https://chartjs-plugin-datalabels.netlify.app/guide/getting-started.html#registration

stockiNail commented 2 years ago

@martinjankov I have tested with your sample:

  1. change Datalabels, using https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0/dist/chartjs-plugin-datalabels.min.js
  2. add plugins: [ChartDataLabels], in chart configuration, after type: 'pie'

Result:

image

David-OConnor commented 3 months ago

Hey! Shoutout to this fix! The syntax I'm finding everywhere, including the datalabels home page, Stack Overflow, ChatGpt etc is showing wrong or oudated syntax that is orthogonal to this. (Results in no labels, and no errors to explain why). stockiNail's syntax works.