[Chartjs]-Show values in Chart.js Pie chart parts

2👍

Yes, this is possible. You can achieve that using a Chart.js plugin called – Chart.PieceLabel.js.

Here is a basic example :

var chart = new Chart(ctx, {
   type: 'pie',
   data: {
      labels: ['Jan', 'Feb', 'Mar'],
      datasets: [{
         data: [30, 40, 25],
         backgroundColor: 'rgba(0,119, 220, 0.2)'
      }]
   },
   options: {
      pieceLabel: {
         render: 'value' //show values
      }
   }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.min.js"></script>
<script src="https://cdn.rawgit.com/emn178/Chart.PieceLabel.js/master/build/Chart.PieceLabel.min.js"></script>

<canvas id="ctx"></canvas>

To learn more about this plugin and it­‘s use-cases, refer here.

Leave a comment