From: Evert Timberg Date: Sat, 17 Sep 2016 15:06:26 +0000 (+0200) Subject: In the doughnut chart, specifically handle multiline strings. X-Git-Tag: v2.4.0~1^2~43^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3d7a3328d759fd55cf044205b88c0e8fbc488d7;p=thirdparty%2FChart.js.git In the doughnut chart, specifically handle multiline strings. --- diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index e0f378dae..3dcd33e9f 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -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; } } }