Reputation: 222
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?
Upvotes: 6
Views: 3259
Reputation: 1173
Angular 2
I have initilized chartlabel on every click of graph display.
this.lineChartLabels=[];
I have put condition in div ,untill data comes to chartlabels ,do not render the graph
<div *ngIf="lineChartLabels!=0">
It works for me
Upvotes: 0
Reputation: 81
For VB.NET, make sure it's all built as a string.
var radarOptions = {
multiTooltipTemplate: "<" + "%= datasetLabel %> - " + "<" + "%= value %>"
}
Upvotes: 0
Reputation: 3
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);
Upvotes: 1
Reputation: 73
For tooltips try something like this:
myLineChart.data.labels = labels; //change all labels
myLineChart.update();
or
myLineChart.data.labels[0] = 'new label';
myLineChart.update();
Upvotes: 0