@pond-ts/charts 0.70.0 → 0.71.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/AGENTS.md +3 -1
- package/API.md +30 -31
- package/CHANGELOG.md +111 -1
- package/dist/AreaChart.d.ts +30 -22
- package/dist/AreaChart.js +37 -22
- package/dist/BoxPlot.js +5 -3
- package/dist/Candlestick.d.ts +3 -3
- package/dist/Candlestick.js +5 -5
- package/dist/ChartContainer.d.ts +8 -149
- package/dist/ChartContainer.js +68 -111
- package/dist/ChartRow.d.ts +1 -12
- package/dist/ChartRow.js +15 -30
- package/dist/HeatMap.d.ts +3 -3
- package/dist/HeatMap.js +3 -3
- package/dist/Layers.js +84 -34
- package/dist/XAxis.js +1 -0
- package/dist/area.d.ts +6 -5
- package/dist/area.js +13 -6
- package/dist/axis-events.d.ts +4 -4
- package/dist/brush.d.ts +13 -21
- package/dist/brush.js +22 -36
- package/dist/context.d.ts +81 -96
- package/dist/cursors.d.ts +81 -51
- package/dist/cursors.js +164 -127
- package/dist/elapsed.d.ts +1 -1
- package/dist/elapsed.js +1 -1
- package/dist/format.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/selection-fixtures.d.ts +4 -7
- package/dist/selection-fixtures.js +0 -9
- package/dist/selection-stories.d.ts +4 -6
- package/dist/selection-stories.js +4 -4
- package/dist/selectors.d.ts +2 -3
- package/dist/selectors.js +2 -3
- package/dist/tracker.d.ts +10 -28
- package/dist/tracker.js +17 -40
- package/dist/tradingTimeScale.d.ts +2 -2
- package/package.json +3 -3
package/dist/context.d.ts
CHANGED
|
@@ -84,23 +84,18 @@ export interface ContainerFrame {
|
|
|
84
84
|
* The values are on {@link CursorFrame} ({@link CursorContext}). */
|
|
85
85
|
setHoverY(y: number | null, rowKey: symbol | null): void;
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* `cursor="region"` buckets — the intervals (from `cursorSequence`) realized
|
|
94
|
-
* over the current view, sorted + non-overlapping. `Layers` finds the one under
|
|
95
|
-
* the pointer and shades it (mapped through `xScale`, so on a trading-time axis
|
|
96
|
-
* the closed part of the bucket collapses). `undefined` when no `cursorSequence`
|
|
97
|
-
* is set.
|
|
87
|
+
* `<RangeCursor>` buckets — the intervals (from its `sequence`, or a
|
|
88
|
+
* `<MultiSelector sequence>`, or a bar layer's bins) realized over the
|
|
89
|
+
* current view, sorted + non-overlapping. `Layers` finds the one under the
|
|
90
|
+
* pointer and shades it (mapped through `xScale`, so on a trading-time axis
|
|
91
|
+
* the closed part of the bucket collapses). `undefined` when there is
|
|
92
|
+
* nothing to snap to.
|
|
98
93
|
*/
|
|
99
94
|
readonly cursorBuckets: readonly Interval[] | undefined;
|
|
100
95
|
/**
|
|
101
96
|
* The `region`-cursor **drag anchor** in axis units (epoch ms on a time axis,
|
|
102
97
|
* the axis value on a value axis), or `null` when not dragging. A drag on a
|
|
103
|
-
*
|
|
98
|
+
* range cursor (only when its `onDragRelease` is set) records the press
|
|
104
99
|
* position here; the band then spans from the anchor's bucket to the pointer's
|
|
105
100
|
* bucket (extending bucket by bucket), or freeform when there are no buckets.
|
|
106
101
|
* Cleared on release.
|
|
@@ -128,18 +123,6 @@ export interface ContainerFrame {
|
|
|
128
123
|
readonly previewSpans: readonly SpanSelection[];
|
|
129
124
|
/** Set / clear the live sweep preview (see {@link previewSpans}). */
|
|
130
125
|
setPreviewSpans(spans: readonly SpanSelection[]): void;
|
|
131
|
-
/**
|
|
132
|
-
* One-shot callback fired when a `region`-cursor **drag** is released, with the
|
|
133
|
-
* selected `[lo, hi]` span in **axis units** — epoch ms on a time axis, the axis
|
|
134
|
-
* value on a value axis (snapped to the `cursorSequence` buckets when present,
|
|
135
|
-
* else the raw drag span). The neutral numeric pair mirrors the container's
|
|
136
|
-
* polymorphic `range` input (which never takes the axis *kind* from its value);
|
|
137
|
-
* a time-axis consumer who wants a `TimeRange` constructs one from the pair.
|
|
138
|
-
* Providing it is what makes the region cursor **draggable**; the cursor does
|
|
139
|
-
* not keep the range (it reverts to the single-bucket highlight). Typical use:
|
|
140
|
-
* zoom the view, or map the span onto a subscription's range params.
|
|
141
|
-
*/
|
|
142
|
-
readonly onRegionSelect: ((range: readonly [number, number]) => void) | undefined;
|
|
143
126
|
/**
|
|
144
127
|
* A stable sink for per-repaint {@link DrawStatsFrame}s, or `undefined` when no
|
|
145
128
|
* `onDrawStats` consumer is subscribed — the `undefined` is the signal for
|
|
@@ -148,13 +131,6 @@ export interface ContainerFrame {
|
|
|
148
131
|
* `onDrawStats` arrow doesn't thrash the draw memo.
|
|
149
132
|
*/
|
|
150
133
|
readonly reportDrawStats: ((frame: DrawStatsFrame) => void) | undefined;
|
|
151
|
-
/**
|
|
152
|
-
* Require a modifier key held to start a region-drag — set to `'shift'` to make
|
|
153
|
-
* plain drag **pan** and **shift**-drag select, when `panZoom` is on. Only
|
|
154
|
-
* enforced while pan is enabled (with no pan there's no gesture to share, so the
|
|
155
|
-
* modifier is optional). `undefined` ⇒ a region-drag preempts pan.
|
|
156
|
-
*/
|
|
157
|
-
readonly regionSelectModifier: 'shift' | undefined;
|
|
158
134
|
/**
|
|
159
135
|
* The selected marks — **empty when nothing is selected**, never `null`.
|
|
160
136
|
* Shared across rows, insertion-ordered. A layer highlights every mark
|
|
@@ -243,13 +219,6 @@ export interface ContainerFrame {
|
|
|
243
219
|
* plain single-mark hover, exactly as before.
|
|
244
220
|
*/
|
|
245
221
|
setHovered(hit: SelectInfo | null, rowKey?: symbol, block?: readonly SelectInfo[]): void;
|
|
246
|
-
/** The default in-chart cursor presentation for all rows ({@link CursorMode});
|
|
247
|
-
* a row may override it via its own `cursor`. */
|
|
248
|
-
readonly cursor: CursorMode;
|
|
249
|
-
/** Show the cursor's time atop the in-chart readout (when a row's cursor draws
|
|
250
|
-
* one), formatted by {@link formatReadout} (else {@link formatTime}, matching
|
|
251
|
-
* the time axis). */
|
|
252
|
-
readonly cursorTime: boolean;
|
|
253
222
|
/**
|
|
254
223
|
* Whether the chart is in **annotation-edit mode** — suppresses the data cursor
|
|
255
224
|
* and makes editable annotations interactive (hovering reveals their handles +
|
|
@@ -259,10 +228,10 @@ export interface ContainerFrame {
|
|
|
259
228
|
readonly editAnnotations: boolean;
|
|
260
229
|
/** Format an epoch-ms instant the same way the time axis labels its ticks —
|
|
261
230
|
* shared by `<TimeAxis>` and (absent {@link formatReadout}) the cursor-time
|
|
262
|
-
* readout. Shaped by the container `timeFormat` only, never `
|
|
231
|
+
* readout. Shaped by the container `timeFormat` only, never a cursor `format`. */
|
|
263
232
|
readonly formatTime: (epochMs: number) => string;
|
|
264
233
|
/**
|
|
265
|
-
* The **readout** channel — defined only when
|
|
234
|
+
* The **readout** channel — defined only when a mounted cursor's `format`
|
|
266
235
|
* is set (time or value axis; a category axis reads names). Readout
|
|
267
236
|
* consumers — the crosshair x pill and in-plot cursor time, marker axis
|
|
268
237
|
* indicators, annotation auto-labels — read `formatReadout ?? <their label
|
|
@@ -274,7 +243,7 @@ export interface ContainerFrame {
|
|
|
274
243
|
* The IANA zone the time axis renders in — the container's resolved
|
|
275
244
|
* `timeZone` (explicit prop, else the calendar's), canonical id; `undefined`
|
|
276
245
|
* when the axis is in the runtime's local zone. For a consumer's own
|
|
277
|
-
* formatter (`timeFormat` / `
|
|
246
|
+
* formatter (`timeFormat` / cursor `format` functions receive epoch ms) to
|
|
278
247
|
* read the same zone the ticks do.
|
|
279
248
|
*/
|
|
280
249
|
readonly timeZone: string | undefined;
|
|
@@ -289,13 +258,13 @@ export interface ContainerFrame {
|
|
|
289
258
|
* custom format owns the whole label, so the ladder mustn't second-line it. */
|
|
290
259
|
readonly xFormatCustom: boolean;
|
|
291
260
|
/**
|
|
292
|
-
* Whether an explicit
|
|
261
|
+
* Whether an explicit cursor `format` shaped {@link formatReadout} —
|
|
293
262
|
* as opposed to the axis kind supplying its own default readout (the elapsed
|
|
294
263
|
* axis's finer duration). The two are indistinguishable from the field alone,
|
|
295
264
|
* and `<XAxis>` must tell them apart to honour the documented pill precedence
|
|
296
|
-
* `
|
|
265
|
+
* `cursor format → axis format → container`: a cursor **`format`** outranks an
|
|
297
266
|
* explicit `<XAxis format>`, a **default** does not. Without this the elapsed
|
|
298
|
-
* default silently occupied the `
|
|
267
|
+
* default silently occupied the cursor `format` slot and a wall-clock strip's
|
|
299
268
|
* pill read durations (issue #540, finding 2).
|
|
300
269
|
*/
|
|
301
270
|
readonly xReadoutCustom: boolean;
|
|
@@ -359,7 +328,7 @@ export interface ContainerFrame {
|
|
|
359
328
|
* fact behind {@link resolveSweep} (which builds the per-drag gesture and is
|
|
360
329
|
* for the pointer-down path). Rows read this to decide the **resting block
|
|
361
330
|
* preview**: with one in scope over a sweep-capable row, the shared brush
|
|
362
|
-
* band becomes the resting cursor (
|
|
331
|
+
* band becomes the resting cursor (when no cursor component is mounted) and
|
|
363
332
|
* hover lights the whole snap block a drag would select. Identity changes
|
|
364
333
|
* when the selector registry does, so it is safe in render memos.
|
|
365
334
|
*/
|
|
@@ -502,8 +471,7 @@ export interface ContainerFrame {
|
|
|
502
471
|
readonly firstRowKey: symbol | null;
|
|
503
472
|
/**
|
|
504
473
|
* Register a mounted **cursor** ({@link CursorEntry}) — the `<LineCursor>` /
|
|
505
|
-
* `<CrosshairCursor>` / … presets
|
|
506
|
-
* from the legacy string props) call this, keyed by the component's
|
|
474
|
+
* `<CrosshairCursor>` / … presets call this, keyed by the component's
|
|
507
475
|
* per-instance slot key. The container resolves the per-row effective set
|
|
508
476
|
* (row mounts override container mounts — see `effectiveCursorEntries`) and
|
|
509
477
|
* the rows/`<XAxis>` render the registered slots. Update is in place;
|
|
@@ -658,8 +626,6 @@ export declare const ContainerContext: import("react").Context<ContainerFrame |
|
|
|
658
626
|
*
|
|
659
627
|
* The cursor *time* is **not** here — each consumer derives it locally from
|
|
660
628
|
* `cursorX` + its own `xScale` (an in-bounds `xScale.invert`), as before.
|
|
661
|
-
* ({@link ContainerFrame} still carries a `cursorTime` **boolean** — the
|
|
662
|
-
* unrelated "show time in the readout" config flag.)
|
|
663
629
|
*/
|
|
664
630
|
export interface CursorFrame {
|
|
665
631
|
/**
|
|
@@ -750,8 +716,13 @@ export interface RowLayer {
|
|
|
750
716
|
* when the layer was given no `as`.
|
|
751
717
|
*/
|
|
752
718
|
readonly as?: string | undefined;
|
|
753
|
-
/**
|
|
754
|
-
|
|
719
|
+
/**
|
|
720
|
+
* This layer's finite-value `[min, max]`, or `null` if it has none. `scale`
|
|
721
|
+
* is the kind of the axis the extent is being fitted to, for a layer whose
|
|
722
|
+
* extent depends on it (an area's zero baseline has no position on a log
|
|
723
|
+
* axis, so it must not be pulled into one).
|
|
724
|
+
*/
|
|
725
|
+
yExtent(scale?: YScaleKind): [number, number] | null;
|
|
755
726
|
/**
|
|
756
727
|
* The **kind of x axis** this layer's data lives on — `'time'` for a
|
|
757
728
|
* `TimeSeries`, `'value'` for a `ValueSeries`, `'category'` for a categorical
|
|
@@ -787,7 +758,7 @@ export interface RowLayer {
|
|
|
787
758
|
binCategories?(): readonly string[] | null;
|
|
788
759
|
/**
|
|
789
760
|
* A bar/histogram layer's bar `[begin, end)` spans, as pond `Interval`s — the
|
|
790
|
-
* **shared snap buckets**. When present (and no `
|
|
761
|
+
* **shared snap buckets**. When present (and no cursor `sequence` is set), a
|
|
791
762
|
* region drag snaps bar by bar and a `<MultiSelector>` sweep's band extends
|
|
792
763
|
* bar by bar, so a histogram gets bin-aligned selection for free. Only a
|
|
793
764
|
* **vertical** bar layer publishes them — a horizontal chart puts the value
|
|
@@ -811,8 +782,8 @@ export interface RowLayer {
|
|
|
811
782
|
* {@link BoxPlot} implements it (low/q1/median/q3/high on one flag at the box's
|
|
812
783
|
* top-centre); line/area/bar/scatter omit it and use the per-sample flag from
|
|
813
784
|
* {@link sampleAt}. `null` when nothing is under the cursor. (`sampleAt` still
|
|
814
|
-
* fans the same values to the off-chart readout
|
|
815
|
-
*
|
|
785
|
+
* fans the same values to the off-chart readout and to the crosshair, which
|
|
786
|
+
* snaps to them; `cursorFlag` only replaces the per-series dots and chips.)
|
|
816
787
|
*/
|
|
817
788
|
cursorFlag?(time: number): CursorFlag | null;
|
|
818
789
|
/**
|
|
@@ -1164,7 +1135,7 @@ export interface SelectModifiers {
|
|
|
1164
1135
|
readonly metaKey: boolean;
|
|
1165
1136
|
/**
|
|
1166
1137
|
* **Note the conflict:** `shift` is already the drag chord for
|
|
1167
|
-
* `<
|
|
1138
|
+
* `<RangeCursor dragModifier="shift">` on a continuous axis, so a
|
|
1168
1139
|
* shift-click there may also be the start of a region drag. Reported for
|
|
1169
1140
|
* completeness; think before you give it a second meaning. (There is
|
|
1170
1141
|
* deliberately no derived `range` flag for this reason — an ordinal range
|
|
@@ -1234,9 +1205,8 @@ export interface SelectorEntry {
|
|
|
1234
1205
|
}
|
|
1235
1206
|
/**
|
|
1236
1207
|
* The span a completed `<RangeCursor>` drag reports to `onDragRelease` —
|
|
1237
|
-
* **one uniform shape with an optional y** (interaction RFC A3.3), not
|
|
1238
|
-
*
|
|
1239
|
-
* consumer must narrow.
|
|
1208
|
+
* **one uniform shape with an optional y** (interaction RFC A3.3), not a bare
|
|
1209
|
+
* pair and not a polymorphic union a consumer must narrow.
|
|
1240
1210
|
*
|
|
1241
1211
|
* `x` is `[lo, hi]` in **axis units** — epoch ms on a time axis, the axis
|
|
1242
1212
|
* value (strike, distance, …) on a value axis — snapped to the cursor's
|
|
@@ -1377,22 +1347,23 @@ export interface TrackerInfo {
|
|
|
1377
1347
|
readonly values: readonly TrackerSample[];
|
|
1378
1348
|
}
|
|
1379
1349
|
/**
|
|
1380
|
-
*
|
|
1381
|
-
*
|
|
1350
|
+
* What a `<CrosshairCursor>` is **snapped to** — the one data point its reticle
|
|
1351
|
+
* centres on, handed to `<CrosshairCursor onSnap>`. The same fields as a
|
|
1352
|
+
* {@link TrackerSample} (the point's `x` and `value`, the series `label` and
|
|
1353
|
+
* `color`, the optional `readout`), plus the y axis it was read against and the
|
|
1354
|
+
* value exactly as the crosshair's axis pill shows it.
|
|
1382
1355
|
*
|
|
1383
|
-
*
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1386
|
-
* - `point` — a dot on each series at the cursor, no line.
|
|
1387
|
-
* - `inline` — dots + a value chip beside each.
|
|
1388
|
-
* - `flag` — dots + value flags (a staffed flag from each point; the staff
|
|
1389
|
-
* geometry lands in a later phase — for now flags stack at the top).
|
|
1390
|
-
* - `crosshair` — the synced vertical line + a dot on each series, with each
|
|
1391
|
-
* series' value pinned to its y-axis edge (an on-axis pill) and the cursor
|
|
1392
|
-
* time pinned to the x-axis. The ChartIQ / trading-terminal readout. Values
|
|
1393
|
-
* snap to the series (the axis pills read like ticks), not the raw mouse Y.
|
|
1356
|
+
* Where {@link TrackerInfo} lists *every* series at the cursor time, this is
|
|
1357
|
+
* the single one the reticle picked — the series nearest the pointer's height
|
|
1358
|
+
* in the row being hovered.
|
|
1394
1359
|
*/
|
|
1395
|
-
export
|
|
1360
|
+
export interface CursorSnap extends TrackerSample {
|
|
1361
|
+
/** The id of the `<YAxis>` the value is measured against (the row's default
|
|
1362
|
+
* axis id when the layer names none). */
|
|
1363
|
+
readonly axisId: string;
|
|
1364
|
+
/** The value formatted by that axis's formatter — the axis pill's text. */
|
|
1365
|
+
readonly formatted: string;
|
|
1366
|
+
}
|
|
1396
1367
|
/**
|
|
1397
1368
|
* How a cursor wants the shared `cursorX` snapped, **declared, resolved by the
|
|
1398
1369
|
* container** (interaction RFC A2.3). The x-snap consults each layer's
|
|
@@ -1418,6 +1389,13 @@ export type CursorSnapX = 'none' | 'sample' | 'sequence';
|
|
|
1418
1389
|
export interface ResolvedCursorSample {
|
|
1419
1390
|
readonly px: number;
|
|
1420
1391
|
readonly py: number;
|
|
1392
|
+
/** The sample's raw x (epoch ms on a time axis) — what `px` was scaled from. */
|
|
1393
|
+
readonly x: number;
|
|
1394
|
+
/** The sample's raw value — what `py` and `formatted` were made from. */
|
|
1395
|
+
readonly value: number;
|
|
1396
|
+
/** The layer's `readout` source value, when it has one (see
|
|
1397
|
+
* {@link TrackerSample.readout}). */
|
|
1398
|
+
readonly readout?: number;
|
|
1421
1399
|
readonly axisId: string;
|
|
1422
1400
|
readonly side: 'left' | 'right';
|
|
1423
1401
|
/** Distance in px from the plot's `side` edge to this axis's inner edge —
|
|
@@ -1463,8 +1441,18 @@ export interface ResolvedCursorFrame {
|
|
|
1463
1441
|
* it is drawing in the row the pointer is in). */
|
|
1464
1442
|
readonly hoveredRowKey: symbol | null;
|
|
1465
1443
|
/** Per-series resolved measurements at the cursor time (empty when the
|
|
1466
|
-
* effective cursors declared no need for them, or nothing is hovered).
|
|
1444
|
+
* effective cursors declared no need for them, or nothing is hovered). A
|
|
1445
|
+
* layer that consolidates its readout into one flag (BoxPlot) is left out:
|
|
1446
|
+
* per-series dots and chips would repeat that flag. */
|
|
1467
1447
|
readonly samples: readonly ResolvedCursorSample[];
|
|
1448
|
+
/**
|
|
1449
|
+
* The crosshair's candidates: every layer's resolved samples, **including**
|
|
1450
|
+
* a consolidated-flag layer's (a box plot's five quantiles). The reticle
|
|
1451
|
+
* picks one value, so a box's quantiles are things it can land on rather
|
|
1452
|
+
* than marks that would repeat the box's flag. Empty unless a cursor
|
|
1453
|
+
* declared {@link CursorWants.reticle}.
|
|
1454
|
+
*/
|
|
1455
|
+
readonly reticleSamples: readonly ResolvedCursorSample[];
|
|
1468
1456
|
/** Resolved consolidated flags (BoxPlot) — the flag cursor's one-chip form. */
|
|
1469
1457
|
readonly flags: readonly ResolvedCursorFlag[];
|
|
1470
1458
|
/**
|
|
@@ -1608,8 +1596,11 @@ export interface CursorSpec {
|
|
|
1608
1596
|
/** What a cursor needs the container to resolve per pointer move — declared at
|
|
1609
1597
|
* registration so a line-only cursor never pays for per-sample measurement. */
|
|
1610
1598
|
export interface CursorWants {
|
|
1611
|
-
/** Per-series {@link ResolvedCursorSample}s (dots, chips
|
|
1599
|
+
/** Per-series {@link ResolvedCursorSample}s (dots, chips). */
|
|
1612
1600
|
readonly samples: boolean;
|
|
1601
|
+
/** {@link ResolvedCursorFrame.reticleSamples} — the crosshair's pick,
|
|
1602
|
+
* box plots included. */
|
|
1603
|
+
readonly reticle: boolean;
|
|
1613
1604
|
/** Consolidated {@link ResolvedCursorFlag}s (the flag cursor only). */
|
|
1614
1605
|
readonly flags: boolean;
|
|
1615
1606
|
/** The range band (+ the degenerate band line). */
|
|
@@ -1629,18 +1620,6 @@ export interface CursorEntry {
|
|
|
1629
1620
|
/** Mount scope: a row's key when mounted inside a `<ChartRow>` (the per-row
|
|
1630
1621
|
* override), `null` when mounted at the container (the default for all rows). */
|
|
1631
1622
|
readonly rowKey: symbol | null;
|
|
1632
|
-
/** Synthesized by the deprecation shim from the legacy string props. A scope
|
|
1633
|
-
* with any non-legacy (component-mounted) cursor drops its legacy entries —
|
|
1634
|
-
* mounting a component overrides the string prop during the window. */
|
|
1635
|
-
readonly legacy: boolean;
|
|
1636
|
-
/**
|
|
1637
|
-
* The shim entry nobody asked for: the container's `'line'` **default**,
|
|
1638
|
-
* synthesized with no `cursor` prop set. A mounted `<MultiSelector>`'s
|
|
1639
|
-
* resting block preview (the brush band as the resting cursor) replaces
|
|
1640
|
-
* only these — an explicitly chosen cursor, component-mounted or via the
|
|
1641
|
-
* legacy string prop, still wins.
|
|
1642
|
-
*/
|
|
1643
|
-
readonly implicit?: boolean;
|
|
1644
1623
|
/**
|
|
1645
1624
|
* Whether this cursor owns **snap and gesture** (RFC A2.5): at most one per
|
|
1646
1625
|
* scope (dev-warned otherwise), resolved to the hovered row's innermost
|
|
@@ -1649,22 +1628,31 @@ export interface CursorEntry {
|
|
|
1649
1628
|
readonly ownsGesture: boolean;
|
|
1650
1629
|
readonly wants: CursorWants;
|
|
1651
1630
|
/** The range cursor's bucket sequence (realized by the container into the
|
|
1652
|
-
* shared snap buckets
|
|
1631
|
+
* shared snap buckets). */
|
|
1653
1632
|
readonly sequence?: Sequence | BoundedSequence | undefined;
|
|
1654
|
-
/** The range cursor's drag-release callback
|
|
1655
|
-
* successor) — read by the brush recognizer (`resolveRangeDrag`), which
|
|
1633
|
+
/** The range cursor's drag-release callback — read by the brush recognizer (`resolveRangeDrag`), which
|
|
1656
1634
|
* wraps it into the range-drag session. Only a `<RangeCursor>` sets it. */
|
|
1657
1635
|
readonly onDragRelease?: ((span: RangeSpan) => void) | undefined;
|
|
1658
1636
|
/** Whether the range drag is live — **resolved** at build time
|
|
1659
1637
|
* (`enableDrag ?? !!onDragRelease`), so `false` here means frozen: the
|
|
1660
1638
|
* gesture is off even though the callback is wired (§6's OFF switch). */
|
|
1661
1639
|
readonly enableDrag?: boolean | undefined;
|
|
1662
|
-
/** The modifier the range drag needs
|
|
1663
|
-
*
|
|
1640
|
+
/** The modifier the range drag needs — only enforced while pan is
|
|
1641
|
+
* enabled. */
|
|
1664
1642
|
readonly dragModifier?: 'shift' | undefined;
|
|
1665
|
-
/** The cursor's readout format
|
|
1666
|
-
*
|
|
1643
|
+
/** The cursor's readout format — resolved by the container into the shared
|
|
1644
|
+
* readout channel. */
|
|
1667
1645
|
readonly format?: CursorFormat | undefined;
|
|
1646
|
+
/**
|
|
1647
|
+
* The crosshair's snap report (`<CrosshairCursor onSnap>`). A row calls it
|
|
1648
|
+
* with its render frame when it is the hovered row, and with `null` when the
|
|
1649
|
+
* pointer is elsewhere; the cursor picks the snapped sample from the frame
|
|
1650
|
+
* and calls the consumer only when that pick changes. Only set when the
|
|
1651
|
+
* consumer passed `onSnap`, so a crosshair nobody listens to never picks or
|
|
1652
|
+
* builds a report (each row still looks up its snap owner, two short
|
|
1653
|
+
* filters over the registered cursors).
|
|
1654
|
+
*/
|
|
1655
|
+
readonly reportSnap?: ((f: ResolvedCursorFrame | null) => void) | undefined;
|
|
1668
1656
|
}
|
|
1669
1657
|
/** A registered layer plus the axis id it draws against. */
|
|
1670
1658
|
export interface LayerEntry {
|
|
@@ -1846,9 +1834,6 @@ export interface RowFrame {
|
|
|
1846
1834
|
* is absent. The other half of matching an axis-edge pill to its axis (see
|
|
1847
1835
|
* {@link axisOffsets}) — the pill takes this colour, else the theme's. */
|
|
1848
1836
|
readonly axisColors: ReadonlyMap<string, string>;
|
|
1849
|
-
/** This row's cursor-mode override, or `undefined` to inherit the container's
|
|
1850
|
-
* default ({@link ContainerFrame.cursor}). */
|
|
1851
|
-
readonly cursor: CursorMode | undefined;
|
|
1852
1837
|
/** Whether this is the first (topmost) row — the shared cursor-time chip shows
|
|
1853
1838
|
* here only, not repeated on every row. Derived from {@link ContainerFrame.firstRowKey}. */
|
|
1854
1839
|
readonly isFirstRow: boolean;
|
package/dist/cursors.d.ts
CHANGED
|
@@ -1,34 +1,49 @@
|
|
|
1
1
|
import type { Sequence, BoundedSequence } from 'pond-ts';
|
|
2
|
-
import { type CursorEntry, type
|
|
2
|
+
import { type CursorEntry, type CursorSnap, type RangeSpan } from './context.js';
|
|
3
3
|
import type { CursorFormat } from './format.js';
|
|
4
4
|
export interface LineCursorProps {
|
|
5
5
|
/** Show the cursor's time atop the readout (once, on the first row),
|
|
6
6
|
* formatted by the container's readout channel. Default `false`. */
|
|
7
7
|
showTime?: boolean;
|
|
8
|
+
/** The readout format for the time this cursor shows (and for marker
|
|
9
|
+
* indicators + annotation auto-labels) — the shared readout channel; see
|
|
10
|
+
* {@link CrosshairCursorProps.format}. */
|
|
11
|
+
format?: CursorFormat;
|
|
8
12
|
}
|
|
9
|
-
/** The synced vertical cursor **line
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
export declare function LineCursor({ showTime }?: LineCursorProps): null;
|
|
13
|
+
/** The synced vertical cursor **line**. Pair with an off-chart readout via
|
|
14
|
+
* `onTrackerChanged`. */
|
|
15
|
+
export declare function LineCursor({ showTime, format }?: LineCursorProps): null;
|
|
13
16
|
export interface PointCursorProps {
|
|
14
17
|
/** Show the cursor's time atop the readout (first row). Default `false`. */
|
|
15
18
|
showTime?: boolean;
|
|
19
|
+
/** The readout format for the time this cursor shows (and for marker
|
|
20
|
+
* indicators + annotation auto-labels) — the shared readout channel; see
|
|
21
|
+
* {@link CrosshairCursorProps.format}. */
|
|
22
|
+
format?: CursorFormat;
|
|
16
23
|
}
|
|
17
|
-
/** A **dot on each series** at the cursor, no line
|
|
18
|
-
export declare function PointCursor({ showTime }?: PointCursorProps): null;
|
|
24
|
+
/** A **dot on each series** at the cursor, no line. */
|
|
25
|
+
export declare function PointCursor({ showTime, format, }?: PointCursorProps): null;
|
|
19
26
|
export interface InlineCursorProps {
|
|
20
27
|
/** Show the cursor's time atop the readout (first row). Default `false`. */
|
|
21
28
|
showTime?: boolean;
|
|
29
|
+
/** The readout format for the time this cursor shows (and for marker
|
|
30
|
+
* indicators + annotation auto-labels) — the shared readout channel; see
|
|
31
|
+
* {@link CrosshairCursorProps.format}. */
|
|
32
|
+
format?: CursorFormat;
|
|
22
33
|
}
|
|
23
|
-
/** Dots **plus a value chip beside each
|
|
24
|
-
export declare function InlineCursor({ showTime }?: InlineCursorProps): null;
|
|
34
|
+
/** Dots **plus a value chip beside each**. */
|
|
35
|
+
export declare function InlineCursor({ showTime, format, }?: InlineCursorProps): null;
|
|
25
36
|
export interface FlagCursorProps {
|
|
26
37
|
/** Show the cursor's time atop the flag stack (first row). Default `false`. */
|
|
27
38
|
showTime?: boolean;
|
|
39
|
+
/** The readout format for the time this cursor shows (and for marker
|
|
40
|
+
* indicators + annotation auto-labels) — the shared readout channel; see
|
|
41
|
+
* {@link CrosshairCursorProps.format}. */
|
|
42
|
+
format?: CursorFormat;
|
|
28
43
|
}
|
|
29
|
-
/** Dots + **staffed value flags** stacked near the top of the row —
|
|
30
|
-
*
|
|
31
|
-
export declare function FlagCursor({ showTime }?: FlagCursorProps): null;
|
|
44
|
+
/** Dots + **staffed value flags** stacked near the top of the row — a `cursorFlag` layer (BoxPlot)
|
|
45
|
+
* consolidates onto one flag. */
|
|
46
|
+
export declare function FlagCursor({ showTime, format }?: FlagCursorProps): null;
|
|
32
47
|
export interface CrosshairCursorProps {
|
|
33
48
|
/**
|
|
34
49
|
* Reticle **y** snapping. **Default `true`** — the reticle centres on the
|
|
@@ -41,15 +56,49 @@ export interface CrosshairCursorProps {
|
|
|
41
56
|
* **Default `true`** — the time pill is the crosshair's readout; there is
|
|
42
57
|
* no per-row time chip to opt into. */
|
|
43
58
|
showTime?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
59
|
+
/**
|
|
60
|
+
* The **cursor / marker readout** format — the x-axis time pill, marker
|
|
61
|
+
* axis indicators, and annotation auto-labels — **independent of the tick
|
|
62
|
+
* labels** on both axis kinds: it does **not** disqualify the `dateStyle`
|
|
63
|
+
* ladder (time), and it never moves the tick labels (value). It beats an
|
|
64
|
+
* explicit `<XAxis format>` for the **readout only** — pill precedence is
|
|
65
|
+
* `format → axis format → container` — so terse ticks can pair with a
|
|
66
|
+
* precise readout (`+2.0σ` labels, `+1.83σ` pill).
|
|
67
|
+
*
|
|
68
|
+
* **Omitted ⇒ the axis's own formatter.** On a time axis that default is
|
|
69
|
+
* grain-aware: the readout formats at the axis's granularity, so a
|
|
70
|
+
* day-or-coarser axis reads a **date** (never a time-of-day) and a sub-day
|
|
71
|
+
* axis reads date + clock. On a value axis it is the tick formatter.
|
|
72
|
+
*
|
|
73
|
+
* A d3 specifier **string** formats uniformly (time specifier on a time
|
|
74
|
+
* axis, number specifier on a value axis); a **function**
|
|
75
|
+
* `(value, { grain, defaultText }) => string` receives the axis's resolved
|
|
76
|
+
* coarse grain (`undefined` on a value axis) and the default readout text,
|
|
77
|
+
* so it can branch on the zoom level and pass `defaultText` through. One
|
|
78
|
+
* channel per chart: when several mounted cursors set `format`, the first
|
|
79
|
+
* mounted wins. (A category axis reads names, and a `transform`ed axis's
|
|
80
|
+
* pill speaks its derived unit — neither consults it.)
|
|
81
|
+
*/
|
|
48
82
|
format?: CursorFormat;
|
|
83
|
+
/**
|
|
84
|
+
* Tells you what the reticle is **snapped to** — the series (`label`,
|
|
85
|
+
* `color`, `axisId`) and the point (`x`, `value`, `formatted`) its centre dot
|
|
86
|
+
* sits on — and `null` when it lets go (the pointer leaves the chart, or
|
|
87
|
+
* moves to a row with no data under it). Fires only when the snapped point
|
|
88
|
+
* **changes**, not on every pointer move.
|
|
89
|
+
*
|
|
90
|
+
* Reports the pointer's snap only: with `snap={false}` the reticle follows
|
|
91
|
+
* the pointer rather than a series, so this stays `null`; and a reticle
|
|
92
|
+
* shown by a controlled `trackerPosition` with no pointer on the chart
|
|
93
|
+
* reports `null` too. For every series' value at the cursor time, use the
|
|
94
|
+
* container's `onTrackerChanged`.
|
|
95
|
+
*/
|
|
96
|
+
onSnap?: (snap: CursorSnap | null) => void;
|
|
49
97
|
}
|
|
50
|
-
/** The inspection **reticle
|
|
51
|
-
* centre dot
|
|
52
|
-
|
|
98
|
+
/** The inspection **reticle**: dashed cross lines, a
|
|
99
|
+
* centre dot in the snapped series' colour, the value pinned to its y axis,
|
|
100
|
+
* the time pinned to the x axis. */
|
|
101
|
+
export declare function CrosshairCursor({ snap, showTime, format, onSnap, }?: CrosshairCursorProps): null;
|
|
53
102
|
export interface RangeCursorProps {
|
|
54
103
|
/**
|
|
55
104
|
* The bucketing for the hover band **and the drag's snap** — a pond
|
|
@@ -57,7 +106,8 @@ export interface RangeCursorProps {
|
|
|
57
106
|
* trading calendar's sessions). A drag extends **bucket by bucket** over
|
|
58
107
|
* these. **Omit ⇒ freeform**: the cursor renders as a plain line and a drag
|
|
59
108
|
* spans the raw `[lo, hi]` (a bar/histogram layer's bins still snap both
|
|
60
|
-
* when present). Time axis only
|
|
109
|
+
* when present). Time axis only; on a category axis the band always
|
|
110
|
+
* snaps to the slot under the pointer. Pass a stable
|
|
61
111
|
* reference (the buckets memoize on it).
|
|
62
112
|
*/
|
|
63
113
|
sequence?: Sequence | BoundedSequence;
|
|
@@ -75,8 +125,11 @@ export interface RangeCursorProps {
|
|
|
75
125
|
* so drag-to-zoom is `onDragRelease={(s) => setRange(s.x)}`.
|
|
76
126
|
*
|
|
77
127
|
* The drag **preempts pan** unless {@link dragModifier} shares the gesture.
|
|
78
|
-
* Continuous x only
|
|
79
|
-
*
|
|
128
|
+
* Continuous x only: on a **category** axis the hover band still shades the
|
|
129
|
+
* slot under the pointer, but the drag never starts — a numeric span means
|
|
130
|
+
* nothing there, and dragging across bars is `<MultiSelector>`'s gesture
|
|
131
|
+
* (it reports the bars). The container dev-warns when this is wired on a
|
|
132
|
+
* category axis.
|
|
80
133
|
*/
|
|
81
134
|
onDragRelease?: (span: RangeSpan) => void;
|
|
82
135
|
/**
|
|
@@ -94,44 +147,26 @@ export interface RangeCursorProps {
|
|
|
94
147
|
* and you want **plain drag to pan, shift-drag to select**. **Only
|
|
95
148
|
* enforced while pan is enabled** (with pan off there is no gesture
|
|
96
149
|
* conflict, so either drag selects). Omitted ⇒ the drag preempts pan.
|
|
97
|
-
* The `regionSelectModifier` successor.
|
|
98
150
|
*/
|
|
99
151
|
dragModifier?: 'shift';
|
|
100
152
|
}
|
|
101
153
|
/**
|
|
102
|
-
* The **range** cursor
|
|
154
|
+
* The **range** cursor (RFC A4.1 names
|
|
103
155
|
* it for what it emits: a live extent — and, dragged, exactly what
|
|
104
156
|
* `ChartContainer.range` accepts — against the annotation `<Region>`'s fixed
|
|
105
|
-
* mark). Hover shades the bucket under the pointer
|
|
157
|
+
* mark). Hover shades the bucket under the pointer (on a category axis, the
|
|
158
|
+
* slot); wiring
|
|
106
159
|
* {@link RangeCursorProps.onDragRelease} adds the drag, which fires once on
|
|
107
160
|
* release and reverts (RFC §6: a region is deliberately a cursor **and** a
|
|
108
161
|
* drag that fires and resets). The gesture rides the shared brush recognizer
|
|
109
162
|
* (`brush.tsx`) — one engine arbitrating every drag claim on the plot.
|
|
110
163
|
*/
|
|
111
164
|
export declare function RangeCursor({ sequence, onDragRelease, enableDrag, dragModifier, }?: RangeCursorProps): null;
|
|
112
|
-
/**
|
|
113
|
-
* The deprecation shim (internal): synthesizes the preset equivalent of a
|
|
114
|
-
* legacy `cursor` string — the container's `cursor` prop (or its `'line'`
|
|
115
|
-
* default), and `<ChartRow cursor>` inside a row. Registers as `legacy`, so a
|
|
116
|
-
* component-mounted cursor in the same scope overrides it.
|
|
117
|
-
*/
|
|
118
|
-
export declare function LegacyCursor({ mode, showTime, snap, sequence, implicit, }: {
|
|
119
|
-
mode: CursorMode;
|
|
120
|
-
/** The container's `cursorTime` (the in-plot time readout opt-in). */
|
|
121
|
-
showTime: boolean;
|
|
122
|
-
/** The container's `crosshairSnap` (the reticle y-snap). */
|
|
123
|
-
snap: boolean;
|
|
124
|
-
sequence?: Sequence | BoundedSequence | undefined;
|
|
125
|
-
/** This shim carries the container's un-asked-for `'line'` DEFAULT (no
|
|
126
|
-
* `cursor` prop set) — the only cursor a mounted `<MultiSelector>`'s
|
|
127
|
-
* resting block preview replaces (see {@link CursorEntry.implicit}). */
|
|
128
|
-
implicit?: boolean;
|
|
129
|
-
}): null;
|
|
130
165
|
/**
|
|
131
166
|
* The cursors in effect for a row: the row's own mounts when it has any (the
|
|
132
|
-
* per-row override — nearest mount wins,
|
|
133
|
-
*
|
|
134
|
-
*
|
|
167
|
+
* per-row override — nearest mount wins), else the container-scoped mounts.
|
|
168
|
+
* A row that wants no cursor while its siblings have one mounts the cursors
|
|
169
|
+
* per row rather than at the container.
|
|
135
170
|
*/
|
|
136
171
|
export declare function effectiveCursorEntries(all: readonly CursorEntry[], rowKey: symbol): readonly CursorEntry[];
|
|
137
172
|
/** The scope's single snap/gesture owner (RFC A2.5) — first mount wins; the
|
|
@@ -153,9 +188,4 @@ export declare function xAxisCursorEntries(all: readonly CursorEntry[], hoveredR
|
|
|
153
188
|
export declare function warnOnDuplicateGestureOwners(all: readonly CursorEntry[], warned: {
|
|
154
189
|
current: boolean;
|
|
155
190
|
}): void;
|
|
156
|
-
/** @internal The dev deprecation notice for a legacy cursor prop — one line
|
|
157
|
-
* naming the replacement, shared by the container and row shims. */
|
|
158
|
-
export declare function legacyCursorWarning(lines: readonly string[]): string;
|
|
159
|
-
/** @internal The preset name a legacy `cursor` mode maps to (for warnings). */
|
|
160
|
-
export declare function presetNameFor(mode: CursorMode): string;
|
|
161
191
|
//# sourceMappingURL=cursors.d.ts.map
|