Skip to content

Enhancement [DEV-12685] Add colors to chart tooltips#2705

Merged
jayb merged 3 commits intodevfrom
colors-in-tooltips
Apr 9, 2026
Merged

Enhancement [DEV-12685] Add colors to chart tooltips#2705
jayb merged 3 commits intodevfrom
colors-in-tooltips

Conversation

@jayb
Copy link
Copy Markdown
Collaborator

@jayb jayb commented Apr 8, 2026

Summary

This adds colored shapes to chart tooltip indicating which series the items in the tooltip belong to.

  • If there is only one series, or the legend is hidden, it does not show colors
  • If more than one series resolves to the same color, it does not show colors
  • It does not show colors for gradient legends
  • If the legend uses boxes, it shows boxes

Testing Steps

Look at as many charts as possible and see if the colors shown in tooltips make sense.

Copilot AI review requested due to automatic review settings April 8, 2026 13:37
@jayb jayb requested a review from Mgetz10 as a code owner April 8, 2026 13:37
Copy link
Copy Markdown
Contributor

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 optional, legend-consistent color/shape markers to chart tooltips so users can visually map tooltip rows back to series.

Changes:

  • Introduces a typed tooltip-row model (with optional marker metadata) and marker-eligibility logic in a shared helper.
  • Updates core tooltip rendering (LinearChart/PieChart via useTooltip, plus Bar/Scatter HTML-tooltips) to render aligned marker swatches when appropriate.
  • Adds supporting tooltip marker styles plus Storybook smoke stories/tests to exercise marker/no-marker scenarios (including small multiples).

Reviewed changes

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

Show a summary per file
File Description
packages/core/components/ui/tooltip.scss Adds layout + swatch styles for tooltip marker column.
packages/chart/src/types/ChartConfig.ts Extends legend config with tooltipLegendVisible? to preserve “source legend visible” semantics for small multiples.
packages/chart/src/hooks/useTooltip.tsx Converts tooltip payload to typed rows and renders optional marker column in React tooltip list items.
packages/chart/src/helpers/tooltipHelpers.ts Adds shared marker eligibility/color resolution + HTML tooltip builders for series tooltips.
packages/chart/src/helpers/tests/tooltipHelpers.test.ts Adds Vitest coverage for marker eligibility, uniqueness suppression, and HTML rendering.
packages/chart/src/components/SmallMultiples/SmallMultipleTile.tsx Propagates “source legend visible” state into hidden tile legends to enable markers when appropriate.
packages/chart/src/components/ScatterPlot/ScatterPlot.jsx Switches tooltip HTML generation to shared builder that can include markers.
packages/chart/src/components/PieChart/PieChart.tsx Adapts tooltip data handling to new row-array format and passes marker-column flag to row renderer.
packages/chart/src/components/LinearChart.tsx Adapts tooltip data handling to new row-array format and passes marker-column flag to row renderer.
packages/chart/src/components/BarChart/components/BarChart.Vertical.tsx Uses shared HTML tooltip builder for consistent markup + optional markers.
packages/chart/src/components/BarChart/components/BarChart.StackedVertical.tsx Uses shared HTML tooltip builder for consistent markup + optional markers.
packages/chart/src/components/BarChart/components/BarChart.StackedHorizontal.tsx Uses shared HTML tooltip builder for consistent markup + optional markers.
packages/chart/src/components/BarChart/components/BarChart.Horizontal.tsx Uses shared HTML tooltip builder for consistent markup + optional markers.
packages/chart/src/_stories/Chart.tooltip.smoke.stories.tsx Adds stories covering marker rendering and “no markers” cases (legend hidden/gradient/patterns).
packages/chart/src/_stories/Chart.SmallMultiples.smoke.stories.tsx Adds assertions around presence/absence of marker markup in small-multiple tooltip HTML.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jayb jayb merged commit a38822b into dev Apr 9, 2026
3 checks passed
@jayb jayb deleted the colors-in-tooltips branch April 9, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants