-
Notifications
You must be signed in to change notification settings - Fork 838
Charts: Allow user margin.top override when legend is positioned at top #45657
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
base: trunk
Are you sure you want to change the base?
Charts: Allow user margin.top override when legend is positioned at top #45657
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! |
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.
Pull Request Overview
This PR fixes a bug where user-provided margin.top values were being overridden when legends were positioned at the top in LineChart and BarChart components. The fix ensures that custom margin values take precedence and the legend height is properly added to them rather than replacing them.
Key Changes:
- Updated margin calculation logic in both LineChart and BarChart to use
margin?.top ?? defaultMargin.toppattern - Added comprehensive test coverage (6 new tests) for margin behavior with legends at different positions
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| line-chart.tsx | Fixed margin.top calculation to respect user-provided values when legend is at top |
| bar-chart.tsx | Fixed margin.top calculation to respect user-provided values when legend is at top |
| line-chart.test.tsx | Added 3 tests covering margin behavior with legend positioning |
| bar-chart.test.tsx | Added 3 tests covering margin behavior with legend positioning |
| changelog/charts-43-legends-ensure-that-the-user-provided-margin-prop-takes | Added changelog entry documenting the fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
Proposed changes:
margin.topwhen legend is positioned at topmargin.topwhen legend is positioned at topmargin?.top ?? defaultMargin.toppatternPreviously, when the legend was positioned at the top, user-provided
margin.topvalues were overridden by the legend calculation. Now the user's margin takes precedence and the legend height is properly added to it.Other information:
Does this pull request change what data or activity we track or use?
No, it does not.
Testing instructions:
margin.topvalue (50px) is respected and the legend height is added to itpnpm test