Skip to content

Comments

Charts: Enhance chart legend styling and theme integration#43868

Merged
chihsuan merged 2 commits intotrunkfrom
charts-31-add-supports-for-customizing-legend-labelcontainer-styles
Jun 11, 2025
Merged

Charts: Enhance chart legend styling and theme integration#43868
chihsuan merged 2 commits intotrunkfrom
charts-31-add-supports-for-customizing-legend-labelcontainer-styles

Conversation

@chihsuan
Copy link
Member

@chihsuan chihsuan commented Jun 10, 2025

Proposed changes:

Enable customization of legend labels and container styles via the theme provider.

  • Added new properties for legend label and container styles in ChartTheme.
  • Updated BaseLegend component to utilize theme styles for legend labels and container.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

Screenshot 2025-06-10 at 14 11 30

chihsuan added 2 commits June 10, 2025 14:03
- Added new properties for legend label and container styles in ChartTheme.
- Updated BaseLegend component to utilize theme styles for legend labels and container.
- Refactored BarChart and LineChart components to remove dependency on providerTheme for legend shape styles.
- Cleaned up unused imports and styles in related components.
@github-actions
Copy link
Contributor

github-actions bot commented Jun 10, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jun 10, 2025
@jp-launch-control
Copy link

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/js-packages/charts/src/components/bar-chart/bar-chart.tsx 20/23 (86.96%) -0.54% 0 💚
projects/js-packages/charts/src/components/legend/base-legend.tsx 14/14 (100.00%) 0.00% 0 💚

Full summary · JS report

color: group.options?.stroke || theme.colors[ index % theme.colors.length ],
shapeStyle:
group?.options?.legendShapeStyle ?? providerTheme.legendShapeStyles?.[ index ] ?? {},
shapeStyle: group?.options?.legendShapeStyle,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove providerTheme.legendShapeStyle logic from bar/line chart since BaseLegend now handles all theme-related styling internally.

@chihsuan chihsuan added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jun 10, 2025
@chihsuan chihsuan self-assigned this Jun 10, 2025
@chihsuan chihsuan requested a review from a team June 10, 2025 06:18
Copy link
Member

@Nikschavan Nikschavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described 🚢

Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I'm thinking of something similar as well - to move these colors, patterns and shapes control to the themes, and to make the themes easier to customize 👍

@chihsuan chihsuan merged commit 97a81a0 into trunk Jun 11, 2025
68 of 69 checks passed
@chihsuan chihsuan deleted the charts-31-add-supports-for-customizing-legend-labelcontainer-styles branch June 11, 2025 01:57
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Jun 11, 2025
mikestottuk pushed a commit that referenced this pull request Jun 26, 2025
* Enhance chart legend styling and theme integration

- Added new properties for legend label and container styles in ChartTheme.
- Updated BaseLegend component to utilize theme styles for legend labels and container.
- Refactored BarChart and LineChart components to remove dependency on providerTheme for legend shape styles.
- Cleaned up unused imports and styles in related components.

* changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [JS Package] Charts RNA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants