Add scale.pointLabels.lineHeight and scale.ticks.lineHeight options#5914
Add scale.pointLabels.lineHeight and scale.ticks.lineHeight options#5914simonbrunel merged 4 commits intochartjs:masterfrom
Conversation
src/core/core.scale.js
Outdated
| // 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.
Would it make sense to capture helpers.options.parseFontOptions into a variable to help minification?
simonbrunel
left a comment
There was a problem hiding this comment.
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.
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.
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.
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?
|
@nagix I like the refactor, and the number of fixed issues is impressive, good job! Just a minor change about |
|
|
simonbrunel
left a comment
There was a problem hiding this comment.
@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. |
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.displayisfalsein a radar chart.The following changes are made in this PR.
lineHeightoption toscale.ticksandscale.pointLabels. Replace the hard-coded line spacing (font size * 1.5) withlineHeight. It fallbacks to theChart.defaults.global.defaultLineHeightif undefined.scale.displaybefore callingfitWithPointLabels.lineHeight.helpers.options.parseFontOptionsto 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