Skip to content

feat(charts): render the account daily activity chart through the parity flag (S5) (@fehmer) - #8627

Draft
fehmer wants to merge 7 commits into
feature/ts-charts-s4-account-histogramfrom
feature/ts-charts-s5-daily-activity
Draft

fehmer wants to merge 7 commits into
feature/ts-charts-s4-account-histogramfrom
feature/ts-charts-s5-daily-activity

Conversation

@fehmer

@fehmer fehmer commented Nov 26, 2026

Copy link
Copy Markdown
Member

Summary

The account daily activity chart (per-day minutes bar + average-speed line + trendline) now also renders through TanStack Charts, switched by the dev-only parity flag. The legacy Chart.js half is kept as the Show fallback until S12.

 <DailyActivityChart> (components/pages/account/DailyActivityChart.tsx)
   <AsyncContent dataQuery>
+    <Show when={getUseTanstackCharts()}
+      fallback={<ChartJs name="DailyActivity" …/>}>   // stepping stone, removed in S12
+      <Chart definition={buildDailyActivityChartDefinition(…)} />
+    </Show>
-    <ChartJs name="DailyActivity" …/>
   </AsyncContent>

The TanStack definition mirrors the Chart.js datasets:

buildDailyActivityChartDefinition
  marks   barY  minutes/day        → left  `y`  scale
          lineY average wpm        → right `avgWpm` scale
          dot   average wpm points → right `avgWpm` scale
          trend linearRegressionY(ci 0) → left `y`, solid, no band
  scales  x        scaleUtc, ~3-month ticks (d MMM)
          y        left  minutes,  beginAtZero
          avgWpm   right avg speed, beginAtZero
  tooltip focus "group-x" → per-day rows (time typing, tests, wpm, accuracy, …)

Parity fixes folded in:

  • beginAtZero via viewport: { domain: [0, max] }, skipped when the data is all-zero — a [0, 0] viewport throws in the library, so an all-zero history must fall back to the fitted scale.
  • x ticks use a preferred count: 8; the utc scale derives its interval from that, resolving to the same ~3-month interval Chart.js' maxTicksLimit: 20 produces (a raw pixel spacing over-packed the axis to monthly ticks).
  • Trendline is dotted (strokeDasharray: "2 2"), matching the Chart.js trendline plugin's dotted style.

Evidence

  • pnpm vitest run __tests__/components/pages/account/DailyActivityChart.spec.tsx → 8 passed (scale bindings, beginAtZero viewport, all-zero guard, dotted trendline with no band, per-day group-x tooltip, flag switch).
  • Full frontend suite: 134 files / 2019 passed; pnpm oxlint --type-aware --type-check clean.
  • Browser parity on /account (dev flag on vs Chart.js): minutes bars, average-speed line/dots, trendline, and x-tick density all match; tooltip and theme reactivity verified.

Merge Danger

Door: two-way. The whole TanStack path sits behind the dev-only parity flag (getUseTanstackCharts), which is always false in production — production keeps the existing Chart.js chart. Reverting the commit (or flipping the flag off) restores the status quo.

Blast Radius: contained — dev-only; the production default (Chart.js) is untouched.

@monkeytypegeorge monkeytypegeorge added frontend User interface or web stuff docs Related to Markdown files and documentation labels Nov 26, 2026
@fehmer
fehmer added this pull request to stack #8625 November 26, 2026 12:16
…c scale (@fehmer)

The utc scale derives its tick interval from a *preferred* count rather than a
hard max, so the previous 55px spacing over-packed the axis to monthly ticks.
A preferred count of 8 resolves to the same ~3-month interval chart.js produces
with maxTicksLimit: 20 on a dense multi-month history.
@fehmer
fehmer force-pushed the feature/ts-charts-s5-daily-activity branch from 449c0f4 to 2b22832 Compare November 26, 2026 15:32
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 frontend User interface or web stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants