-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes Label Array Tick alignment and Centering #5248
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -857,11 +857,17 @@ 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 / 2; | ||
var lineHeight = tickFont.size * 1.5; | ||
var y = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I do: Which seems just slightly off. I think the equation is missing something small or I'm doing it wrong. |
||
if (!me.isHorizontal()) { | ||
y = -tickFont.size * lineCount; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to use the line height (not only the font size) and it would be easier and faster to translate
|
||
for (var i = 0; i < label.length; ++i) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use |
||
// 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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
var lineCount = label.length;
and re-used in the for loop.