I struggled with the Chart JS documentation, trying to figure out how to change the contents of a tooltip of a line chart tool when I hover over a specific point.
Basically, I want to display values on the same vertical axis whenever one point freezes. I tried something like this:
tooltips: {
callbacks: {
label: function(tooltipItem, data){
console.log(data);
var html = "";
for(var dataset in data.datasets){
html += "<label>" + data.datasets[dataset].label + ": " + data.datasets[dataset].data[tooltipItem.index] + "%</label><br/>";
}
return html;
}
},
},
This works with the degree of cyclization of each dataset and the addition <label>Example: 0%<br/></label>for each dataset, but when I return this HTML, a tooltip literally displays a line:
<label>Example1: 1%</label><br/><label>Example2: 5%</label><br/> ...
Instead of displaying the correct HTML:
Example1: 1%
Example2: 5%
...
, Chart JS 1.0 tooltipTemplate, , HTML tooltips.callbacks.label. , , , , .