2👍
✅
Custom Labels for Each Dataset
You can do this by using a custom label object.
Preview
Script
function TeamPlayerLabel(label, team1Label, team2Label) {
this.label = label;
this["Team 1"] = team1Label;
this["Team 2"] = team2Label;
}
TeamPlayerLabel.prototype.toString = function () {
return this.label;
}
var data = {
labels: [
new TeamPlayerLabel("Player 1", "John Red", "John Green"),
new TeamPlayerLabel("Player 2", "Mark Red", "Mark Green"),
new TeamPlayerLabel("Player 3", "Jane Red", "Jane Green"),
new TeamPlayerLabel("Player 4", "Jill Red", "Jill Green"),
],
datasets: [
{
label: "Team 1",
...
},
{
label: "Team 2",
...
}
]
};
and then
new Chart(ctx).Line(data, {
multiTooltipTemplate: function (self) {
return self.label[self.datasetLabel] + ': ' + self.value;
}
});
Fiddle – https://jsfiddle.net/htq3kgay/
Source:stackexchange.com