Could you tell me what to add in the chartJS options to have the legend title also into the tooltip title? In the screenshot attached, you can see I'd like to add a reminder of the year in the title of the tooltip.
var chartdata = {
labels: ['Jan','Fev','Mar','Avr','Mai','Jui','Jui','Aou','Sep','Oct','Nov','Dec'],
datasets: JSON.parse('<?php echo $datasets ?>')
};
var graphTarget = $("#graphCanvas");
var barGraph = new Chart(graphTarget, {
type: 'bar',
data: chartdata,
options: {
responsive: true,
legend: {
position: 'right',
},
title: {
display: true,
text: 'Consommation électrique'
},
tooltips: {
enabled: true,
mode: 'single',
callbacks: {
label: function(tooltipItems, data) {
return tooltipItems.yLabel + ' kW';
}
}
},
scales: {
yAxes: [{
ticks: {
// Includes 'kW' after the value
callback: function(value, index, values) {
return value + ' kW';
}
}
}]
}
}
});
Thank you!
