Skip to content

Conversation

@hcopp
Copy link
Contributor

@hcopp hcopp commented Dec 8, 2025

What changed? Why?

This PR adds legend and tooltip components. ChartTooltip is only available on web but legend is available on both platforms. I named it this way to not interfere with regular Tooltip, we took a similar approach with 'ChartText'.

There are some items that I am implementing in a different branch as it will require some refactoring

  • Support tabbing with tooltip
  • Support gray rectangle by default when using bar chart scrubber
  • Support pie chart with tooltip

Root cause (required for bugfixes)

UI changes

image image image image image

Testing

How has it been tested?

  • Unit tests
  • Interaction tests
  • Pseudo State tests
  • Manual - Web
  • Manual - Android (Emulator / Device)
  • Manual - iOS (Emulator / Device)

Testing instructions

Illustrations/Icons Checklist

Required if this PR changes files under packages/illustrations/** or packages/icons/**

  • verified visreg changes with Terran (include link to visreg run/approval)
  • all illustration/icons names have been reviewed by Dom and/or Terran

Change management

type=routine
risk=low
impact=sev5

automerge=false

@cb-heimdall
Copy link
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 1
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1
CODEOWNERS 🟡 See below

🟡 CODEOWNERS

Code Owner Status Calculation
ui-systems-eng-team 🟡 0/1
Denominator calculation
Additional CODEOWNERS Requirement
Show calculation
Sum 0
0
From CODEOWNERS 1
Sum 1

@hcopp hcopp changed the base branch from master to hunter/polar-charts-2 December 8, 2025 19:33
@hcopp hcopp mentioned this pull request Dec 9, 2025
8 tasks
@hcopp hcopp self-assigned this Dec 9, 2025
* Custom component to render bars for this series.
*/
BarComponent?: BarComponent;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feature allows us to use different bar components per series

Image

background = elevated ? 'var(--color-bg)' : 'transparent',
borderRadius,
background = elevated ? 'var(--color-bgElevation1)' : 'transparent',
borderRadius = 4,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had some inconsistencies with ChartText/DefaultScrubberBeaconLabel across web and mobile - this fixes them.

color?: string;
shape?: LegendShape;
value: React.ReactNode;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm gonna take another look through this component to see if we can clean it up.

* Position of the legend relative to the chart.
* @default 'bottom'
*/
legendPosition?: LegendPosition;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For legend implementation there are a few paths

Location: inside or outside of svg
Implementation pattern: as a child of chart or as a prop

Material UI uses a slot prop and it is located outside of the SVG, recharts supports it as a child and it is inside of the SVG.

I decided on location being outside of the SVG since we can reuse parts with ChartTooltip on web (same legend shape component) and we can rely on standard flex CSS properties to support wrapping to multiple lines, customization (such as pressable legend items) is accessible, etc.

Downside of this path is that we have to accept it as a prop or do some funky workarounds - ChartTooltip doesn't have this issue as it can use createPortal from react dom.

I tried using portal for legend - I needed 4 Box components always present, one for each position. However createPortal doesn't exijst on mobile and so we would be back to square one, or we could do some sort of iteration on children for chart - nothing seemed perfect here.

As a result I ended up at providing it as a prop. The biggest downside is someone couldn't add multiple legends but I don't think that is a deal breaker.

@hcopp hcopp marked this pull request as ready for review December 9, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants