Below is a demonstration showcasing a customized tooltip label:
https://i.sstatic.net/dSkaw.png
let context = document.getElementById("myChart");
let chartData = {
labels: ["Jan/16", "Feb/16", "Mar/16", "Abr/16", "May/16", "Jun/16", "Jul/16"],
datasets: [{
type: 'bar',
label: "Revenue (US$)",
data: [4000, 4850, 5900, 6210, 2500, 4000, 6500],
backgroundColor: 'rgba(0, 0, 255, 0.3)'
}]
};
let myCustomChart = new Chart(context,
{
type: 'bar',
data: chartData,
options: {
responsive: true,
tooltips: {
callbacks: { // CUSTOMIZING THE LABELS
title: function() {
return '***** My customized label title *****';
},
beforeLabel: function(tooltipItem, data) {
return 'Month: ' + tooltipItem.xLabel;
},
label: function(tooltipItem, data) {
return data.datasets[tooltipItem.datasetIndex].label + ': ' + tooltipItem.yLabel;
},
afterLabel: function(tooltipItem, data) {
return '***** Test *****';
},
}
},
scales: {
xAxes: [{
display: true,
labels: {
show: true,
}
}],
yAxes: [{
type: "linear",
display: true,
position: "left",
labels: { show: true },
ticks: {
beginAtZero: true
}
}]
}
}
});