Is it possible to have the label & units when my mouse pointer is hover the chart ? For now there is only the number.
For the example bellow I would like to show :
My options looks like this :
var options = {
//Boolean - Show a backdrop to the scale label
scaleShowLabelBackdrop : true,
//Boolean - Whether to show labels on the scale
scaleShowLabels : true,
// Boolean - Whether the scale should begin at zero
scaleBeginAtZero : true,
scaleLabel : "<%%= Number(value) + ' %'%>",
legendTemplate: "<ul class=\"<%%=name.toLowerCase()%>-legend\"><%% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%%=datasets[i].strokeColor%>\"></span><%%if(datasets[i].label){%><%%=datasets[i].label%> <strong><%%=datasets[i].value%></strong><%%}%></li><%%}%></ul>",
tooltipTemplate: "<%%= value %> Label"
}
With scaleLabel option I have the % shown on the Y-axis but not on the hover pop-up...
I found the solution on the ChartJS repository on Github.
The solution is to use the option multiTooltipTemplate
if your graph has multiple data. Otherwise, you should use tooltipTemplate
multiTooltipTemplate: "<%=datasetLabel%> : <%= value %>" // Regular use
// or
multiTooltipTemplate: "<%%=datasetLabel%> : <%%= value %>" // Ruby on Rails use
Will give you :
Try this one, it will work. You just need to check what's the data coming in the label function.
options: {
tooltips: {
callbacks: {
title: function() {
return "";
},
label: function(item, data) {
var datasetLabel = data.datasets[item.datasetIndex].label || "";
var dataPoint = item.yLabel;
return datasetLabel + ": " + dataPoint + "min";
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With