Skip to content

feat(charts): add TanStack Solid Charts foundation + about speed histogram (S1, S3) (@fehmer) - #8623

Open
fehmer wants to merge 10 commits into
integration/chartsfrom
feature/ts-charts-s1-foundation
Open

fehmer wants to merge 10 commits into
integration/chartsfrom
feature/ts-charts-s1-foundation

Conversation

@fehmer

@fehmer fehmer commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Overview

Adds the TanStack Solid Charts foundation (roadmap S1, docs/specs/tanstack-charts/) and the first chart behind the parity flag (roadmap S3): the about page speed histogram now renders through a dual-renderer SpeedHistogram component, with the TanStack half asserted by a real definition contract spec.

  • @tanstack/charts 1.5.0 (solid peer dep)
  • vendor-chart bundle group widened to /node_modules\/(chart|@tanstack\/charts|d3-)/ and moved ahead of vendor-tanstack (first match wins)
  • src/styles/tanstack-charts.scss: host color + --ts-chart-1…4 + --ts-chart-tooltip-* from our theme variables, imported in vendor.scss
  • Dev-only parity flag (button in the dev options modal, __mt handle, Chart.js default); it now controls which renderer SpeedHistogram uses
  • The TanStack half is a pure definition builder (buildSpeedHistogramDefinition): band x scale, zero-based nice linear y, group-x focus/tooltip, --ts-chart-1 bar paint, themed grid lines and axis label
  • The host is sized per the TanStack responsive-charts guide: no width (follows the container), fixed 192 px height like the section and the canvas it replaces, initialWidth seeds the first frame; rotated bucket labels thin collision-aware at narrow widths (built-in thinning, ends kept)
  • Zero-count buckets render empty (accepted minBarLength deviation, recorded in the spec); tiny buckets keep the 2 px clamp
  • AboutPage renders the new component; the Chart.js options moved into it verbatim (kept until S12)

Implementation Sketch

SpeedHistogram(data)
├── parity flag off (default) → old ChartJs canvas, options unchanged
└── parity flag on → <Chart definition={buildSpeedHistogramDefinition(rows, getTheme)}
│                     height={192} initialWidth={640}>   # no width: follows the container
│                     band x (buckets) · nice linear y from 0 · barY · group-x tooltip
│                     zero buckets → 0 · tiny buckets → 2 px clamp · labels auto-thin

The parity branch and the kept Chart.js half are S12 stepping stones; S3 lands on this branch, so the chart is dev-visible on integration/charts from this PR.

Evidence

No screenshots in this repo — measured on the dev server, about page, parity flag both ways:

container Chart.js canvas TanStack host bucket labels
~1216 px (desktop) 1216×192 1216×192, viewBox tracks the container all 29 shown / 13 (rotated −45°, collision-thinned)
~296 px (narrow) 296×192 296×192, viewBox tracks the container auto-rotated + skipped (8) / thinned (5, ends kept), no collisions
  • Theme change (serika → incognito): bars re-tint #e2b714 → #ff9900; ticks and grid follow the currentColor/scss tokens ✓
  • Hover tooltip (60–69 bucket): title + Users: 75942 + top 57.21% ✓
  • No click handler on this chart; container resize re-lays out immediately (no resize animation) ✓

Definition contract spec after the responsive/zero-bucket refinements: pnpm vitest run → __tests__/components/pages/SpeedHistogram.spec.tsx 4/4 pass (scale domains; one bar per row; 2 px clamp on a tiny bucket; zero bucket stays zero; flag wiring both ways).

How to test

  • pnpm i in frontend, start the dev server, open about
  • Open the dev options modal (Ctrl/Cmd-Shift-D) → Chart Renderer button toggles Chart.js ↔ TanStack Charts; the label shows the active renderer; reload → state persists
  • About: the speed histogram renders in both states; theme change re-tints; hover shows a tooltip with the bucket, user count and the top XX% line (TanStack half: check the whole column highlights, as with Chart.js index mode today)
  • Resize the window / narrow the viewport → both renderers stay responsive; the TanStack labels thin (Chart.js auto-rotates + skips)
  • Non-dev build: the flag cannot switch (stays Chart.js) — production charts are untouched by this PR's flag; only the bundle changes (the chart half ships)

Post-Draft Parity Fixes

Three commits after the initial draft, each verified in the browser against both renderers (parity flag both ways):

  • Focus ring — the library gives the chart <svg> tabindex 0 for keyboard focus, and Chrome paints the UA focus ring on mouse click; the old canvas wasn't focusable. The host suppresses the ring for pointer focus (svg:focus:not(:focus-visible)); the keyboard ring stays
  • Scale label font — the library defaults its axis labels to 11 px / weight 600 / 0.76 opacity and tick labels to 11 px / 0.68, while chart.js paints scale titles and ticks at 12 px / weight 400 / full opacity. The host pins the chart.js metrics on svg text (family still inherits from the body, like chart.js)
  • Scale chrome opacity — the library paints grid lines at 0.11 and axis/tick lines at 0.28 opacity, far fainter than chart.js's solid lines. The host pins stroke-opacity: 1 on the .ts-chart__grid / .ts-chart__axes lines (marks keep their own). S3's grid/axis stroke moves sub → subAlt, matching the spec and the chart.js wrapper (addColorsToOptions)

Bundle

vendor-chart raw gzip
master baseline 265.50 kB 85.30 kB
with the chart (this branch) 416.50 kB 137.96 kB (+52.7 kB)

Within the spec's budget; vendor-tanstack unchanged (no leakage); Chart.js goes in S12. The responsive/zero-bucket commits add no modules.

Checks

  • pnpm vitest run — 131 files / 2002 tests pass (new: __tests__/components/pages/SpeedHistogram.spec.tsx — scene scale domains, one bar per row in the theme colour with the 2 px clamp / zero-bucket behaviour, flag wiring both ways)
  • pnpm oxlint --type-aware --type-check
  • pnpm lint-styles, npx oxfmt on the diff
  • Production build: chart modules land in vendor-chart only
  • Browser parity check — both renderers on the about page: desktop + narrow, theme change, hover/tooltip (see Evidence)

Merge Danger

Door: two-way — the TanStack half is dev-visible only (flag defaults to Chart.js, always false in production); the production effect is the bundle. Revert is clean; S12 removes the whole branch's machinery at the move.

Blast Radius: about page (dev render + production bundle).

S1 of docs/specs/tanstack-charts:

- @tanstack/charts 1.5.0 (solid peer); vendor-chart bundle group takes the
  new regex and moves ahead of vendor-tanstack (first match wins)
- src/styles/tanstack-charts.scss: palette + tooltip tokens off the theme
  variables on the .ts-chart-host element, imported in vendor.scss
- dev-only chart renderer parity flag (dev/chart-parity.ts): defaults to
  Chart.js, persisted, dev-gated; DevOptions button shows the active
  renderer, exposed on __mt

Prod build verified: with a temporary probe import, the core + d3 modules
land in vendor-chart (+41.2 kB gzip for core + solid adapter, +66.4 kB for
the full planned surface); no new chunks, vendor-tanstack unchanged.
@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Nov 24, 2026
@socket-security

socket-security Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​tanstack/​charts@​1.5.09910010097100

View full report

@fehmer fehmer added the force-ci Force CI to run on draft PRs label Nov 24, 2026
@fehmer
fehmer marked this pull request as draft November 24, 2026 18:09
@monkeytypegeorge monkeytypegeorge added the docs Related to Markdown files and documentation label Nov 24, 2026
Signed-off-by: Christian Fehmer <cfe@sexy-developer.com>
@fehmer)

Signed-off-by: Christian Fehmer <cfe@sexy-developer.com>
…ts empty (@fehmer)

The host follows the container width, keeps a fixed 192 px height like the
section and the canvas it replaces, and seeds the first frame with
initialWidth, per the TanStack responsive-charts guide. Zero-count buckets
render empty (accepted minBarLength deviation); tiny buckets keep the 2 px
clamp. Spec updated: a tiny row exercises the clamp, a zero row stays zero.
@fehmer fehmer changed the title feat(charts): add TanStack Solid Charts foundation (S1) (@fehmer) feat(charts): add TanStack Solid Charts foundation + about speed histogram (S1, S3) (@fehmer) Nov 25, 2026
@fehmer
fehmer marked this pull request as ready for review November 25, 2026 14:42
@github-actions github-actions Bot added the waiting for review Pull requests that require a review before continuing label Nov 25, 2026
@fehmer
fehmer added this pull request to stack #8625 November 25, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Related to Markdown files and documentation force-ci Force CI to run on draft PRs frontend User interface or web stuff waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants