Repository navigation
fix(charts): end dots draw whole and a thinned axis keeps its last label - #12438
josephfarina wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
045c671 to
e6d1b20
Compare
|
AI review status for this pull request.
|
e6d1b20 to
9c4748b
Compare
There was a problem hiding this comment.
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
maxTicksdocs atChartAxis.tsx:34andChartAxis.doc.mjs:98still 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
mainthe first and last dots are cut in half by the plot clip: verified (mainmaps x to the full plot width inside a plot-sized clip; before capture). - Claim:
mainthins 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 anddot()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.layoutgains 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
mainand 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: stalemaxTicksJSDoc (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.
|
|
||
| /** | ||
| * 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 |
There was a problem hiding this comment.
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."
PR Analysis Report🔎 Preview ·
|
|
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 |
|
/approve-spec 9c4748b |
|
/approve-spec 6e24b96 |
There was a problem hiding this comment.
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 anddot()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
maxTicksdocs 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.layoutgains 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
mainand 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.
| /** 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. */ |
There was a problem hiding this comment.
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."
- #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]>
|
Landed in #12718. |
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
ChartAxisthins labels withi % step === 0. For 14 labels at a cap of 7 (step 2) that keeps indices 0 to 12 and drops 13.The fix:
layout.xOverhang: how far it draws past a point's x.line({dots: true})declares its dot radius anddot()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.Expected behavior and authority
maxTicksdocs 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,maxTicks7 desktop / 4 phone):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):
ChartShowcase,ChartTrendComparison), thedashboard-progresstemplate, and three bar-only pages are pixel-identical (0 changed pixels in all 36 captures). Only pages with dotted lines or dot marks change.Chart.test.tsx"insets a linear x range by the widest mark overhang" andChartAxis.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
SeriesDef.layoutgains one optional hint,xOverhang, next tostack,group,includeZero, andyBandKey. It is additive, and@astryxdesign/chartsis a private, canary-only package (no Changeset).Testing
CI=1 vitest run --project ui packages/charts: 12 files, 126 tests pass.tsc --noEmitin packages/charts; prettier on changed files.