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 dracos committed Feb 26, 2018
1 parent a540b0e commit 4130c31
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4130c31

Please sign in to comment.