#6

feat: yDomain — auto-fitted and explicit y-domains for cartesian charts

OpenDloomPlzwants to merge intofrom

Motivation

The y-scale is currently always [0, max]. That's right for bars and stacks, but for value time-series it has two sharp edges:

  1. High-magnitude, low-variance series flatten. A $4M portfolio moving ±$50k renders as a near-flat line — the signal is in the variance, and the zero anchor throws it away.
  2. Negative values clamp. A PnL series that dips below 0 can't render at all.

There's also no way to pin the domain from outside, which matters when a host draws DOM overlays that must share the chart's value↔pixel mapping (e.g. a draggable price-range slider over an area chart).

What this adds

A yDomain prop on the cartesian roots (AreaChart/LineChart/BarChart) plus a passthrough on Sparkline:

  • "zero" (default — no behavior change): today's zero-anchored, nice()d domain.
  • "auto": [min − pad, max + pad] fitted to the data (8% pad), negatives supported. Area fills anchor to the domain floor.
  • [lo, hi]: explicit domain used verbatim (no padding, no nice()), so a host can reproduce the exact mapping: y = plotH * (1 − (v − lo)/(hi − lo)).

Stacked/percent stacks stay zero-anchored (yDomain is ignored there, as documented). YDomain is exported from the index. Registry JSON regenerated with npm run build.

Activity

3
tripwire-dev[bot]4mo ago

passed — nothing tripped. good to merge.

DloomPlz4mo ago

Rebased onto the registry/CLI architecture + the #12 memoization rework. The domain is normalized to primitive deps before feeding the new computeBands/buildYScale memos, so a host passing a fresh [lo, hi] tuple each render can't invalidate them. Registry JSON regenerated; suite green (24/24).