Fix label vertical alignment on vertical scales (#5248)

This commit is contained in:
Michael 2018-02-09 17:20:06 -05:00 committed by Simon Brunel
parent bba29e5916
commit 584d1c646c

View File

@ -857,11 +857,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);