@pond-ts/charts 0.49.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,7 +8,9 @@ The `@pond-ts` packages — `pond-ts`, `@pond-ts/react`, `@pond-ts/charts`,
8
8
  tag, so this file covers them all. Pre-1.0: minor bumps may include new features
9
9
  and type-level changes; patch bumps are strictly additive.
10
10
 
11
- [Unreleased]: https://github.com/pond-ts/pond/compare/v0.49.0...HEAD
11
+ [Unreleased]: https://github.com/pond-ts/pond/compare/v0.51.0...HEAD
12
+ [0.51.0]: https://github.com/pond-ts/pond/compare/v0.50.0...v0.51.0
13
+ [0.50.0]: https://github.com/pond-ts/pond/compare/v0.49.0...v0.50.0
12
14
  [0.49.0]: https://github.com/pond-ts/pond/compare/v0.48.1...v0.49.0
13
15
  [0.48.1]: https://github.com/pond-ts/pond/compare/v0.48.0...v0.48.1
14
16
  [0.48.0]: https://github.com/pond-ts/pond/compare/v0.47.0...v0.48.0
@@ -49,6 +51,141 @@ and type-level changes; patch bumps are strictly additive.
49
51
 
50
52
  ## [Unreleased]
51
53
 
54
+ ## [0.51.0] — 2026-07-22
55
+
56
+ ### Changed
57
+
58
+ - **charts:** **`trackerPosition` is now a _followed_ position, not a hard pin —
59
+ enabling cross-chart cursor sync.** A live local hover wins over
60
+ `trackerPosition`, so the chart under the pointer shows its own cursor while
61
+ any chart without a local pointer follows the controlled time (mapped through
62
+ its own `xScale`, so it's correct across different zooms). This makes
63
+ **multi-chart dashboard cursor sync** fall out of the plain props: give every
64
+ `<ChartContainer>` the same `trackerPosition={sharedTime}` and set `sharedTime`
65
+ from each one's `onTrackerChanged` (clear it to `null` on the group's
66
+ `onPointerLeave`) — no "which chart is active" bookkeeping. **Behaviour
67
+ change:** previously a numeric `trackerPosition` overrode local hover, and
68
+ `trackerPosition={null}` force-hid the cursor; now `null` and `undefined` are
69
+ equivalent ("no controlled position") and a hovered chart always tracks its
70
+ pointer. To force a chart to never show a cursor, use `cursor="none"`. See the
71
+ "Synced cursors across charts" story. No type change (`number | null`).
72
+ - **charts:** **Line / area draw is ~3× faster on stroke-bound frames**
73
+ (PND-AFFINE / PND-GRADX; 2026-07 external-bench profile). When the curve is
74
+ linear and both scales are affine (every y axis is `scaleLinear`; x is
75
+ `scaleLinear` / `scaleTime` / the gap-free default time axis), `drawLine` and
76
+ `drawArea` now map points with an inline `k·v + b` over the typed arrays
77
+ instead of a per-point d3-scale closure + d3-shape generator — a **visually
78
+ identical** draw (guarded by the decimation pixel-identity and per-layer
79
+ visual-regression e2e). A real-gap trading-time axis, or a non-linear curve,
80
+ transparently keeps the exact d3 path. Measured on a JS-only micro-bench
81
+ (`scripts/perf-affine.mjs`): line 1M 60.4 → 19.0 ms (3.2×), area 1M 132 →
82
+ 38 ms (3.5×). Separately, the area fill gradient's full-series value extent is
83
+ now memoized per column buffer, so a y-zoom / pan repaint no longer re-walks
84
+ the whole series to find the gradient span. No API change.
85
+ - **charts:** **A y-zoom / y-autorange repaint no longer re-decimates line /
86
+ area layers** (PND-DECKEY; same 2026-07 profile, finding 3). The M4
87
+ decimation output is a pure function of the source data, x-domain, device
88
+ width, threshold, and session breaks — it never reads the y-scale — so it is
89
+ identical across every y-only frame. `drawLine` / `drawArea` now memoize the
90
+ cull+decimate result per source series (one entry, keyed on the x-scale
91
+ object + width + threshold + breaks), so a y-zoom / live y-autorange frame
92
+ reuses the prior polyline instead of re-binning O(N) points; a pan / x-zoom
93
+ mints a fresh x-scale and correctly recomputes. Measured
94
+ (`scripts/perf-deckey.mjs`): the ~5 ms/frame decimation walk at 1M points is
95
+ eliminated on every y-only frame. No API change.
96
+
97
+ ### Added
98
+
99
+ - **charts:** **`<BarChart decimate>` — dense column charts now decimate**
100
+ (PND-MARKDEC; 2026-07 profile, finding 4 — "column dead by 5M"). **Default
101
+ `true`**: once the visible **single-series** bars are denser than ~2 per device
102
+ pixel (each slot < ~1px), they're drawn as one per-column **envelope** rect —
103
+ the exact painted union `[min(value, baseline), max(value, baseline)]` of each
104
+ pixel column — instead of every bar, so a 100k–5M-bar column chart stays
105
+ interactive. **Visually lossless** at that density (a perf knob, not a style);
106
+ interaction still reads the source bars (`barAt`), and the per-bar
107
+ selection/hover highlight is suppressed only when decimated (a <1px bar's ring
108
+ isn't visible anyway). `decimate={false}` draws every bar; `{ threshold }`
109
+ tunes the samples-per-pixel factor. No-op for a stacked / multi-group
110
+ histogram (the low-count categorical path). `drawBars` now returns
111
+ `LayerDrawStats` (visible via `onDrawStats`). Measured
112
+ (`scripts/perf-markdec.mjs`, JS-only): the bar draw at 5M points drops
113
+ 485 → 26 ms (18.9×), 100k drops 9.7 → 0.9 ms (10.7×) — with the larger
114
+ rasterization win on top, browser-side.
115
+ - **charts:** **`panZoom` is now a three-way mode + a `bounds` extent.**
116
+ `<ChartContainer panZoom>` takes `'none'` / `'pan'` / `'panZoom'` (drag-only
117
+ vs. drag+wheel), with the old boolean kept as shorthand (`true` ⇒ `'panZoom'`,
118
+ `false` ⇒ `'none'`) — so existing charts are unchanged. A new `bounds`
119
+ (`[min, max]`) prop fences pan/zoom to an **outer** extent (panning into an
120
+ edge stops there keeping its span; zoom-out is capped at the whole span), the
121
+ companion
122
+ to the existing `minDuration` zoom-in floor — together they pin the reachable
123
+ window between an inner and outer bound. On a trading-time axis `bounds`
124
+ clamps in wall-clock ms. Purely additive; no type narrowing.
125
+ - **charts:** **Draw-cost + decimation observability** — `<ChartContainer
126
+ onDrawStats>` (PND-DECOBS; dashboard A/B friction, 2026-07-21). Fires a
127
+ `DrawStatsFrame` once per row-canvas repaint (keyed by an opaque `rowKey` for
128
+ multi-row attribution), one `LayerDrawInfo` per layer carrying its `as`,
129
+ measured `drawMs`, and — for a decimating layer (line / area / band / candle /
130
+ box) — `sourceCount` / `drawnCount` / `decimated`.
131
+ Compare `drawnCount` to `sourceCount` to see whether M4 engaged; read `drawMs`
132
+ for per-layer render cost. **Zero-overhead when unused** — the render loop
133
+ skips per-layer timing entirely unless a consumer subscribes. New exports:
134
+ `DrawStatsFrame`, `LayerDrawInfo`.
135
+
136
+ ### Fixed
137
+
138
+ - **charts:** hovering no longer repaints the row data canvas on every cursor
139
+ mousemove. The container frame minted a fresh `timeRange` array identity per
140
+ rebuild (and the frame rebuilds per cursor move), which the Layers draw
141
+ callback — depending on `container.timeRange` — read as a domain change:
142
+ each hover frame re-fired the canvas draw effect, including per-layer M4
143
+ re-decimation (measured 105 repaints per 122 mousemove events; with
144
+ `decimate` off, hover fell to ~10 fps). The tuple is now identity-stable on
145
+ its endpoints, restoring the SVG-overlay cursor contract (0 repaints, full
146
+ frame rate while hovering). Found running uPlot's bench protocol against
147
+ pond-charts; guarded by a new hover-sweep perf invariant in
148
+ `e2e/perf-invariants.spec.ts`.
149
+ - **charts:** hovering no longer re-renders cursor-independent components
150
+ (both `YAxis`, `Bar`/`Box`). The cursor position was a `ContainerFrame`
151
+ field, so every mousemove re-identified the whole (~50-field) frame and
152
+ re-rendered **all** its context consumers — even ones that never read the
153
+ cursor. The per-move cursor state (`cursorX`/`cursorY`/`cursorRowKey`) now
154
+ lives in a dedicated `CursorContext`; the frame stays identity-stable across
155
+ a hover, so only the genuine cursor consumers (the `Layers` overlay,
156
+ `XAxis` crosshair pill, `Legend` values) re-render. Measured: 4 → 2 React
157
+ commits per mousemove, ~25% less hover script time on the uPlot-bench
158
+ workload (the win scales with axis/row count). No API change — the split
159
+ types are internal (`PND-HOVCTX`, follow-up to the repaint fix above).
160
+ - **charts:** corrected the `@pond-ts/charts` package-header doc comment, which
161
+ described a "chunked Path2D cache" render stage that was explored and
162
+ **deferred**, never built (it doesn't help the pan case, which re-decimates
163
+ every frame). The stale comment had misled a consumer's perf investigation.
164
+
165
+ ## [0.50.0] — 2026-07-21
166
+
167
+ ### Added
168
+
169
+ - **charts:** M4 decimation extended to **`<Candlestick>`** (same auto-on
170
+ `decimate` prop). Dense candles are drawn as per-pixel-column **aggregate
171
+ candles** — `open=first`, `high=max`, `low=min`, `close=last` over the column —
172
+ i.e. re-bucketed to the pixel-column timeframe, the way a trading chart shows
173
+ fewer, wider candles as you zoom out (decimator §2.4). It is a faithful OHLC of
174
+ each column's span, never a distortion; the hover readout still reads the
175
+ **source** candle at the cursor (§2.3). Decimation gates on the **visible**
176
+ candle count, so a deep zoom into a large series still draws full-width
177
+ candles. Pass `decimate={false}` (and pre-aggregate upstream) for
178
+ fixed-timeframe candles.
179
+ - **charts:** M4 decimation extended to **`<BoxPlot>`** (same auto-on `decimate`
180
+ prop) — the interval-mark sibling of the candle. Dense boxes are drawn as
181
+ per-pixel-column **aggregate boxes**: the whiskers widen to the column's reach
182
+ (`min(lower)`/`max(upper)`), the body to its IQR envelope
183
+ (`min(q1)`/`max(q3)`), the centre line to the first box's median. Gates on the
184
+ **visible** box count (a deep zoom still draws full-width boxes); the
185
+ `hasBox`/`hasMedian` flags carry through, so a range-only box stays range-only.
186
+ Interaction is unaffected — hit-testing reads the source boxes (§2.3). Pass
187
+ `decimate={false}` to draw every box at its own slot.
188
+
52
189
  ## [0.49.0] — 2026-07-21
53
190
 
54
191
  ### Added
package/dist/AreaChart.js CHANGED
@@ -59,6 +59,7 @@ export function AreaChart({ series, column, as: semantic, axis, baseline, curve,
59
59
  const gapConnectorOpacity = container.theme.gap?.connectorOpacity ?? DEFAULT_GAP_CONNECTOR_OPACITY;
60
60
  const entry = useMemo(() => ({
61
61
  layer: {
62
+ as: semantic,
62
63
  yExtent: () => areaExtent(cs, baseline),
63
64
  // The container infers the shared x scale's kind from its layers — a
64
65
  // ValueSeries plots on a value axis, a TimeSeries on time.
package/dist/BandChart.js CHANGED
@@ -49,6 +49,7 @@ export function BandChart({ series, lower, upper, as: semantic, axis, curve, dec
49
49
  }, [semantic]);
50
50
  const entry = useMemo(() => ({
51
51
  layer: {
52
+ as: semantic,
52
53
  yExtent: () => bandExtent(bs),
53
54
  // The container infers the shared x scale's kind from its layers — a
54
55
  // ValueSeries plots on a value axis, a TimeSeries on time.
@@ -2,6 +2,7 @@ import { ValueSeries } from 'pond-ts';
2
2
  import type { SeriesSchema, TimeSeries, ValueSeriesSchema } from 'pond-ts';
3
3
  import { type BinRecord, type CategoryDatum } from './data.js';
4
4
  import { type Orientation } from './bars.js';
5
+ import type { DecimateOption } from './decimate.js';
5
6
  export interface BarChartProps<S extends SeriesSchema = SeriesSchema, VS extends ValueSeriesSchema = ValueSeriesSchema> {
6
7
  /**
7
8
  * The source series. Provide **exactly one** of `series` or `bins`.
@@ -120,6 +121,18 @@ export interface BarChartProps<S extends SeriesSchema = SeriesSchema, VS extends
120
121
  * would invert collapses to the style's `minWidth`.
121
122
  */
122
123
  gap?: number;
124
+ /**
125
+ * **M4 column decimation** (charts decimator wave). **Omitted ⇒ `true`**: once
126
+ * the visible bars are denser than ~2 per device pixel (each slot < ~1px), the
127
+ * **single-series** bars are drawn as one per-column **envelope** rect — the
128
+ * exact painted union `[min, max]` of each pixel column's bars — instead of every
129
+ * bar, so a 100k-bar column chart stays interactive. It is **visually lossless**
130
+ * at that density (a perf knob, not a style); interaction still reads the source
131
+ * bars. Pass `false` to always draw every bar, or `{ threshold }` to tune the
132
+ * samples-per-pixel factor. **No-op for a stacked / multi-group histogram** (the
133
+ * categorical case is low-count; only the single-series path decimates).
134
+ */
135
+ decimate?: DecimateOption;
123
136
  /**
124
137
  * This layer's `<Legend>` row(s): `false` ⇒ none (opt out), a string ⇒ the
125
138
  * display name of a **one-row** layer. **Omitted ⇒** the single path (and a
@@ -180,5 +193,5 @@ export interface BarChartProps<S extends SeriesSchema = SeriesSchema, VS extends
180
193
  * </Layers>
181
194
  * ```
182
195
  */
183
- export declare function BarChart<S extends SeriesSchema = SeriesSchema, VS extends ValueSeriesSchema = ValueSeriesSchema>({ series, bins, categories, column, columns, as: semantic, colors, binColors, orientation, ordinal, id, axis, gap, legend, index, }: BarChartProps<S, VS>): null;
196
+ export declare function BarChart<S extends SeriesSchema = SeriesSchema, VS extends ValueSeriesSchema = ValueSeriesSchema>({ series, bins, categories, column, columns, as: semantic, colors, binColors, orientation, ordinal, id, axis, gap, decimate, legend, index, }: BarChartProps<S, VS>): null;
184
197
  //# sourceMappingURL=BarChart.d.ts.map
package/dist/BarChart.js CHANGED
@@ -48,7 +48,7 @@ import { useSlotKey } from './use-slot-key.js';
48
48
  * </Layers>
49
49
  * ```
50
50
  */
51
- export function BarChart({ series, bins, categories, column, columns, as: semantic, colors, binColors, orientation = 'vertical', ordinal = false, id, axis, gap, legend, index = 0, }) {
51
+ export function BarChart({ series, bins, categories, column, columns, as: semantic, colors, binColors, orientation = 'vertical', ordinal = false, id, axis, gap, decimate = true, legend, index = 0, }) {
52
52
  const container = useContext(ContainerContext);
53
53
  if (container === null) {
54
54
  throw new Error('<BarChart> must be rendered inside a <ChartContainer>');
@@ -226,6 +226,7 @@ export function BarChart({ series, bins, categories, column, columns, as: semant
226
226
  const bs = shape.bs;
227
227
  return {
228
228
  layer: {
229
+ as: semantic,
229
230
  yExtent: () => barExtent(bs),
230
231
  xKind: binAxisKind,
231
232
  xExtent: () => bs.length === 0 ? null : [bs.begin[0], bs.end[bs.length - 1]],
@@ -266,7 +267,7 @@ export function BarChart({ series, bins, categories, column, columns, as: semant
266
267
  };
267
268
  },
268
269
  }),
269
- draw: (ctx, xScale, yScale) => drawBars(ctx, bs, xScale, yScale, singleStyle, resolveBarBaseline(yScale), gapPx, id, selection, hover),
270
+ draw: (ctx, xScale, yScale) => drawBars(ctx, bs, xScale, yScale, singleStyle, resolveBarBaseline(yScale), gapPx, id, selection, hover, decimate),
270
271
  },
271
272
  axisId: axis,
272
273
  index,
@@ -279,6 +280,7 @@ export function BarChart({ series, bins, categories, column, columns, as: semant
279
280
  const vertical = orientation === 'vertical';
280
281
  return {
281
282
  layer: {
283
+ as: semantic,
282
284
  // Horizontal puts the value on the shared x (always 'value'); vertical
283
285
  // keeps the bin axis on x. The bin axis on the *other* side is a linear
284
286
  // numeric scale either way (time ms label via <YAxis ticks>).
@@ -336,6 +338,7 @@ export function BarChart({ series, bins, categories, column, columns, as: semant
336
338
  label,
337
339
  id,
338
340
  gapPx,
341
+ decimate,
339
342
  stackMinWidth,
340
343
  selection,
341
344
  hover,
package/dist/BoxPlot.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ValueSeries } from 'pond-ts';
2
2
  import type { SeriesSchema, TimeSeries, ValueSeriesSchema } from 'pond-ts';
3
3
  import { type BoxShape } from './box.js';
4
+ import type { DecimateOption } from './decimate.js';
4
5
  export interface BoxPlotProps<S extends SeriesSchema = SeriesSchema, VS extends ValueSeriesSchema = ValueSeriesSchema> {
5
6
  /**
6
7
  * The source series. A `TimeSeries` plots against the time axis; a `ValueSeries`
@@ -98,6 +99,16 @@ export interface BoxPlotProps<S extends SeriesSchema = SeriesSchema, VS extends
98
99
  * (its `begin`).
99
100
  */
100
101
  id?: string;
102
+ /**
103
+ * **M4 viewport decimation** (charts decimator wave). **Omitted ⇒ `true`**:
104
+ * once the visible boxes are denser than ~2 per device pixel, they are drawn as
105
+ * per-pixel-column **aggregate boxes** — whiskers widen to the column's reach
106
+ * (`min(lower)`/`max(upper)`), the body to its IQR envelope
107
+ * (`min(q1)`/`max(q3)`), the centre line to the first box's median. Pass `false`
108
+ * to draw every box at its own slot. Interaction is unaffected (hit-testing
109
+ * reads the source boxes). Shares {@link LineChart}'s `DecimateOption`.
110
+ */
111
+ decimate?: DecimateOption;
101
112
  /**
102
113
  * This layer's `<Legend>` row: `false` ⇒ no row (opt out), a string ⇒ the
103
114
  * row's display name. **Omitted ⇒ a row named by the layer's readout
@@ -142,5 +153,5 @@ export interface BoxPlotProps<S extends SeriesSchema = SeriesSchema, VS extends
142
153
  * </Layers>
143
154
  * ```
144
155
  */
145
- export declare function BoxPlot<S extends SeriesSchema = SeriesSchema, VS extends ValueSeriesSchema = ValueSeriesSchema>({ series, lower, q1, median, q3, upper, as: semantic, axis, gap, shape, showMedian, offset, capWidth, id, legend, index, }: BoxPlotProps<S, VS>): null;
156
+ export declare function BoxPlot<S extends SeriesSchema = SeriesSchema, VS extends ValueSeriesSchema = ValueSeriesSchema>({ series, lower, q1, median, q3, upper, as: semantic, axis, gap, shape, showMedian, offset, capWidth, id, decimate, legend, index, }: BoxPlotProps<S, VS>): null;
146
157
  //# sourceMappingURL=BoxPlot.d.ts.map
package/dist/BoxPlot.js CHANGED
@@ -38,7 +38,7 @@ const MIN_BOX_WIDTH_PX = 1;
38
38
  * </Layers>
39
39
  * ```
40
40
  */
41
- export function BoxPlot({ series, lower, q1, median, q3, upper, as: semantic, axis, gap = 0, shape = 'whisker', showMedian = true, offset = 0, capWidth, id, legend, index = 0, }) {
41
+ export function BoxPlot({ series, lower, q1, median, q3, upper, as: semantic, axis, gap = 0, shape = 'whisker', showMedian = true, offset = 0, capWidth, id, decimate = true, legend, index = 0, }) {
42
42
  const container = useContext(ContainerContext);
43
43
  if (container === null) {
44
44
  throw new Error('<BoxPlot> must be rendered inside a <ChartContainer>');
@@ -73,6 +73,7 @@ export function BoxPlot({ series, lower, q1, median, q3, upper, as: semantic, ax
73
73
  const hoveredKey = id !== undefined && hov !== null && hov.id === id ? hov.key : null;
74
74
  const entry = useMemo(() => ({
75
75
  layer: {
76
+ as: semantic,
76
77
  yExtent: () => boxExtent(bx),
77
78
  // A ValueSeries plots on a value axis, a TimeSeries on time; the container
78
79
  // infers the shared x kind from its layers.
@@ -142,7 +143,7 @@ export function BoxPlot({ series, lower, q1, median, q3, upper, as: semantic, ax
142
143
  return { id, key: begin, value, color: style.whisker, label };
143
144
  },
144
145
  }),
145
- draw: (ctx, xScale, yScale) => drawBox(ctx, bx, xScale, yScale, style, gap, MIN_BOX_WIDTH_PX, shape, showMedian, offset, capWidth, selectedKey, hoveredKey),
146
+ draw: (ctx, xScale, yScale) => drawBox(ctx, bx, xScale, yScale, style, gap, MIN_BOX_WIDTH_PX, shape, showMedian, offset, capWidth, selectedKey, hoveredKey, decimate),
146
147
  },
147
148
  axisId: axis,
148
149
  index,
@@ -166,6 +167,7 @@ export function BoxPlot({ series, lower, q1, median, q3, upper, as: semantic, ax
166
167
  label,
167
168
  selectedKey,
168
169
  hoveredKey,
170
+ decimate,
169
171
  axis,
170
172
  index,
171
173
  ]);
@@ -1,4 +1,5 @@
1
1
  import type { SeriesSchema, TimeSeries } from 'pond-ts';
2
+ import type { DecimateOption } from './decimate.js';
2
3
  import { type CandleVariant, type ColorBy } from './ohlc.js';
3
4
  export interface CandlestickProps<S extends SeriesSchema> {
4
5
  /**
@@ -56,6 +57,18 @@ export interface CandlestickProps<S extends SeriesSchema> {
56
57
  * for a compact legend; the full quote is opt-in for a dense hover readout.
57
58
  */
58
59
  showOHLC?: boolean;
60
+ /**
61
+ * **M4 viewport decimation** (charts decimator wave). **Omitted ⇒ `true`**:
62
+ * once the visible candles are denser than ~2 per device pixel, they are drawn
63
+ * as per-pixel-column **aggregate candles** (`open=first`, `high=max`,
64
+ * `low=min`, `close=last`) — i.e. re-bucketed to the pixel-column timeframe, the
65
+ * way a trading chart shows fewer, wider candles as you zoom out. It is a
66
+ * faithful OHLC of each column's span (never a distortion), just at a coarser
67
+ * timeframe. Pass `false` to draw every candle at its own slot (and
68
+ * pre-aggregate upstream if you need a fixed timeframe). Shares
69
+ * {@link LineChart}'s `DecimateOption`.
70
+ */
71
+ decimate?: DecimateOption;
59
72
  /**
60
73
  * This layer's `<Legend>` row: `false` ⇒ no row (opt out), a string ⇒ the
61
74
  * row's display name. **Omitted ⇒ a row named by the layer's readout
@@ -96,5 +109,5 @@ export interface CandlestickProps<S extends SeriesSchema> {
96
109
  * </Layers>
97
110
  * ```
98
111
  */
99
- export declare function Candlestick<S extends SeriesSchema>({ series, open, high, low, close, as: semantic, axis, variant, colorBy, gap, showOHLC, legend, index, }: CandlestickProps<S>): null;
112
+ export declare function Candlestick<S extends SeriesSchema>({ series, open, high, low, close, as: semantic, axis, variant, colorBy, gap, showOHLC, decimate, legend, index, }: CandlestickProps<S>): null;
100
113
  //# sourceMappingURL=Candlestick.d.ts.map
@@ -31,7 +31,7 @@ import { useSlotKey } from './use-slot-key.js';
31
31
  * </Layers>
32
32
  * ```
33
33
  */
34
- export function Candlestick({ series, open = 'open', high = 'high', low = 'low', close = 'close', as: semantic, axis, variant = 'candle', colorBy = 'direction', gap = 0, showOHLC = false, legend, index = 0, }) {
34
+ export function Candlestick({ series, open = 'open', high = 'high', low = 'low', close = 'close', as: semantic, axis, variant = 'candle', colorBy = 'direction', gap = 0, showOHLC = false, decimate = true, legend, index = 0, }) {
35
35
  const container = useContext(ContainerContext);
36
36
  if (container === null) {
37
37
  throw new Error('<Candlestick> must be rendered inside a <ChartContainer>');
@@ -49,6 +49,7 @@ export function Candlestick({ series, open = 'open', high = 'high', low = 'low',
49
49
  const label = semantic ?? close;
50
50
  const entry = useMemo(() => ({
51
51
  layer: {
52
+ as: semantic,
52
53
  yExtent: () => ohlcExtent(ohlc),
53
54
  xKind: 'time',
54
55
  xExtent: () => ohlc.length === 0 ? null : [ohlc.x[0], ohlc.xEnd[ohlc.length - 1]],
@@ -83,7 +84,7 @@ export function Candlestick({ series, open = 'open', high = 'high', low = 'low',
83
84
  ];
84
85
  return samples;
85
86
  },
86
- draw: (ctx, xScale, yScale) => drawCandles(ctx, ohlc, xScale, yScale, style, variant, colorBy, gap),
87
+ draw: (ctx, xScale, yScale) => drawCandles(ctx, ohlc, xScale, yScale, style, variant, colorBy, gap, undefined, decimate),
87
88
  },
88
89
  axisId: axis,
89
90
  index,
@@ -96,6 +97,7 @@ export function Candlestick({ series, open = 'open', high = 'high', low = 'low',
96
97
  colorBy,
97
98
  gap,
98
99
  showOHLC,
100
+ decimate,
99
101
  axis,
100
102
  index,
101
103
  ]);
@@ -2,7 +2,7 @@ import { type ReactNode } from 'react';
2
2
  import { type DiscontinuityProvider, type TradingCalendarLike } from './tradingTimeScale.js';
3
3
  import { Sequence, BoundedSequence } from 'pond-ts';
4
4
  import type { TimeRange } from 'pond-ts';
5
- import { type AnnotationKind, type CreateSpec, type CursorMode, type SelectInfo, type TrackerInfo } from './context.js';
5
+ import { type AnnotationKind, type CreateSpec, type CursorMode, type SelectInfo, type TrackerInfo, type DrawStatsFrame } from './context.js';
6
6
  import { type AxisFormat, type CursorFormat } from './format.js';
7
7
  import { type ChartTheme } from './theme.js';
8
8
  export interface ChartContainerProps {
@@ -94,9 +94,25 @@ export interface ChartContainerProps {
94
94
  */
95
95
  showAxis?: boolean;
96
96
  /**
97
- * Controlled tracker position (epoch ms) — pins the synced crosshair across
98
- * rows. Omit for uncontrolled (the chart tracks the pointer itself); pass
99
- * `null` to force it hidden. See {@link onTrackerChanged}.
97
+ * Controlled tracker position (epoch ms) — where to show the synced crosshair
98
+ * **when this chart isn't the one under the pointer**. A live local hover
99
+ * always wins over it, so this is a *followed* position, not a hard pin:
100
+ * supply it to drive the cursor from outside (a scrubber, a playback head, or
101
+ * — the main use — **cross-chart sync**). Maps through this chart's own
102
+ * `xScale`, so it lands at the right pixel even under a different zoom.
103
+ *
104
+ * **Multi-chart sync** falls out of this plus {@link onTrackerChanged}: give
105
+ * every `<ChartContainer>` the same `trackerPosition={sharedTime}` and set
106
+ * `sharedTime` from each one's `onTrackerChanged`. The hovered chart favors its
107
+ * own pointer (and reports the time out); the others follow. Clear `sharedTime`
108
+ * to `null` on the group's `onPointerLeave` so the crosshair lifts when the
109
+ * pointer leaves every chart. (See the "Synced cursors across charts" story /
110
+ * dashboard guide.)
111
+ *
112
+ * **Omit or pass `null`** (equivalent) for no controlled position — a hovered
113
+ * chart still tracks its pointer, a non-hovered one shows nothing. To force a
114
+ * chart to *never* show a cursor, use `cursor="none"`, not `trackerPosition`.
115
+ * See {@link onTrackerChanged}.
100
116
  */
101
117
  trackerPosition?: number | null;
102
118
  /**
@@ -154,9 +170,10 @@ export interface ChartContainerProps {
154
170
  onRegionSelect?: (range: readonly [number, number]) => void;
155
171
  /**
156
172
  * Which modifier a region-drag needs — set `'shift'` when you also enable
157
- * `panZoom` and want **plain drag to pan, shift-drag to select**. It's only
158
- * enforced while `panZoom` is on (with pan off there's no gesture conflict, so
159
- * shift is optional — either drag selects). **Omitted** ⇒ a region-drag
173
+ * **pan** (`panZoom="pan"` or `"panZoom"`) and want **plain drag to pan,
174
+ * shift-drag to select**. It's only enforced while pan is enabled (with pan
175
+ * off there's no gesture conflict, so shift is optional — either drag
176
+ * selects). **Omitted** ⇒ a region-drag
160
177
  * **preempts** pan (drag always selects; document that precedence for users).
161
178
  * Wheel-zoom is unaffected in every case.
162
179
  */
@@ -166,6 +183,17 @@ export interface ChartContainerProps {
166
183
  * you can render a readout outside the chart), and `null` on leave.
167
184
  */
168
185
  onTrackerChanged?: (info: TrackerInfo | null) => void;
186
+ /**
187
+ * Draw-cost + decimation observability. Fires **once per row-canvas repaint**
188
+ * with a {@link DrawStatsFrame} — one {@link LayerDrawInfo} per layer in that
189
+ * row carrying its `as`, `drawMs`, and (for a decimating layer) `sourceCount`
190
+ * / `drawnCount` / `decimated`. Compare `drawnCount` to `sourceCount` to see
191
+ * whether M4 engaged; read `drawMs` for per-layer render cost. **Omitted ⇒ no
192
+ * measurement** — the render loop skips per-layer timing entirely, so this is
193
+ * zero-overhead when unused. Keep the callback cheap (it runs inside the draw
194
+ * frame); route it to a ref/store rather than doing React state work per frame.
195
+ */
196
+ onDrawStats?: (frame: DrawStatsFrame) => void;
169
197
  /**
170
198
  * Controlled selection — the selected mark (echo the `onSelect` arg back), or
171
199
  * `null`. **Omitted ⇒ uncontrolled** (a click on a selectable layer manages it
@@ -212,10 +240,32 @@ export interface ChartContainerProps {
212
240
  */
213
241
  onHover?: (hit: SelectInfo | null) => void;
214
242
  /**
215
- * Enable pan/zoom: drag the plot to pan the time range, wheel to zoom around
216
- * the cursor. **Default off** — so it doesn't capture drag/scroll unless asked.
243
+ * Which pan/zoom gestures the plot captures:
244
+ *
245
+ * - `'none'` (or `false`, the **default**) — neither; the plot doesn't capture
246
+ * drag or scroll.
247
+ * - `'pan'` — drag to pan the time range, **no** wheel-zoom (scroll still
248
+ * scrolls the page).
249
+ * - `'panZoom'` (or `true`) — drag to pan **and** wheel to zoom around the
250
+ * cursor.
251
+ *
252
+ * The boolean form is the back-compat shorthand (`true` ⇒ `'panZoom'`,
253
+ * `false` ⇒ `'none'`). Bound the reachable range with {@link bounds}
254
+ * (zoom-out / pan extent) and {@link minDuration} (zoom-in floor).
255
+ */
256
+ panZoom?: boolean | 'none' | 'pan' | 'panZoom';
257
+ /**
258
+ * **Outer pan/zoom extent** — `[min, max]` (same units as {@link range}) the
259
+ * view can never move outside. Panning into an edge stops there (the window
260
+ * keeps its span); zooming out is capped at this width, so `bounds` is the
261
+ * zoom-**out** ceiling that pairs with the {@link minDuration} zoom-**in**
262
+ * floor. **Omit for no limit** (pan/zoom is unbounded). Constrains gestures
263
+ * (and any range routed through the container); seed {@link range} within it.
264
+ * On a trading-time axis the clamp is in wall-clock ms (a sensible outer
265
+ * limit; the per-session pan/zoom math already holds the trading span at each
266
+ * calendar edge).
217
267
  */
218
- panZoom?: boolean;
268
+ bounds?: readonly [number, number];
219
269
  /**
220
270
  * Controlled view range — fires on pan/zoom with the new `[start, end]`. Wire
221
271
  * it back to `range` for a controlled chart; omit for uncontrolled (the
@@ -340,5 +390,5 @@ export interface ChartContainerProps {
340
390
  * {@link TimeAxis} at the bottom, aligned under the plots. Y axes are per-row
341
391
  * (`<YAxis>`).
342
392
  */
343
- export declare function ChartContainer({ range, width, rowGap, showAxis, trackerPosition, onTrackerChanged, selected, onSelect, hovered, onHover, panZoom, onTimeRangeChange, minDuration, cursor, cursorSequence, onRegionSelect, regionSelectModifier, cursorTime, crosshairSnap, editAnnotations, creating, onCreate, onSelectAnnotation, onHoverAnnotation, onEditAnnotation, snap, timeFormat, cursorFormat, theme, discontinuities, calendar, spacing, grid, sessionDividers, children, }: ChartContainerProps): import("react/jsx-runtime").JSX.Element;
393
+ export declare function ChartContainer({ range, width, rowGap, showAxis, trackerPosition, onTrackerChanged, onDrawStats, selected, onSelect, hovered, onHover, panZoom, bounds, onTimeRangeChange, minDuration, cursor, cursorSequence, onRegionSelect, regionSelectModifier, cursorTime, crosshairSnap, editAnnotations, creating, onCreate, onSelectAnnotation, onHoverAnnotation, onEditAnnotation, snap, timeFormat, cursorFormat, theme, discontinuities, calendar, spacing, grid, sessionDividers, children, }: ChartContainerProps): import("react/jsx-runtime").JSX.Element;
344
394
  //# sourceMappingURL=ChartContainer.d.ts.map