-
Notifications
You must be signed in to change notification settings - Fork 121
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
feat(heatmap): reduce font size to fit label within cells #1352
feat(heatmap): reduce font size to fit label within cells #1352
Conversation
BREAKING CHANGE: this commit and the previous ones introduce a breaking change in the configuration. The `fontSize`, `align` and `baseline` parameters are no longer available. Only `fontSize` is replaces by `minFontSize` and `maxFontSize`.
packages/charts/src/chart_types/heatmap/layout/viewmodel/viewmodel.ts
Outdated
Show resolved
Hide resolved
packages/charts/src/chart_types/heatmap/renderer/canvas/canvas_renderers.ts
Outdated
Show resolved
Hide resolved
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.
LGTM 🎉 The three limitations mentioned in the description would be useful to solve in this or an eventual PR, depending on the priority landscape. Two of those items have visual impact and it may be better to offer the more defensible options first, and by default (allowing a slight padding, and allowing a capping of the font size a bit like what you asked for for the treemap back then). It's hard to wean users off of suboptimal defaults as they desensitize users for their weaknesses while accustom them for their (maybe lesser) benefits. But there may be reasons for expediency, or strong demand for the volatile font size
While the slight disentanglement of the union type is implementation detail, it's probably easier while the code is in working memory, and gain experience with a shift to a disambiguation layer. Maybe at some point it could be a listed PR eval criterion (no propagation of user facing union types into internals if it's reasonably solvable upstream)
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.
LGTM
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.
LGTM
@monfera please take a look at 9017878 and 3c2dc77 where I've added the text padding (it looks like a sensible default for now but happy to play with the value a bit more) and the default configuration that use the global minimum fontSize instead of a fontSize relative to each cell text value. |
@monfera I've seen @nickofthyme working on cleaning up the various interfaces/types/api and I prefer to wait him before adding a disambiguation layer for the |
# [35.0.0](v34.2.1...v35.0.0) (2021-09-13) ### Bug Fixes * **a11y:** restore focus after popover close with color picker ([#1272](#1272)) ([0c6f945](0c6f945)), closes [#1266](#1266) [#935](#935) * **build:** fix license in package.json ([#1362](#1362)) ([d524fdf](d524fdf)) * **deps:** update dependency @elastic/eui to ^37.5.0 ([#1341](#1341)) ([fb05c98](fb05c98)) * **deps:** update dependency @elastic/eui to ^37.6.1 ([#1359](#1359)) ([2ae90ce](2ae90ce)) * **deps:** update dependency @elastic/eui to ^37.7.0 ([#1373](#1373)) ([553b6b0](553b6b0)) * **heatmap:** filter out tooltip picked shapes in x-axis area ([#1351](#1351)) ([174047d](174047d)), closes [#1215](#1215) * **heatmap:** remove values when brushing only over axes ([#1364](#1364)) ([77ff8d3](77ff8d3)) ### Features * **annotations:** add onClickHandler for annotations ([#1293](#1293)) ([48198be](48198be)), closes [#1211](#1211) * **heatmap:** add text color contrast to heatmap cells ([#1342](#1342)) ([f9a26ef](f9a26ef)), closes [#1296](#1296) * **heatmap:** reduce font size to fit label within cells ([#1352](#1352)) ([16b5546](16b5546)) * **xy:** mutilayer time axis step 1 ([#1326](#1326)) ([867b1f5](867b1f5)) ### BREAKING CHANGES * **xy:** - feat: removes the axis deduplication feature - fix: `showDuplicatedTicks` causes a duplication check on the actual axis tick label (possibly yielded by `Axis.tickLabel` rather than the more general `tickFormat`) * **heatmap:** the `config.label.fontSize` prop is replaced by `config.label.minFontSize` and `config.label.maxFontSize`. You can specify the same value for both properties to have a fixed font size. The `config.label.align` and `config.label.baseline` props are removed from the `HeatmapConfig` object.
🎉 This PR is included in version 35.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
We introduced the ability to scale the font size of numeric values within the heatmap cells if the label doesn't fit within the label using the default font size. The resulting font size is constrained within a user-configured range. If the label doesn't fit using the min font size, the label is not rendered.
BREAKING CHANGE
The
config.label.fontSize
prop is replaced byconfig.label.minFontSize
andconfig.label.maxFontSize
. You can specify the same value for both properties to have a fixed font size.The
config.label.align
andconfig.label.baseline
props are removed from theHeatmapConfig
object. These props handle the alignment of the text within the text and they are not currently compatible with the font size scaling feature introduced. Is not very common to change the alignment of text within rectangular boxes where the centered option is the most used one.Details
The changes are actually suboptimal:
fontSize
likePixels | [minFontSize: Pixels, maxFontSize:Pixels]
or something along those lines. Is a union type but it should be converted to the extended form after the API layer.Issues
fix #1295
Checklist
:xy
,:partition
):interactions
,:axis
)closes #123
,fixes #123
)packages/charts/src/index.ts