Skip to content

refactor(ui): shared uPlot axis/cursor/range helpers#160

Merged
daharoni merged 1 commit into
mainfrom
refactor/shared-chart-axis-primitives
Jul 8, 2026
Merged

refactor(ui): shared uPlot axis/cursor/range helpers#160
daharoni merged 1 commit into
mainfrom
refactor/shared-chart-axis-primitives

Conversation

@daharoni

@daharoni daharoni commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

The audit found the same uPlot boilerplate copy-pasted into every chart component across the apps:

  • The theme axis chrome — { stroke: AXIS_TEXT, grid: { stroke: AXIS_GRID }, ticks: { stroke: AXIS_TICK } } — plus consistent label styling (6+ copies).
  • The integer-only tick values formatter.
  • The cursor-sync config { sync: { key, setSeries: true } } and the static { drag: { x: false, y: false } }.
  • The degenerate-span range guard (uPlot's drawAxesGrid crashes on a zero [v, v] span), re-implemented in AsymptoteTrends and inline elsewhere.

This collapses them into one place in @calab/ui/chart (axis-helpers.ts):

  • chartAxis(overrides) / labeledAxis(label, overrides) — axis chrome + labels
  • integerTickValues / hiddenTickValues — reusable axis values formatters
  • syncCursor(key) / staticCursor — cursor configs
  • safeRange(padFrac) — the zero-span guard

Migrated

The live direct-SolidUplot charts now use the helpers: AsymptoteTrends, KernelConvergence, KernelDisplay, HistogramCard, and the shared TracePanel (which backs TraceInspector + CaTune). This centralizes the chart chrome so all apps stay consistent — per the "CaDecon is one of several CaLab apps" guidance.

Dead components (drilldown/*, SubsetVariance — imported nowhere) are not migrated; they're left for the dead-code cleanup pass.

Behavior

Pure refactor — no visual or behavioral change. Verified in-browser across Asymptote / Kernel / Distributions / Kernel Shape / Trace Inspector: identical rendering, axes/colors/markers intact, 0 console errors.

Checks

typecheck, eslint, prettier, and all 289 TS tests pass.

Follow-ups (deferred)

Legend unification (fold KernelDisplay + AsymptoteTrends custom swatch markup and KernelConvergence's uPlot-native legend onto the shared TraceLegend) — the other half of the chart-primitives consolidation — and the dead-code removal.

🤖 Generated with Claude Code

The theme axis chrome ({ stroke: AXIS_TEXT, grid: { stroke: AXIS_GRID },
ticks: { stroke: AXIS_TICK } }) plus label styling, the integer-tick formatter,
the cursor-sync config, and the degenerate-span range guard were copy-pasted
into every chart across the apps. Collapse them into @calab/ui/chart:

- chartAxis(overrides) / labeledAxis(label, overrides) — axis chrome + labels
- integerTickValues / hiddenTickValues — reusable  formatters
- syncCursor(key) / staticCursor — cursor configs
- safeRange(padFrac) — the zero-span guard (uPlot crashes on a [v, v] range)

Migrate the live direct-SolidUplot charts to the helpers: AsymptoteTrends,
KernelConvergence, KernelDisplay, HistogramCard, and the shared TracePanel.
Behavior-preserving — no visual change (verified in-browser across all tabs).

Dead components (drilldown/*, SubsetVariance — imported nowhere) are left for
the cleanup pass rather than migrated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@daharoni daharoni merged commit 7993151 into main Jul 8, 2026
6 checks passed
@daharoni daharoni deleted the refactor/shared-chart-axis-primitives branch July 8, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant