From 4130c313b75e418c4b76e5a58531b1be9b1e9e88 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 9 Feb 2018 17:20:06 -0500 Subject: [PATCH] Fix label vertical alignment on vertical scales (#5248) --- src/core/core.scale.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 3a020eebc32..4be157a23b4 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -875,11 +875,15 @@ module.exports = function(Chart) { var label = itemToDraw.label; if (helpers.isArray(label)) { - for (var i = 0, y = 0; i < label.length; ++i) { + var lineCount = label.length; + var lineHeight = tickFont.size * 1.5; + var y = me.isHorizontal() ? 0 : -lineHeight * (lineCount - 1) / 2; + + for (var i = 0; i < lineCount; ++i) { // We just make sure the multiline element is a string here.. context.fillText('' + label[i], 0, y); // apply same lineSpacing as calculated @ L#320 - y += (tickFont.size * 1.5); + y += lineHeight; } } else { context.fillText(label, 0, 0);