0

I've created a pie chart using the chart.js and react-chartjs-2 library but I was wondering if there is a way to display the data over the chart component and not as a tooltip while hovering about each area of the pie chart

What I wanted to do is display the data related to each area over itself, like on top of it.

justAbajit
  • 33
  • 5
  • This can be done with `chartjs-plugin-datalabels` as explained here for example: https://stackoverflow.com/a/59403435/2358409 or https://stackoverflow.com/a/67623057/2358409 – uminder Feb 24 '22 at 05:55

1 Answers1

-1

The options can be added while creating new chart

var pieChart = new Chart(canvas, {
type: "pie",
data: data,
options: {
     legend: {
        display: true,
        position : 'top'
     },
     tooltips: {
        enabled: false
     }
}
});
  • First this syntax you are using is outdated and incorrect, also the legend is on by default and this does not show the data of the chart above it, just the labels – LeeLenalee Feb 24 '22 at 09:40
  • Thanks for your answer but this doesn't work. I wanted it to display over each slice. – justAbajit Feb 25 '22 at 06:47