feat(bullet): improve header layout and positioning #2243
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Improves positioning of title. subtitle, value and target
Details
Positioning changes
Previously we used a font size and line height approach that left the baselines of the subtitle/title misaligned with the value/target. This was fixed by using a common baseline for the value/target and the subtitle (or title if no subtitle) along with
ctx.textBaseline = 'alphabetic'
.In addition to using a common bottom baseline, we consider the height of the text using an approximation of the ascent, see diagram below, along with a defined line spacing for elements allowed to render multiple lines, for now this is just the title.
With this approach we can better space the text without having overly padded gaps or line heights, with better control over the overall sizing and spacing. With this change the baselines always matchup nicely...
This way no matter if there is a title or subtitle or multiline title, it always aligns the bottom-most left side text with the bottom-most right side text. This also accounts for cases where the value font size is greater than a single title line.
Break points for stacking value/target below title/subtitle when...
I am happy to tweak or add to this but this is what I came up from discussing with @gvnmagni and made some assumptions on my own. This way we are not too eager to stack the target value when it's not needed and tends to fill the space the best.
This change look something like this...
Issues
closes #2235
Checklist
:xy
,:partition
):interactions
,:axis
)closes #123
,fixes #123
)packages/charts/src/index.ts