-
Notifications
You must be signed in to change notification settings - Fork 0
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
Component | Donut: Automatic label placement #8
Conversation
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.
@curran Left some comments to the code
![image](https://private-user-images.githubusercontent.com/755708/394000936-19dc2cbc-40c8-4a5a-9c90-9d7cc4494e65.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NDg1MzMsIm5iZiI6MTczOTY0ODIzMywicGF0aCI6Ii83NTU3MDgvMzk0MDAwOTM2LTE5ZGMyY2JjLTQwYzgtNGE1YS05YzkwLTlkN2NjNDQ5NGU2NS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQxOTM3MTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kOGYwOGE5YmRlZWQ3ZjRjY2Y1OTUyMzNiZjg3N2M1ODcwYjZiZWI2NmZkMDUzZjdkZmFlOTU3OWFkNmJhNDI2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.OTF8kRHhP57gvriI_4JQd9Tj9I_EqCWWRcdZ3OCIpRw)
Will do the following, as suggested in #5 (comment)
|
Maybe this other PR would be a better first step: Then later, on top of those changes, we could add an option to automatically calculate the offsets based on measuring/estimating text size. What do you think? |
Converted this to draft PR because:
|
Current status:
Next steps:
|
4b55775
to
aadf850
Compare
Researching this more to get the right terminology... The text size estimation appears to only account for the height as the distance between the baseline and the cap height. It does not account for the descender or ascender, resulting in those things getting cut off. I wonder what the best solution here would be... Perhaps we could bring back the idea of Or maybe we can modify the text height estimation to account for the descenders and ascenders? I'm not sure what that would look like. I don't think it's as straightforward as multiplying the size by some constant, because I would guess that various fonts have different values for the ratio of the cap height (which we know) to ascender height and descender height (both of which we don't know). |
Noting down the code that measured the x-height here for future reference, since we are squashing the commits and can't see the commit history: const fastEstimatesMode = true // Fast but inaccurate
const fontWidthToHeightRatio = 0.52
const centralLabelFontSize = getCSSVariableValueInPixels('var(--vis-donut-central-label-font-size)', this.element)
const centralLabelSize = estimateTextSize(this.centralLabel, centralLabelFontSize, 0, fastEstimatesMode, fontWidthToHeightRatio)
const centralSubLabelFontSize = getCSSVariableValueInPixels('var(--vis-donut-central-sub-label-font-size)', this.element)
const centralSubLabelSize = estimateTextSize(this.centralSubLabel, centralSubLabelFontSize, 0, fastEstimatesMode, fontWidthToHeightRatio) |
aadf850
to
a07c96a
Compare
@curran Nice! You can keep working in your Feel free the modify the |
Got it. Thanks for the feedback! I made this mockup to clarify what you mean - that the sub-label should be aligned with the central label, and those should both be aligned with the edge of the half donut. I'm pretty sure this is what you mean. Also, would we want to introduce some sort of "padding" option to apply in addition to the automatic offsets that do exact alignment? I could imagine cases where users would want the automatic alignment, but then would also want to add a tiny gap so the text is not exactly aligned. |
a07c96a
to
e6ca4ec
Compare
e6ca4ec
to
c2ae7f7
Compare
Closing in favor of #9 |
No description provided.