Skip to content

CHARTS-15 - Add support to enable default start glyph for the line chart #43819

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 12 commits into from
Jun 9, 2025

Conversation

Nikschavan
Copy link
Member

@Nikschavan Nikschavan commented Jun 6, 2025

Fixes CHARTS-15

Proposed changes:

  • Add a prop to enable/disable the glyph at the start of the line in line chart

Arc -2025-06-06 at 17 25 01@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:

Copy link
Contributor

github-actions bot commented Jun 6, 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 RNA [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jun 6, 2025
Copy link

jp-launch-control bot commented Jun 6, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/js-packages/charts/src/components/line-chart/line-chart.tsx 53/65 (81.54%) 5.54% 0 💚

Full summary · JS report

@Nikschavan Nikschavan added the [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it label Jun 6, 2025
@Nikschavan Nikschavan requested a review from Copilot June 6, 2025 12:04
data={ seriesData }
color={ stroke }
glyphStyle={ glyphStyle }
renderStartGlyph={ defaultRenderGlyph }
Copy link
Member Author

@Nikschavan Nikschavan Jun 6, 2025

Choose a reason for hiding this comment

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

Right now, I am not allowing overriding the glyph and using the default style, which matches the style of glyphs shown with the tooltip/hover.

I assume in the separate task we will probably want to allow using custom glyphs per data? pcO4xN-2zR-p2

Arc -2025-06-06 at 17 49 25@2x

Copilot

This comment was marked as outdated.

@Nikschavan Nikschavan requested a review from Copilot June 6, 2025 12:19
@Nikschavan Nikschavan added the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Jun 6, 2025
@Nikschavan Nikschavan requested a review from a team June 6, 2025 12:20
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

Adds support for rendering a glyph at the start of each series in the line chart when enabled

  • Introduces a withStartGlyphs prop and default glyph renderer
  • Implements a StartGlyph component and exports its props type
  • Adds a Storybook story and changelog entry for the new feature

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
projects/js-packages/charts/src/index.ts Export RenderLineStartGlyphProps type
projects/js-packages/charts/src/components/line-chart/stories/index.stories.tsx Add WithStartGlyphs story
projects/js-packages/charts/src/components/line-chart/line-chart.tsx Add withStartGlyphs prop, StartGlyph component, and default glyph rendering
projects/js-packages/charts/changelog/charts-15-add-glyphs-at-the-start-of-the-lines Add changelog for the new glyph feature
Comments suppressed due to low confidence (2)

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

  • The new withStartGlyphs prop should be documented in the JSDoc comment for LineChartProps, including its default value and behavior.
withStartGlyphs?: boolean;

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

  • The logic for rendering start glyphs isn't covered by unit tests. Consider adding tests to verify that when withStartGlyphs is true, the StartGlyph component is rendered correctly.
renderTooltip = renderDefaultTooltip,

dognose24
dognose24 previously approved these changes Jun 6, 2025
Copy link
Contributor

@dognose24 dognose24 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, nice work! 👍🏼 Left my thought, but it won't be a blocker. 🙂

data: SeriesData;
index: number;
color: string;
renderStartGlyph: < Datum extends object >(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put my 2 cents here: I think the renderStartGlyph function could be more converged inside the component StartGlyph rather than exposing the whole render function, since the primary purpose is to add the glyph at the start point of the line chart in this scenario. I imagine the StartGlyph component would receive a simple icon or element for a customizable glyph.

Is there a more complex use case to adjust more options for the glyph point?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was imagining that if we were to allow changing the glyph and add a custom shape here, we would want to match the one on the tooltip. That's why I have kept the type/format of this same as the one from the ToolTip Glyph in visx, so that same Glyph could be potentially passed to Tooltip as well - https://github.com/airbnb/visx/blob/86738178e86fdc0feacf83ac96e68724da0627c2/packages/visx-xychart/src/components/Tooltip.tsx#L75-L102C17

Copy link
Contributor

Choose a reason for hiding this comment

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

so that same Glyph could be potentially passed to Tooltip as well

👍

@kangzj kangzj self-requested a review June 9, 2025 03:07
kangzj
kangzj previously approved these changes Jun 9, 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 to me! Nice one 👍

@Nikschavan Nikschavan dismissed stale reviews from kangzj and dognose24 via d84f017 June 9, 2025 06:52
@Nikschavan Nikschavan merged commit c883c8f into trunk Jun 9, 2025
63 checks passed
@Nikschavan Nikschavan deleted the charts-15-add-glyphs-at-the-start-of-the-lines branch June 9, 2025 07:41
@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] Needs Team Review Obsolete. Use Needs Review instead. labels Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[JS Package] Charts RNA [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants