Skip to content

fix(charts): end dots draw whole and a thinned axis keeps its last label - #12438

Closed
josephfarina wants to merge 2 commits into
mainfrom
rl40-chart-edge-points
Closed

josephfarina wants to merge 2 commits into
mainfrom
rl40-chart-edge-points

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Line charts with dots, dot marks, and charts that combine them with areas or bars on a numeric x axis lose their end points. The dots at the first and last x are cut in half by the plot clip. When the bottom axis has more labels than fit, thinning keeps every n-th label from the start, so the last label (often the newest day) is dropped whenever the count does not divide evenly. Readers see a half dot on the plot edge with no label under the newest value.

Problem and solution fit

  1. Why are the end dots cut? Marks are clipped to the plot rectangle (so curve overshoot cannot spill into the margins), and a linear x range runs from 0 to the plot width, so the centre of the first and last dot sits on the clip edge.
  2. Why is the last label lost? ChartAxis thins labels with i % step === 0. For 14 labels at a cap of 7 (step 2) that keeps indices 0 to 12 and drops 13.
  3. Why does it matter? The end of a time series is usually the value the chart exists to show.

The fix:

  • A series can declare layout.xOverhang: how far it draws past a point's x. line({dots: true}) declares its dot radius and dot() its radius. The layout pass insets a linear x range by the largest overhang, so end marks draw whole inside the clip. Domains (explicit or automatic) do not change, and band scales are untouched (they already centre points in bands). A line without dots, an area, and bars declare nothing and render exactly as before.
  • Thinning keeps every step-th label from the first, plus the last label. The kept label before the last drops when it sits closer than one step, so the cap and the minimum spacing still hold.

Expected behavior and authority

  • Chart component record: marks are clipped to the plot (FR3) and share one scale set (FR2); the inset keeps both and changes no domain (ORD2).
  • ChartAxis component record (draft): AV2 lets density limits omit evenly spaced labels while preserving their order. Keeping the last label makes the last interval up to one step longer, which departs from that wording. Both records are drafts, the departure is an owner decision, and the records are not edited here. The maxTicks docs now say: labels are thinned to at most this many; the first and last labels stay.

Smallest restoration

Five source files and two focused tests. No visual default, theme value, or interaction changes.

Evidence

Before (left) and after (right). A two-week report chart (explicit xDomain, 14 daily points, maxTicks 7 desktop / 4 phone):

report chart, desktop light
report chart, desktop dark
report chart, phone 390 dark
report chart, phone 375 light

Every chart type that shares the axis: line with dots, area, a combo of area + line with dots + dots, and a line without dots (unchanged except the kept last label):

line, area, combo, desktop light
line, area, combo, desktop dark
line, area, combo, phone 390 light
line, area, combo, phone 375 dark

  • Reproduction before the change: the last dot is a half circle on the right plot edge and the newest day has no label.
  • Result after the change: end dots are whole, and the last label is shown at 375, 390, and 1280 in light and dark.
  • Representative unchanged path: pixel compare of before/after builds at 375/390/1280 in light and dark: the two chart blocks (ChartShowcase, ChartTrendComparison), the dashboard-progress template, and three bar-only pages are pixel-identical (0 changed pixels in all 36 captures). Only pages with dotted lines or dot marks change.
  • Regression tests: Chart.test.tsx "insets a linear x range by the widest mark overhang" and ChartAxis.test.tsx "keeps the last label when thinning cannot land on it" both fail on the base and pass with the fix.

Scope

Components: Chart, ChartAxis, line, dot

  • One defect is restored: the end of a line series (its dots and its label) is lost at the plot edge.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label. Note: SeriesDef.layout gains one optional hint, xOverhang, next to stack, group, includeZero, and yBandKey. It is additive, and @astryxdesign/charts is a private, canary-only package (no Changeset).
  • Public text and artifacts contain no internal Meta context.

Testing

  • CI=1 vitest run --project ui packages/charts: 12 files, 126 tests pass.
  • tsc --noEmit in packages/charts; prettier on changed files.
  • Real Chromium: a Vite app on the built packages, base vs head, full-page captures at 375, 390, and 1280 in light and dark.

@vercel

vercel Bot commented Nov 17, 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 Nov 17, 2026 10:23pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@josephfarina
josephfarina force-pushed the rl40-chart-edge-points branch from 045c671 to e6d1b20 Compare November 17, 2026 21:20
@josephfarina
josephfarina marked this pull request as ready for review November 17, 2026 21:20
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 10:40 PM UTC

@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.

Approval waits on an engineering owner's decision, and two fixes are needed either way.

The Chart and ChartAxis component records are still drafts, so no current spec settles that a numeric x axis insets its range by the widest mark overhang (through the new optional SeriesDef.layout.xOverhang), or that thinning always keeps the last label and leaves the last interval uneven. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), or asks for another form.

Blocking

  • The maxTicks docs at ChartAxis.tsx:34 and ChartAxis.doc.mjs:98 still say labels are evenly skipped while the head keeps the last label and leaves an uneven last interval, so please reword both, for example "Labels are thinned to at most this many; the first and last labels stay."
  • The description says ChartAxis AV2 covers keeping the last label, but AV2 only allows omitting evenly spaced labels and both cited records are drafts, so please restate that section to say the thinning departs from their even-spacing wording pending the owner decision.

The fix itself works: both new tests fail on main and pass here, and before and after captures show whole end dots and the Day 14 label.

Claims and files checked

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

  • Claim: on main the first and last dots are cut in half by the plot clip: verified (main maps x to the full plot width inside a plot-sized clip; before capture).
  • Claim: main thins with every step-th label, so 14 labels at a cap of 7 drop the last: verified (red-first test failure).
  • Claim: line({dots: true}) declares its dot radius and dot() its radius: verified (line.tsx:61, dot.tsx:44).
  • Claim: the layout pass insets a numeric x range by the largest overhang so end marks draw whole: verified (layout.ts:125-147; after capture).
  • Claim: domains do not change and band scales are untouched: verified (layout.ts:143-152).
  • Claim: a line without dots, an area and bars render as before: verified for charts holding only those marks; beside a dotted series they share the inset scale.
  • Claim: thinning keeps every step-th label plus the last, within the cap and minimum spacing: verified (count argument; ChartAxis.test.tsx:91-112).
  • Claim: the Chart record keeps clipping, one scale and exact domains: the behavior matches, but the record is a draft.
  • Claim: ChartAxis AV2 covers keeping the last label: false (AV2 says evenly spaced labels).
  • Claim: no record changes; five source files and two tests: verified.
  • Claim: no option default, theme value or interaction changes: verified; dotted charts' rendered geometry does change, as described.
  • Claim: SeriesDef.layout gains one optional hint in a private, canary-only package with no changeset: verified.
  • Claim: public text carries no internal context: verified.
  • Claim: both new tests fail on main and pass with the fix: verified.
  • Claim: the charts unit suite passes (12 files, 126 tests), with a clean typecheck and formatting: verified.
  • Claim: chart blocks, the dashboard template and bar-only pages are pixel-identical: consistent with the source (none uses a dotted series); not re-captured.
  • File packages/charts/src/ChartAxis.tsx: stale maxTicks JSDoc (blocking); comment wording at lines 68 and 180 (non-blocking).
  • File packages/charts/src/layout.ts: clear.
  • File packages/charts/src/types.ts: clear.
  • File packages/charts/src/marks/dot.tsx: clear.
  • File packages/charts/src/marks/line.tsx: clear.
  • File packages/charts/src/Chart.test.tsx: clear.
  • File packages/charts/src/ChartAxis.test.tsx: clear.

Automated review (maintainer link)

Comment thread packages/charts/src/ChartAxis.tsx Resolved

/**
* Keeps at most `cap` ticks: every `step`-th tick from the first, plus the last
* tick. The last tick is the end of the data (often the newest value), so it

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.

Non-blocking: on a continuous axis the last tick is d3's last generated tick, which can stop short of the end of the data. A shorter, accurate line: "The last tick is often the newest value. It keeps its label."

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 6e24b96

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@josephfarina

Copy link
Copy Markdown
Contributor Author

Owner decision (engineering owner, covering this pull request): a chart's end dots draw whole instead of being clipped at the plot edges: a numeric x axis insets its range by the widest mark overhang, through the optional additive SeriesDef.layout.xOverhang. Axis thinning keeps the first and last labels, so the last interval may be uneven. The Chart and ChartAxis records are drafts and stay unedited; this pull request describes the behavior.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 9c4748b

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 6e24b96

@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.

Approved pending CI: the CI run on this head found no room under its capacity ceiling and stopped, so build and tests have not run (the failed build job reports only "CI is full"); re-run CI so the required checks finish before merge.

An engineering owner has decided the end-dot inset, the last-label thinning and the optional SeriesDef.layout.xOverhang for this head, and the earlier maxTicks doc and description fixes are in. Both new tests fail on main and pass here, and before and after captures show whole end dots and the Day 14 label. One optional wording note on the maxTicks docs is inline.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Claim: on main, end dots on a numeric x axis are cut in half by the plot clip: verified (the clip spans the plot and the x range spans its full width; before capture).
  • Claim: on main, thinning keeps every n-th label from the start, so the last label is dropped when the step misses it: verified (red-first test); the stated condition "the count does not divide evenly" is loose, since 14 labels at a cap of 7 divide evenly and still lose the last.
  • Claim: line({dots: true}) declares its dot radius and dot() its radius: verified (line.tsx:61, dot.tsx:44).
  • Claim: the layout pass insets a numeric x range by the largest overhang so end marks draw whole: verified (layout.ts:122-147; after capture).
  • Claim: domains do not change and band scales are untouched: verified (layout.ts:136-152; a band-x dotted line renders pixel-identical).
  • Claim: a line without dots, an area and bars render as before: verified for charts holding only those marks; beside a dotted series they share the inset scale, as the description's combo evidence shows.
  • Claim: thinning keeps every step-th label plus the last within the cap and minimum spacing: verified (count argument; ChartAxis.test.tsx:91-112).
  • Claim: the draft Chart record's clipping, shared-scale and domain rules still hold: verified against the draft text.
  • Claim: keeping the last label departs from the draft ChartAxis record's even spacing and needs an owner decision: verified; an engineering owner decided it for this head.
  • Claim: the maxTicks docs now say labels are thinned to the cap with the first and last kept: verified (ChartAxis.tsx:34, ChartAxis.doc.mjs:98); it holds for a cap of 2 or more.
  • Claim: five source files and two focused tests, with no record edited: verified.
  • Claim: no option default, theme value or interaction changes: verified; dotted charts' rendered geometry changes, as described.
  • Claim: SeriesDef.layout gains one optional hint in a private, canary-only package with no changeset: verified.
  • Claim: public text carries no internal context: verified.
  • Claim: both new tests fail on main and pass with the fix: verified.
  • Claim: the charts unit suite passes (12 files, 126 tests) with a clean typecheck and formatting: verified.
  • Claim: the chart blocks, the dashboard template and bar-only pages are pixel-identical: consistent with the source (none uses a dotted series); not re-captured.
  • File packages/charts/src/ChartAxis.tsx: non-blocking wording notes at lines 34, 68 and 180.
  • File packages/charts/src/ChartAxis.doc.mjs: non-blocking wording note at line 98.
  • File packages/charts/src/layout.ts: clear.
  • File packages/charts/src/types.ts: clear.
  • File packages/charts/src/marks/dot.tsx: clear.
  • File packages/charts/src/marks/line.tsx: clear.
  • File packages/charts/src/Chart.test.tsx: clear.
  • File packages/charts/src/ChartAxis.test.tsx: clear.
  • File packages/charts/docs/CHARTV2_VERIFICATION_CHECKLIST.md: clear.

Automated review (maintainer link)

/** Number of ticks (approximate — d3 decides final count) */
tickCount?: number;
/** Maximum number of tick labels to show. Labels are evenly skipped when exceeded. */
/** Maximum number of tick labels to show. Labels are thinned to at most this many; the first and last labels stay. */

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.

Non-blocking: with maxTicks={1}, or an automatic cap of 1 on a plot narrower than two labels (line 189), thinTicks keeps only the first label (lines 76-78), so "the first and last labels stay" holds for a cap of 2 or more. A precise ending, here and in ChartAxis.doc.mjs:98: "with a cap of 2 or more, the first and last labels stay."

josephfarina added a commit that referenced this pull request Nov 18, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12252 docs(cli): agent docs name the prop names that differ from other libraries
  Author: Joey Farina <[email protected]>
- #12154 fix(core): a numeric typography weight builds through an extended base's adaptation rules
  Author: Joey <[email protected]>
- #12092 fix(cli): theme build reads the Core it builds with for variant declarations, and names the build command alone
  Author: Joey Farina <[email protected]>
- #12316 fix(core): a shorthand never follows its own longhand in one style merge
  Author: josephfarina <[email protected]>
- #12357 fix(core): a Table stays the scroll region when a host scrolls every table's parent
  Author: Joey Farina <[email protected]>
- #12349 fix(core): end a mouse drag a sandboxed frame never saw released
  Author: josephfarina <[email protected]>
- #12425 fix(cli): use a stored doc parse only with the zod release that made it
  Author: Joey <[email protected]>
- #12396 fix(AppShell): with the standard width points, a server-rendered shell hides its inline side nav on a phone before its script runs
  Author: Joey <[email protected]>
- #12438 fix(charts): end dots draw whole and a thinned axis keeps its last label
  Author: Joey Farina <[email protected]>
- #12448 fix(cli): upgrade outside a project names the project, not --from
  Author: Joey Farina <[email protected]>
- #12459 fix(templates): the dashboard scorecard fits a phone screen
  Author: Joey Farina <[email protected]>
- #12428 fix(core): Field labels draw in a bolder face than their description
  Author: Joey Farina <[email protected]>
- #12435 fix(theme-matcha): dark menus, popovers and muted fills take the theme's deep gray neutral
  Author: Joey <[email protected]>
- #12432 fix(templates): dashboard chart labels show whole instead of clipped by the chart edge
  Author: Joey Farina <[email protected]>
- #12441 fix(cli): mark icon-set generated calls pure so apps drop unused icons
  Author: Joey Farina <[email protected]>
- #12472 fix(MetadataListItem): a value breaks only a word longer than its line
  Author: Joey <[email protected]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12718.

@github-actions
github-actions Bot deleted the rl40-chart-edge-points branch November 19, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 6e24b966 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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