-
Notifications
You must be signed in to change notification settings - Fork 842
Fix labelBackgroundColor to apply to background instead of text #44990
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
Fix labelBackgroundColor to apply to background instead of text #44990
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
|
- Update labelTextColor from #333 to #FFFFFF in all themes (default, jetpack, woo) - Maintains original chart appearance with white text on segments - Ensures consistent behavior across all theme variations
- Remove direct theme prop from PieChart component - Wrap PieChart in ThemeProvider when theme is provided - Handle all theme variations (default, jetpack, woo, object) - Convert nested ternaries to if-else statements for linter compliance - Resolves TS2322 error about theme prop not existing
halfo
left a comment
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.
Works as described. 👍🏿
|
|
||
| // Estimate text width more accurately for background sizing | ||
| const fontSize = 12; | ||
| const estimatedTextWidth = arc.data.label.length * fontSize * 0.6; // Rough estimate |
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.
Could we please try to use getStringWidth instead:
| return getStringWidth( longestTick, labelStyle ); |
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! Let't take a look at the feedback with a follow up.
| return ( | ||
| <g key={ `arc-${ index }` }> | ||
| <path { ...pathProps } /> | ||
| { hasSpaceForLabel && ( |
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.
We should probably skip the rendering if the label is set to empty
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.

Fix
labelBackgroundColorto apply to background instead of textProposed changes:
labelBackgroundColorwas incorrectly applied as text color instead of background color in pie chartslabelTextColorproperty to properly control text color independently from backgroundKey improvements:
labelBackgroundColormade labels invisible on light segmentslabelTextColorproperty to ChartTheme interface for explicit text color controllabelBackgroundColoris set to any non-transparent valueOther information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
No, this PR only affects chart rendering and theme properties. No tracking or user data changes.
Testing instructions:
Test Default Appearance (No Visual Changes)
pnpm run storybook:devTest Label Color Controls in Storybook