Skip to content

docs(charts): add a single-series Tooltip story - #14214

Merged
marie-lucas merged 1 commit into
mainfrom
charts/tooltip-single-series
Dec 3, 2026
Merged

marie-lucas merged 1 commit into
mainfrom
charts/tooltip-single-series

Conversation

@marie-lucas

Copy link
Copy Markdown
Contributor

Reader impact

Engineers who use <Chart tooltip> saw only grouped cards on the Tooltip page. They had no example of the card a chart with one primary series gets, so they could not tell what changes when a chart draws a single series. After this change, the page has a fixed example of that card next to the grouped ones.

Source of truth

The current code:

  • In packages/charts/src/ChartTooltip.tsx, the default card renders a bare value when rows.length === 1 && !labelRows.
  • labelRows is hasMultiplePrimarySeries(series) in packages/charts/src/tooltip.ts, which leaves utility marks out of the count.

The draft component:ChartTooltip record (FR3 and its "Single series" state row) describes the same card. This pull request documents current behavior only. It edits no record and adds no rule.

Correction

A new story on Charts/Chrome/Tooltip: Single series (charts-chrome-tooltip--single-series). It is a fixed example with its controls disabled.

  • Data: the existing monthlyRevenueData as one line() series labelled "Revenue", with currency('$') as its formatValue and as the left axis's formatTick.
  • Description: in the default card, one resolved row on a chart with a single primary series shows the x heading and a bare value, with no series label and no color swatch, because there is only one value to read.
    • A chart with two or more primary series labels every row, as in Default, even when only one of its rows resolves at the hovered x.
    • Utility marks do not count as primary series.
    • The description does not cover custom render bodies.
  • Name: "Single series" names the condition that changes the card. It uses sentence case, like the other explicit story names on the Charts pages.
  • Docs intro: the page's Docs description gains one sentence: "See the bare-value card for one primary series and grouped rows for comparison."
  • Edit: the story is appended at the end of the file. The other edits are that intro sentence and one name added to the _data import.

No component, API or default changes. No changeset: story-only.

Evidence

Screenshots not attached.

  • Real Chrome, Single series hovered at Apr: at 1280 px and 390 px, light and dark, 4 of 4 configurations show:
    • an open card with the literal text "Apr" and "$95.8K";
    • zero swatches;
    • no "Revenue" label.
    • The expected strings come from the dataset by hand: April revenue is 95,800, which compact currency text reads as "$95.8K".
  • Red arm: a build in which hasMultiplePrimarySeries counts > 0 instead of > 1 fails that same check in all four configurations. The card then shows a "Revenue" label and one swatch.
  • Grouped Default, hovered at Apr: it matches the main baseline in all four configurations: "Apr", "Revenue 61", "Costs 38", "Trend 48", and three swatches.
  • Existing Tooltip stories: the 5 stories have the same normalized chart SVG markup as main, at 1280 px light only. Per-render ids are normalized.
  • Story list: it gains exactly one id. No id is removed or renamed.
  • Play functions: the existing two (Default, ModalLayering) passed when observed through the Storybook preview channel. The story play guard script was not run locally. Single series has no play function.

Scope

Components: ChartTooltip

  • This PR changes documentation only, or names every necessary generated artifact.
  • Runtime, API, visual, and policy changes were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

Author-run checks:

  • build-storybook and story-tree.test.ts: pass.
  • Storybook tsc: pass.
  • prettier --check and eslint --max-warnings=0 on the changed file: pass.
  • pnpm review:pre --head HEAD: 0 findings.

Coverage limit: the new story has no play function, so CI does not check its card text. The single-row layout rule is covered by packages/charts/src/ChartTooltip.test.tsx.

The Tooltip page showed only grouped cards. In the default card, one
resolved row on a chart with a single primary series shows the x value
as its heading and a bare value below it, with no series label and no
color swatch. Readers had no story that shows it.

A fixed "Single series" story on the Tooltip page now shows that card
on the existing monthly revenue dataset, with currency('$') as the
series' value format and the left axis's tick format. Its description
says what differs from the grouped card and why. It documents current
behavior and adds no rule. Its controls are off. The page's Docs intro
points to it next to the grouped rows.
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Dec 3, 2026 1:39am UTC

Request Review

@marie-lucas marie-lucas added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Dec 3, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 3, 2026
@astracat-bot

astracat-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Dec 3, 2026, 1:42 AM UTC

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 80b13e5

⏳ Building… Until it's ready, Storybook · Sandbox open the branch's previous preview.

Current run: Heavy CI deferred: runs when review passes and before merge. Lint, typecheck and any path-filtered checks ran on this push.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new Single series story is approved pending CI: the heavy CI suites have not finished on this head yet.

Hovered at Apr, the story shows the card the description promises: "Apr" and "$95.8K", with no series label and no swatch, in light and dark at 1280 px and 390 px. The grouped Default card is unchanged. No changes are requested.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claims
    • Before this change, the Tooltip page showed only multi-series cards: verified (every existing story draws two or three series).
    • The page now has a fixed single-series example with its controls off, next to the grouped ones: verified.
    • The default card shows a bare value when it has one row and the chart has one primary series: verified in ChartTooltip.tsx.
    • The primary-series count leaves out utility marks: verified in tooltip.ts and the utility mark list.
    • The draft ChartTooltip record's FR3 and its Single series state describe the same card: verified.
    • The pull request documents current behavior only, edits no record and adds no rule: verified (one story file).
    • The story id is charts-chrome-tooltip--single-series: verified in the head Storybook index.
    • The story uses the monthly revenue data, one Revenue line, and currency('$') for the value and the left axis: verified.
    • The story text (bare value, labelled rows with two or more primary series even when one row resolves, utility marks not counted, custom render bodies out of scope) matches the code and the existing unit tests: verified.
    • "Single series" uses sentence case like the other explicit story names on the Charts pages: verified (all 15 explicit names on those pages).
    • The Docs intro gains one sentence: verified.
    • The only other edits are the appended story and one more data import: verified.
    • There is no component, API or default change, and no changeset is needed: verified.
    • Real-Chrome checks of the new story at Apr in four configurations: reported; reproduced here in all four.
    • A mutated build fails the same check: reported.
    • Default at Apr matches main in four configurations: reported; reproduced here at 1280 px light, pixel-identical.
    • The five existing stories render the same chart markup as main: reported; their code is unchanged.
    • The story list gains exactly one id, and none is removed or renamed: verified (Storybook index, base against head).
    • The existing play functions pass: reported.
    • Storybook build and story-tree test pass: reported.
    • Storybook typecheck passes: verified here, and CI's typecheck passes.
    • Prettier and ESLint pass on the changed file: verified here, and CI's lint passes.
    • The pre-review script reports 0 findings: reported.
    • The new story has no play function, so CI does not check its card text: verified.
    • The single-row layout rule is covered by ChartTooltip.test.tsx: verified (its one-series, utility-mark and keyless-series cases; 43 tests pass here).
  • Files
    • apps/storybook/stories/charts/Tooltip.stories.tsx: clear

Automated review (maintainer link)

@marie-lucas
marie-lucas merged commit 6d356d1 into main Dec 3, 2026
143 of 146 checks passed
@github-actions
github-actions Bot deleted the charts/tooltip-single-series branch December 3, 2026 06:09

This branch was successfully deployed

1 active deployment
Preview — 80b13e55 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant