1π
β
I revisited this problem today and found a solution really quick.
Accessing the βhiddenβ property can be done like in this post: Tell if an line is hidden
This is the updated code:
callbacks: {
label: function(tooltipItem, data) {
let total = 0;
let value = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
let stop = tooltipItem.datasetIndex+1;
for (let j = 0; j < stop; j++) {
if(!data.datasets[j]._meta[Object.keys(data.datasets[j]._meta)[0]].hidden) {
total += data.datasets[j].data[tooltipItem.index];
}
}
total = Math.floor(total * 100) / 100;
return 'Value: ' + value + ' Total: ' + total;
}
}
Source:stackexchange.com