Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chartjs doesn't update dataset label on tooltips

I am trying to show dataset labels on ChartJS tooltips. It works fine by setting:

Chart.defaults.global = {
    multiTooltipTemplate: "<%= datasetLabel %> - <%= value %>"
}

. But when a label changes, it doesn't get updated on tooltips and the previous label is still shown:

myLineChart.datasets[0].label = 'new label';
myLineChart.update();

Any Idea?

like image 642
AccessToken Avatar asked May 05 '15 20:05

AccessToken


1 Answers

Instead of try like that, you just put your code within chart options. It will work fine.

example:

var radarOptions = {
  multiTooltipTemplate: "<%= datasetLabel %> - <%= value %>"
}
var ctx = document.getElementById("radarChart").getContext("2d");//radarChart is the canvasid for radar chart//
var myNewChart = new Chart(ctx).Radar(radarData, radarOptions);
like image 59
Thamizhmani Avatar answered Oct 16 '22 11:10

Thamizhmani