Skip to content Skip to sidebar Skip to footer

Show The Values Of Each Arc On Doughtnut Chart Of Chart.js

This is my current doughnut chart and I want to show the values of each arc on the arc itself. This is the configurations of the chart. const genderConfig={ plugins: { title:

Solution 1:

You can make use of the chart.js datalabels plugin, vor V3 they currently have a release candidate, there is 1 issue thats needs to be resolved before it can be released officially according to this issue of them: https://github.com/chartjs/chartjs-plugin-datalabels/discussions/213

V3 example:

Chart.register(ChartDataLabels)
var options = {
  type: 'pie',
  data: {
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [{
        label: '# of Votes',
        data: [12, 19, 3, 5, 2, 3],
        borderWidth: 1
      },
      {
        label: '# of Points',
        data: [7, 11, 5, 8, 3, 7],
        borderWidth: 1
      }
    ]
  },
  options: {}
}

var ctx = document.getElementById('chartJSContainer').getContext('2d');
newChart(ctx, options);
<body><canvasid="chartJSContainer"width="600"height="400"></canvas><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.2.1/chart.js"></script><scriptsrc="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0-rc/dist/chartjs-plugin-datalabels.min.js"></script></body>

Post a Comment for "Show The Values Of Each Arc On Doughtnut Chart Of Chart.js"