Skip to content

Commit

Permalink
Fix label vertical alignment on vertical scales (chartjs#5248)
Browse files Browse the repository at this point in the history
  • Loading branch information
MPierre9 authored and simonbrunel committed Feb 9, 2018
1 parent 24b9ff3 commit fb9b484
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/core.scale.js
Expand Up @@ -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);
Expand Down

0 comments on commit fb9b484

Please sign in to comment.