score:5

In react-chartjs-2 you can access the datasets through chart.config.data.datasets.

So for:

data = {
    labels: [
        'Red',
        'Green',
        'Yellow'
    ],
    datasets: [{
        data: [300, 50, 100],
    ...

Inside the draw callback in Chart.helpers.extend you can use:

var sum = 0;
for (var i = 0; i < this.chart.config.data.datasets[0].data.length; i++) {
   sum += this.chart.config.data.datasets[0].data[i];
}

Here's an example Codepen: http://codepen.io/anon/pen/xqMQQB?editors=1010


Related Query

More Query from same tag