Skip to content

CHARTS-33: Allow glyphs to be defined from theme #43875

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

Merged
merged 42 commits into from
Jun 16, 2025

Conversation

Nikschavan
Copy link
Member

@Nikschavan Nikschavan commented Jun 10, 2025

Fixes CHARTS-33

Proposed changes:

  • Allow defining glyphs array in theme
  • Allow customizing the glyphs per data source

Arc -2025-06-10 at 16 50 36@2x

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?

No

Testing instructions:

Nikschavan added 29 commits June 9, 2025 16:28
- Use @visx/group Group component for legend glyphs
- Add defaultRenderGlyph fallback for legend
- Fix tooltip type compatibility with DataPointDate
- Pass glyphStyle props consistently across components
Base automatically changed from charts-16-show-glyphs-shapes-in-legend to trunk June 11, 2025 10:53
@Nikschavan Nikschavan requested a review from Copilot June 11, 2025 11:00
Copy link
Contributor

@Copilot Copilot AI left a 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 extends the chart theming API to let consumers declare a list of glyph-rendering functions in their theme and applies those glyphs per series (including tooltips), plus updates stories and changelog to demonstrate the feature.

  • Added an optional glyphs array to ChartTheme
  • Extracted DefaultGlyph into its own component and wired theme glyphs into LineChart
  • Updated Storybook stories to showcase theme-based glyph overrides
  • Recorded a changelog entry for the new feature

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
projects/js-packages/charts/src/types.ts Added glyphs property to ChartTheme
projects/js-packages/charts/src/components/shared/default-glyph.tsx Extracted the default glyph renderer into its own file
projects/js-packages/charts/src/components/line-chart/stories/index.stories.tsx Demonstrated custom theme glyphs and added themeName control
projects/js-packages/charts/src/components/line-chart/line-chart.tsx Integrated theme glyphs for start markers, series, and tooltips
projects/js-packages/charts/changelog/charts-package-glyphs-theme Added changelog entry
Comments suppressed due to low confidence (2)

projects/js-packages/charts/src/types.ts:103

  • [nitpick] Consider expanding the doc comment to explain how glyphs indices map to data series and what happens when fewer glyph functions than series are provided.
glyphs?: Array< < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode >;

projects/js-packages/charts/src/components/line-chart/line-chart.tsx:239

  • No tests currently verify that the tooltipRenderGlyph override correctly picks theme glyphs per series. Add unit or integration tests to cover custom tooltip glyph behavior.
const tooltipRenderGlyph = useMemo( () => {

@Nikschavan Nikschavan marked this pull request as ready for review June 12, 2025 13:39
@Nikschavan Nikschavan changed the title Charts: Allow glyphs to be defined from theme Charts-33: Allow glyphs to be defined from theme Jun 12, 2025
@Nikschavan Nikschavan added the Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR label Jun 12, 2025
@Nikschavan Nikschavan changed the title Charts-33: Allow glyphs to be defined from theme CHARTS-33: Allow glyphs to be defined from theme Jun 13, 2025
kangzj
kangzj previously approved these changes Jun 16, 2025
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 and works as described 👍

@Nikschavan Nikschavan merged commit 622922f into trunk Jun 16, 2025
64 checks passed
@Nikschavan Nikschavan deleted the charts-package-glyphs-theme branch June 16, 2025 06:32
@github-actions github-actions bot removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [JS Package] Charts RNA [Tests] Includes Tests [Type] Feature Development of a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants