[Chartjs]-Displaying custom dataset properties in tooltip in chart.js

2👍

Charts doesn’t support this feature officially. But you can customize tooltip with your data like this in case of LineChart.

first, make chart with datasets and options

var chart = new Chart(ctx).Line(dataset, opt);

and, add properties what you want show in tooltip

var points = chart.datasets[0].points;
for (var i = 0; i < points.length; i++) {
    // Add properties in here like this
    // points[i].time = '2015-04-23 13:06:24'; 
}

then, you can use these properties like this.

tooltipTemplate: "<%=time%> : <%=value%>"

I hope this is helpful to someone. 😀

1👍

You should go:

  var options = {
       tooltipTemplate: "<%= label + '-' + %> <%= description %>"
    };

0👍

It’s not a solution really, but I solved it by adding just the description inside the label…

label: "Label 2 - Description",

Leave a comment