Hi All,
Has anyone successfully implemented a custom data label for Charter?
Ive been playing around with piecharts and have been able to get the tooltip to display the percentage value using the following call back code.
callbacks: {
label: function(tooltipItem, data) {
var dataset = data.datasets[tooltipItem.datasetIndex];
var meta = dataset._meta[Object.keys(dataset._meta)[0]];
var total = meta.total;
var currentValue = dataset.data[tooltipItem.index];
var percentage = parseFloat((currentValue/total*100).toFixed(1));
return currentValue + ’ (’ + percentage + ‘%)’;
},
title: function(tooltipItem, data) {
return data.labels[tooltipItem[0].index];
}
}
However, I’m not sure how to adapt this to a data-label in order to display the percentage value instead of the number value in the csv. Has anyone managed to get this to work?