From 1f3fd8211e0b25e07a78c5b4b4a630583f6ff5f2 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 7 Feb 2018 14:56:14 -0500 Subject: [PATCH 1/4] Fixes array tick alignment and centering --- src/core/core.scale.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index f79dbee8009..c03df61151f 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -857,6 +857,11 @@ module.exports = function(Chart) { var label = itemToDraw.label; if (helpers.isArray(label)) { + if (label.length % 2 === 0) { + context.translate(0, (-tickFont.size * (label.length / 2)) / 2); + } else { + context.translate(0, -tickFont.size * (label.length / 2)); + } for (var i = 0, y = 0; i < label.length; ++i) { // We just make sure the multiline element is a string here.. context.fillText('' + label[i], 0, y); From ddcf3c58e9225dffdde7b2a923a5993f3d3874e2 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 8 Feb 2018 13:09:03 -0500 Subject: [PATCH 2/4] Horizontal scale fix and update --- src/core/core.scale.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index c03df61151f..17abf60ae47 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -857,16 +857,17 @@ module.exports = function(Chart) { var label = itemToDraw.label; if (helpers.isArray(label)) { - if (label.length % 2 === 0) { - context.translate(0, (-tickFont.size * (label.length / 2)) / 2); - } else { - context.translate(0, -tickFont.size * (label.length / 2)); + var lineCount = label.length / 2; + var lineHeight = tickFont.size * 1.5; + var y = 0; + if (!me.isHorizontal()) { + y = -tickFont.size * lineCount; } - for (var i = 0, y = 0; i < label.length; ++i) { + for (var i = 0; i < label.length; ++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); From 5f1bc9196329f17b6764a1544bfaa0f043c6fc71 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 9 Feb 2018 09:44:19 -0500 Subject: [PATCH 3/4] Equation Change --- src/core/core.scale.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 17abf60ae47..d91f3a905a5 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -859,10 +859,8 @@ module.exports = function(Chart) { if (helpers.isArray(label)) { var lineCount = label.length / 2; var lineHeight = tickFont.size * 1.5; - var y = 0; - if (!me.isHorizontal()) { - y = -tickFont.size * lineCount; - } + var y = me.isHorizontal() ? 0 : -lineHeight * lineCount / 1.2; + for (var i = 0; i < label.length; ++i) { // We just make sure the multiline element is a string here.. context.fillText('' + label[i], 0, y); From 9368c8be0eb7f579e90c92675be20ee41a11a5c3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 9 Feb 2018 11:23:11 -0500 Subject: [PATCH 4/4] Updated equation --- src/core/core.scale.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index d91f3a905a5..1996c6c894d 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -857,11 +857,11 @@ module.exports = function(Chart) { var label = itemToDraw.label; if (helpers.isArray(label)) { - var lineCount = label.length / 2; + var lineCount = label.length; var lineHeight = tickFont.size * 1.5; - var y = me.isHorizontal() ? 0 : -lineHeight * lineCount / 1.2; + var y = me.isHorizontal() ? 0 : -lineHeight * (lineCount - 1) / 2; - for (var i = 0; i < label.length; ++i) { + 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