mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-12 19:26:49 +01:00
Merge pull request #3325 from chartjs/fix/3269
Improve multiline labeling for tooltips in doughnut charts
This commit is contained in:
@@ -102,7 +102,19 @@ module.exports = function(Chart) {
|
||||
return '';
|
||||
},
|
||||
label: function(tooltipItem, data) {
|
||||
return data.labels[tooltipItem.index] + ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
|
||||
var dataLabel = data.labels[tooltipItem.index];
|
||||
var value = ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
|
||||
|
||||
if (helpers.isArray(dataLabel)) {
|
||||
// show value on first line of multiline label
|
||||
// need to clone because we are changing the value
|
||||
dataLabel = dataLabel.slice();
|
||||
dataLabel[0] += value;
|
||||
} else {
|
||||
dataLabel += value;
|
||||
}
|
||||
|
||||
return dataLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user