-
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
Add scale.pointLabels.lineHeight and scale.ticks.lineHeight options #5914
Conversation
src/core/core.scale.js
Outdated
@@ -341,7 +319,7 @@ module.exports = Element.extend({ | |||
|
|||
// Get the width of each grid by calculating the difference | |||
// between x offsets between 0 and 1. | |||
var tickFont = parseFontOptions(tickOpts); | |||
var tickFont = helpers.options.parseFontOptions(tickOpts, globalDefaults); |
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.
Would it make sense to capture helpers.options.parseFontOptions
into a variable to help minification?
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.
Thanks @nagix. I will review this PR in details after we decided about the public API of the new helpers.
|
src/helpers/helpers.options.js
Outdated
* @param {Object} font - A font object. | ||
* @return {Stringg} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font | ||
*/ | ||
toFontString: function(font) { |
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.
I would not expose this method to the public API until we need to, but instead I would declare it outside the export (we can test this method via _parseFont
). We should also deprecate helpers.fontString
, which could be moved at the end of this file and fallback to this method (similar to what's done in the canvas helpers)
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.
helpers.fontString
is called from core.tooltip. I think tooltips.{body|title|footer}Font{Family|Size|Style|Color}
should be replaced with tooltips.*.font.*
in v3, but _parseFont
cannot be used for these options in the current version. Should we leave helpers.fontString
for now?
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.
That's fine to keep using fontString
in this case, though I would still move toFontString
outside the export to make it fully private for now. What do you think?
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.
Yes, I agree.
@nagix I like the refactor, and the number of fixed issues is impressive, good job! Just a minor change about |
|
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.
@nagix should we merge this PR? is there any of these changes that could badly impact existing projects and should be considering breaking?
4780832
I have reviewed the code again and checked all the samples, and I didn't see any issues (I found a few issues in master which is not related to this PR, though). I think it's ready to merge. |
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.
Thanks @nagix
Add lineHeight and padding props to ScaleTitleOptions, based on https://www.chartjs.org/docs/latest/axes/labelling.html. related issue chartjs/Chart.js#5914 (comment)
This PR fixes following problems.
scale.display
isfalse
in a radar chart.The following changes are made in this PR.
lineHeight
option toscale.ticks
andscale.pointLabels
. Replace the hard-coded line spacing (font size * 1.5) withlineHeight
. It fallbacks to theChart.defaults.global.defaultLineHeight
if undefined.scale.display
before callingfitWithPointLabels
.lineHeight
.helpers.options.parseFontOptions
to eliminate code duplication.Master: https://jsfiddle.net/nagix/sm2neb58/
This PR: https://jsfiddle.net/nagix/bjh3y8s9/
Note that the overlaps of tick labels (backdrop boxes) in radar charts is a different issue (#5917). I will open another PR for it.
Fixes #4292
Fixes #4379
Fixes #4759
Fixes #4799
Fixes #4962
Fixes #5280