insomni-plot 0.1.0-alpha.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/LICENSE.md +674 -0
- package/README.md +81 -0
- package/dist/core.d.mts +340 -0
- package/dist/core.mjs +1047 -0
- package/dist/index.d.mts +3426 -0
- package/dist/index.mjs +12762 -0
- package/dist/interactions-DEFL_F4E.mjs +5395 -0
- package/dist/range-presets-CzECsu3V.d.mts +1523 -0
- package/package.json +34 -0
- package/src/annotations.d.ts +121 -0
- package/src/annotations.ts +438 -0
- package/src/axis.d.ts +184 -0
- package/src/axis.test.ts +131 -0
- package/src/axis.ts +765 -0
- package/src/colorbar.d.ts +69 -0
- package/src/colorbar.ts +294 -0
- package/src/colors.d.ts +57 -0
- package/src/colors.test.ts +28 -0
- package/src/colors.ts +486 -0
- package/src/core.ts +299 -0
- package/src/format.d.ts +54 -0
- package/src/format.ts +138 -0
- package/src/grammar/accessibility.d.ts +147 -0
- package/src/grammar/accessibility.test.ts +199 -0
- package/src/grammar/accessibility.ts +443 -0
- package/src/grammar/aes.d.ts +35 -0
- package/src/grammar/aes.test.ts +75 -0
- package/src/grammar/aes.ts +120 -0
- package/src/grammar/annotations.d.ts +86 -0
- package/src/grammar/annotations.test.ts +68 -0
- package/src/grammar/annotations.ts +336 -0
- package/src/grammar/attach-brush.d.ts +44 -0
- package/src/grammar/attach-brush.test.ts +214 -0
- package/src/grammar/attach-brush.ts +111 -0
- package/src/grammar/attach-presets.d.ts +33 -0
- package/src/grammar/attach-presets.test.ts +106 -0
- package/src/grammar/attach-presets.ts +215 -0
- package/src/grammar/chart.d.ts +952 -0
- package/src/grammar/chart.test.ts +118 -0
- package/src/grammar/chart.ts +1172 -0
- package/src/grammar/color-utils.d.ts +29 -0
- package/src/grammar/color-utils.test.ts +53 -0
- package/src/grammar/color-utils.ts +66 -0
- package/src/grammar/constants.d.ts +45 -0
- package/src/grammar/constants.ts +61 -0
- package/src/grammar/coord.d.ts +183 -0
- package/src/grammar/coord.test.ts +355 -0
- package/src/grammar/coord.ts +619 -0
- package/src/grammar/data/pivot.d.ts +57 -0
- package/src/grammar/data/pivot.ts +107 -0
- package/src/grammar/emphasis-driver.d.ts +69 -0
- package/src/grammar/emphasis-driver.test.ts +199 -0
- package/src/grammar/emphasis-driver.ts +205 -0
- package/src/grammar/equality.d.ts +3 -0
- package/src/grammar/equality.ts +40 -0
- package/src/grammar/facet.d.ts +63 -0
- package/src/grammar/facet.test.ts +60 -0
- package/src/grammar/facet.ts +175 -0
- package/src/grammar/geoms/_categorical.d.ts +94 -0
- package/src/grammar/geoms/_categorical.ts +0 -0
- package/src/grammar/geoms/_distribution.d.ts +52 -0
- package/src/grammar/geoms/_distribution.ts +125 -0
- package/src/grammar/geoms/_mark.d.ts +69 -0
- package/src/grammar/geoms/_mark.ts +136 -0
- package/src/grammar/geoms/_shape.d.ts +41 -0
- package/src/grammar/geoms/_shape.ts +74 -0
- package/src/grammar/geoms/aggregate.d.ts +95 -0
- package/src/grammar/geoms/aggregate.test.ts +554 -0
- package/src/grammar/geoms/aggregate.ts +840 -0
- package/src/grammar/geoms/area.d.ts +32 -0
- package/src/grammar/geoms/area.test.ts +165 -0
- package/src/grammar/geoms/area.ts +578 -0
- package/src/grammar/geoms/band.d.ts +27 -0
- package/src/grammar/geoms/band.test.ts +57 -0
- package/src/grammar/geoms/band.ts +126 -0
- package/src/grammar/geoms/bar.d.ts +56 -0
- package/src/grammar/geoms/bar.test.ts +367 -0
- package/src/grammar/geoms/bar.ts +1054 -0
- package/src/grammar/geoms/boxplot.d.ts +129 -0
- package/src/grammar/geoms/boxplot.test.ts +299 -0
- package/src/grammar/geoms/boxplot.ts +834 -0
- package/src/grammar/geoms/connected-scatter.d.ts +27 -0
- package/src/grammar/geoms/connected-scatter.test.ts +157 -0
- package/src/grammar/geoms/connected-scatter.ts +63 -0
- package/src/grammar/geoms/emphasis.d.ts +76 -0
- package/src/grammar/geoms/emphasis.test.ts +135 -0
- package/src/grammar/geoms/emphasis.ts +162 -0
- package/src/grammar/geoms/histogram.d.ts +75 -0
- package/src/grammar/geoms/histogram.test.ts +262 -0
- package/src/grammar/geoms/histogram.ts +740 -0
- package/src/grammar/geoms/index.d.ts +20 -0
- package/src/grammar/geoms/index.ts +77 -0
- package/src/grammar/geoms/interval.d.ts +31 -0
- package/src/grammar/geoms/interval.test.ts +154 -0
- package/src/grammar/geoms/interval.ts +342 -0
- package/src/grammar/geoms/line.d.ts +38 -0
- package/src/grammar/geoms/line.test.ts +247 -0
- package/src/grammar/geoms/line.ts +659 -0
- package/src/grammar/geoms/point.d.ts +57 -0
- package/src/grammar/geoms/point.test.ts +163 -0
- package/src/grammar/geoms/point.ts +545 -0
- package/src/grammar/geoms/polar.test.ts +216 -0
- package/src/grammar/geoms/ribbon.d.ts +21 -0
- package/src/grammar/geoms/ribbon.test.ts +170 -0
- package/src/grammar/geoms/ribbon.ts +87 -0
- package/src/grammar/geoms/ridgeline.d.ts +89 -0
- package/src/grammar/geoms/ridgeline.test.ts +247 -0
- package/src/grammar/geoms/ridgeline.ts +1164 -0
- package/src/grammar/geoms/rolling.d.ts +43 -0
- package/src/grammar/geoms/rolling.test.ts +217 -0
- package/src/grammar/geoms/rolling.ts +387 -0
- package/src/grammar/geoms/rug.d.ts +28 -0
- package/src/grammar/geoms/rug.test.ts +126 -0
- package/src/grammar/geoms/rug.ts +214 -0
- package/src/grammar/geoms/rule.d.ts +23 -0
- package/src/grammar/geoms/rule.test.ts +69 -0
- package/src/grammar/geoms/rule.ts +212 -0
- package/src/grammar/geoms/smooth.d.ts +54 -0
- package/src/grammar/geoms/smooth.test.ts +78 -0
- package/src/grammar/geoms/smooth.ts +337 -0
- package/src/grammar/geoms/text.d.ts +29 -0
- package/src/grammar/geoms/text.test.ts +64 -0
- package/src/grammar/geoms/text.ts +234 -0
- package/src/grammar/geoms/tile.d.ts +61 -0
- package/src/grammar/geoms/tile.test.ts +157 -0
- package/src/grammar/geoms/tile.ts +621 -0
- package/src/grammar/geoms/types.d.ts +319 -0
- package/src/grammar/geoms/types.ts +362 -0
- package/src/grammar/geoms/violin.d.ts +85 -0
- package/src/grammar/geoms/violin.test.ts +187 -0
- package/src/grammar/geoms/violin.ts +672 -0
- package/src/grammar/index.d.ts +22 -0
- package/src/grammar/index.ts +269 -0
- package/src/grammar/interactions/_disposable.d.ts +5 -0
- package/src/grammar/interactions/_disposable.ts +23 -0
- package/src/grammar/interactions/_z.d.ts +4 -0
- package/src/grammar/interactions/_z.ts +16 -0
- package/src/grammar/interactions/brush-selection.test.ts +262 -0
- package/src/grammar/interactions/brush.d.ts +63 -0
- package/src/grammar/interactions/brush.test.ts +483 -0
- package/src/grammar/interactions/brush.ts +452 -0
- package/src/grammar/interactions/crosshair.d.ts +19 -0
- package/src/grammar/interactions/crosshair.test.ts +127 -0
- package/src/grammar/interactions/crosshair.ts +76 -0
- package/src/grammar/interactions/hit-layer.d.ts +64 -0
- package/src/grammar/interactions/hit-layer.ts +246 -0
- package/src/grammar/interactions/legend.d.ts +19 -0
- package/src/grammar/interactions/legend.ts +101 -0
- package/src/grammar/interactions/menu.d.ts +93 -0
- package/src/grammar/interactions/menu.test.ts +373 -0
- package/src/grammar/interactions/menu.ts +342 -0
- package/src/grammar/interactions/selection.d.ts +25 -0
- package/src/grammar/interactions/selection.test.ts +289 -0
- package/src/grammar/interactions/selection.ts +142 -0
- package/src/grammar/interactions/series-readout.d.ts +91 -0
- package/src/grammar/interactions/series-readout.test.ts +668 -0
- package/src/grammar/interactions/series-readout.ts +422 -0
- package/src/grammar/interactions/series-snap.d.ts +70 -0
- package/src/grammar/interactions/series-snap.test.ts +214 -0
- package/src/grammar/interactions/series-snap.ts +218 -0
- package/src/grammar/interactions/tooltip-axis.test.ts +176 -0
- package/src/grammar/interactions/tooltip-touch.browser.test.ts +49 -0
- package/src/grammar/interactions/tooltip-touch.test.ts +161 -0
- package/src/grammar/interactions/tooltip.d.ts +140 -0
- package/src/grammar/interactions/tooltip.test.ts +406 -0
- package/src/grammar/interactions/tooltip.ts +622 -0
- package/src/grammar/interactions/transitions.d.ts +34 -0
- package/src/grammar/interactions/transitions.test.ts +172 -0
- package/src/grammar/interactions/transitions.ts +160 -0
- package/src/grammar/layout.d.ts +68 -0
- package/src/grammar/layout.ts +186 -0
- package/src/grammar/legend-merge.test.ts +332 -0
- package/src/grammar/mount.d.ts +78 -0
- package/src/grammar/mount.test.ts +479 -0
- package/src/grammar/mount.ts +2112 -0
- package/src/grammar/palettes.d.ts +54 -0
- package/src/grammar/palettes.test.ts +80 -0
- package/src/grammar/palettes.ts +167 -0
- package/src/grammar/pan-zoom.test.ts +398 -0
- package/src/grammar/phylo.d.ts +65 -0
- package/src/grammar/phylo.test.ts +59 -0
- package/src/grammar/phylo.ts +112 -0
- package/src/grammar/pipeline.auto-ticks.test.ts +40 -0
- package/src/grammar/pipeline.d.ts +158 -0
- package/src/grammar/pipeline.test.ts +463 -0
- package/src/grammar/pipeline.ts +1233 -0
- package/src/grammar/profiling.d.ts +8 -0
- package/src/grammar/profiling.ts +24 -0
- package/src/grammar/scales.d.ts +188 -0
- package/src/grammar/scales.test.ts +181 -0
- package/src/grammar/scales.ts +800 -0
- package/src/grammar/svg.d.ts +3 -0
- package/src/grammar/svg.ts +39 -0
- package/src/grammar/theme.d.ts +261 -0
- package/src/grammar/theme.test.ts +105 -0
- package/src/grammar/theme.ts +490 -0
- package/src/heatmap/cpu.ts +109 -0
- package/src/heatmap/gpu.ts +565 -0
- package/src/heatmap/types.ts +177 -0
- package/src/heatmap.browser.test.ts +308 -0
- package/src/heatmap.test.ts +320 -0
- package/src/heatmap.ts +123 -0
- package/src/index.d.ts +1 -0
- package/src/index.ts +8 -0
- package/src/interactions.d.ts +48 -0
- package/src/interactions.test.ts +226 -0
- package/src/interactions.ts +394 -0
- package/src/layout/box.d.ts +48 -0
- package/src/layout/box.test.ts +107 -0
- package/src/layout/box.ts +143 -0
- package/src/legend.d.ts +115 -0
- package/src/legend.ts +422 -0
- package/src/marks/curve.d.ts +43 -0
- package/src/marks/curve.ts +244 -0
- package/src/marks/stack.d.ts +53 -0
- package/src/marks/stack.ts +184 -0
- package/src/marks.d.ts +273 -0
- package/src/marks.test.ts +541 -0
- package/src/marks.ts +1292 -0
- package/src/navigator.test.ts +174 -0
- package/src/navigator.ts +393 -0
- package/src/range-presets.d.ts +113 -0
- package/src/range-presets.test.ts +345 -0
- package/src/range-presets.ts +349 -0
- package/src/scales.d.ts +98 -0
- package/src/scales.test.ts +103 -0
- package/src/scales.ts +695 -0
- package/src/stats/index.d.ts +200 -0
- package/src/stats/index.test.ts +349 -0
- package/src/stats/index.ts +740 -0
- package/src/stats/regression.d.ts +38 -0
- package/src/stats/regression.test.ts +56 -0
- package/src/stats/regression.ts +396 -0
- package/src/stats/rolling-window.d.ts +55 -0
- package/src/stats/rolling-window.test.ts +237 -0
- package/src/stats/rolling-window.ts +256 -0
- package/src/test-setup.ts +19 -0
- package/src/viewport/axis-state.d.ts +72 -0
- package/src/viewport/axis-state.ts +476 -0
- package/src/viewport.d.ts +170 -0
- package/src/viewport.test.ts +363 -0
- package/src/viewport.ts +510 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Grammar-level click-selection wiring
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Subscribes to the shared `GrammarHitLayer` for press events. Each press is
|
|
5
|
+
// routed through the generic `Selection<string>` primitive — plain click
|
|
6
|
+
// replaces, shift toggles, meta/ctrl removes — and a background tap clears.
|
|
7
|
+
// Selection state is exposed through `onChange(HoveredHit[])`; the mount
|
|
8
|
+
// projects this onto `MountedPlot.selected` and `CompileContext.selected`.
|
|
9
|
+
//
|
|
10
|
+
// Selection IDs are `${geomKind}:${dataIndex}:${seriesKey?}`, stable across
|
|
11
|
+
// re-renders as long as the row stays in `data` at the same index (and the
|
|
12
|
+
// same segment key for multi-series hits). When data reshuffles the stale ids
|
|
13
|
+
// drop on the next sync (their position lookup misses).
|
|
14
|
+
|
|
15
|
+
import { createSelection, type InteractionManager, type Selection } from "insomni";
|
|
16
|
+
import type { CompiledHitTest, HoveredHit } from "../geoms/types.ts";
|
|
17
|
+
import type { GrammarHitLayer, HitEventContext } from "./hit-layer.ts";
|
|
18
|
+
import { createDisposable } from "./_disposable.ts";
|
|
19
|
+
|
|
20
|
+
export interface GrammarSelectionOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Fired whenever the selection set changes. Receives a fresh array of
|
|
23
|
+
* `HoveredHit`s (one per currently-selected row) so callers can mirror it
|
|
24
|
+
* onto a public signal or run side-effects.
|
|
25
|
+
*/
|
|
26
|
+
onChange?(selected: HoveredHit[]): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface GrammarSelectionDeps {
|
|
30
|
+
manager: InteractionManager;
|
|
31
|
+
hitLayer: GrammarHitLayer;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface GrammarSelection {
|
|
35
|
+
/** Refresh id→position registry after each pipeline run. */
|
|
36
|
+
sync<T>(hits: readonly CompiledHitTest<T>[]): void;
|
|
37
|
+
/** Read-only snapshot of the current selection. */
|
|
38
|
+
current(): HoveredHit[];
|
|
39
|
+
/** Imperatively clear the selection (e.g., from outside on Escape). */
|
|
40
|
+
clear(): void;
|
|
41
|
+
dispose(): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function idFor(geomKind: string, dataIndex: number, seriesKey?: string): string {
|
|
45
|
+
return `${geomKind}:${dataIndex}:${seriesKey ?? ""}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function createGrammarSelection(
|
|
49
|
+
deps: GrammarSelectionDeps,
|
|
50
|
+
opts: GrammarSelectionOptions = {},
|
|
51
|
+
): GrammarSelection {
|
|
52
|
+
const selection: Selection<string> = createSelection<string>();
|
|
53
|
+
// Map<id, HoveredHit> — used to project Selection<string> back to the
|
|
54
|
+
// public HoveredHit[] payload. Updated on every sync so positions stay
|
|
55
|
+
// current as the chart redraws.
|
|
56
|
+
const idToHit = new Map<string, HoveredHit>();
|
|
57
|
+
|
|
58
|
+
const emit = () => {
|
|
59
|
+
const out: HoveredHit[] = [];
|
|
60
|
+
for (const id of selection.values()) {
|
|
61
|
+
const hit = idToHit.get(id);
|
|
62
|
+
if (hit) out.push(hit);
|
|
63
|
+
}
|
|
64
|
+
opts.onChange?.(out);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
selection.onChange(emit);
|
|
68
|
+
|
|
69
|
+
const unsubscribeBgTap = deps.manager.onBackgroundTap(() => {
|
|
70
|
+
selection.clear();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const unsubscribeHits = deps.hitLayer.subscribe({
|
|
74
|
+
key: "selection",
|
|
75
|
+
onPress(ctx: HitEventContext) {
|
|
76
|
+
const id = idFor(ctx.hit.geomKind, ctx.hit.dataIndex, ctx.hit.seriesKey);
|
|
77
|
+
// Refresh hit registry for this id so the projected HoveredHit has
|
|
78
|
+
// the freshest position; sync() will overwrite again next frame.
|
|
79
|
+
idToHit.set(id, ctx.hit);
|
|
80
|
+
selection.pressFromEvent(id, ctx.pointer.mods);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const refreshIdMap = <T>(hits: readonly CompiledHitTest<T>[]) => {
|
|
85
|
+
idToHit.clear();
|
|
86
|
+
for (const hit of hits) {
|
|
87
|
+
const positions = hit.positions;
|
|
88
|
+
const indices = hit.dataIndex;
|
|
89
|
+
const n = indices.length;
|
|
90
|
+
for (let i = 0; i < n; i++) {
|
|
91
|
+
const dataIdx = indices[i]!;
|
|
92
|
+
const seriesKey = hit.seriesKey?.[i];
|
|
93
|
+
const id = idFor(hit.geomKind, dataIdx, seriesKey);
|
|
94
|
+
idToHit.set(id, {
|
|
95
|
+
geomKind: hit.geomKind,
|
|
96
|
+
dataIndex: dataIdx,
|
|
97
|
+
seriesKey,
|
|
98
|
+
data: hit.data as readonly unknown[],
|
|
99
|
+
x: positions[i * 2]!,
|
|
100
|
+
y: positions[i * 2 + 1]!,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const d = createDisposable(() => {
|
|
107
|
+
unsubscribeBgTap();
|
|
108
|
+
unsubscribeHits();
|
|
109
|
+
idToHit.clear();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
sync(hits) {
|
|
114
|
+
if (d.isDisposed) return;
|
|
115
|
+
const before = selection.size;
|
|
116
|
+
refreshIdMap(hits);
|
|
117
|
+
// Drop selection ids whose row is no longer present (data array changed
|
|
118
|
+
// or index filtered out). Emit only when something actually drops.
|
|
119
|
+
const stale: string[] = [];
|
|
120
|
+
for (const id of selection.values()) {
|
|
121
|
+
if (!idToHit.has(id)) stale.push(id);
|
|
122
|
+
}
|
|
123
|
+
for (const id of stale) selection.delete(id);
|
|
124
|
+
// Emit when there was a prior selection: covers both rows dropping
|
|
125
|
+
// out (selection shrunk) and positions on still-selected rows shifting
|
|
126
|
+
// after a re-layout, so consumers always see fresh coords.
|
|
127
|
+
if (before > 0) emit();
|
|
128
|
+
},
|
|
129
|
+
current() {
|
|
130
|
+
const out: HoveredHit[] = [];
|
|
131
|
+
for (const id of selection.values()) {
|
|
132
|
+
const hit = idToHit.get(id);
|
|
133
|
+
if (hit) out.push(hit);
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
},
|
|
137
|
+
clear() {
|
|
138
|
+
selection.clear();
|
|
139
|
+
},
|
|
140
|
+
dispose: () => d.dispose(),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type Color, type Frame, type InteractionManager, type Invalidator } from "insomni";
|
|
2
|
+
import type { CompiledHitTest, ScaleBundle } from "../geoms/types.ts";
|
|
3
|
+
import type { Theme } from "../theme.ts";
|
|
4
|
+
import type { GrammarHitLayer } from "./hit-layer.ts";
|
|
5
|
+
import { collectLayerGroups, overrideGroupPick, resolveGroupKey } from "./series-snap.ts";
|
|
6
|
+
export interface SeriesReadoutRow {
|
|
7
|
+
/** Series name (color-channel value) or layer label. */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Formatted display value (raw y at the snapped x). */
|
|
10
|
+
value: string;
|
|
11
|
+
/** Series swatch color, when the layer has a color channel. */
|
|
12
|
+
color?: Color;
|
|
13
|
+
/** True for the row whose snapped position is closest to the cursor. */
|
|
14
|
+
active: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SeriesReadoutSnapshot {
|
|
17
|
+
/** Formatted snapped x (from the closest layer). */
|
|
18
|
+
x: string;
|
|
19
|
+
/** Raw snapped x value (column-typed). Useful for custom formatting. */
|
|
20
|
+
xValue: unknown;
|
|
21
|
+
/** One row per series across all layers, in original layer + series order. */
|
|
22
|
+
rows: readonly SeriesReadoutRow[];
|
|
23
|
+
}
|
|
24
|
+
export type SeriesReadoutFormat = {
|
|
25
|
+
/** Format the snapped x for the panel title. Default: `defaultFormat`. */
|
|
26
|
+
x?: (value: unknown) => string;
|
|
27
|
+
/** Format each per-series y value. Default: `defaultFormat`. */
|
|
28
|
+
y?: (value: unknown) => string;
|
|
29
|
+
};
|
|
30
|
+
export type SeriesReadoutPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
31
|
+
export interface SeriesReadoutUi {
|
|
32
|
+
/** Element to append the panel into (typically the chart's stage). */
|
|
33
|
+
mount: HTMLElement;
|
|
34
|
+
/** Corner inside `mount`. Default `"top-right"`. */
|
|
35
|
+
position?: SeriesReadoutPosition;
|
|
36
|
+
/** Inset (px) from the chosen corner. Default `12`. */
|
|
37
|
+
inset?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface AttachSeriesReadoutOptions {
|
|
40
|
+
/** DOM mount info. Omit to run headless and observe via `subscribe`. */
|
|
41
|
+
ui?: SeriesReadoutUi;
|
|
42
|
+
/**
|
|
43
|
+
* How to pick a hit per series.
|
|
44
|
+
* - `"nearest-x"` (default): the hit with smallest |x − cursorX|. Best for
|
|
45
|
+
* time-series readouts; one row per series at the cursor's x.
|
|
46
|
+
* - `"hover"`: only show rows while the cursor is over a real hit (the
|
|
47
|
+
* tooltip-style behavior, but extended to every series in the chart).
|
|
48
|
+
*/
|
|
49
|
+
snap?: "nearest-x" | "hover";
|
|
50
|
+
/** Per-channel formatters. */
|
|
51
|
+
format?: SeriesReadoutFormat;
|
|
52
|
+
/** Hide when the cursor leaves the plot frame. Default `true`. */
|
|
53
|
+
hideOnLeave?: boolean;
|
|
54
|
+
/** Notified whenever the snapshot changes (incl. with `ui` attached). */
|
|
55
|
+
onChange?(snapshot: SeriesReadoutSnapshot | null): void;
|
|
56
|
+
}
|
|
57
|
+
export interface AttachedSeriesReadout {
|
|
58
|
+
peek(): SeriesReadoutSnapshot | null;
|
|
59
|
+
subscribe(fn: (snapshot: SeriesReadoutSnapshot | null) => void): () => void;
|
|
60
|
+
dispose(): void;
|
|
61
|
+
}
|
|
62
|
+
export interface SeriesReadoutDeps {
|
|
63
|
+
manager: InteractionManager;
|
|
64
|
+
/** Plot-frame bounds (absolute element-CSS px). */
|
|
65
|
+
bounds: () => Frame;
|
|
66
|
+
/** Latest resolved scales (for color swatches). */
|
|
67
|
+
scales: () => ScaleBundle | null;
|
|
68
|
+
theme: () => Theme;
|
|
69
|
+
invalidator: Invalidator;
|
|
70
|
+
/**
|
|
71
|
+
* Optional shared hit-layer. When provided, the readout also subscribes to
|
|
72
|
+
* its hover events so the panel stays populated while the cursor is over a
|
|
73
|
+
* real mark (where high-z hit-cloud nodes claim hover and the readout's own
|
|
74
|
+
* low-z pointer node never fires).
|
|
75
|
+
*/
|
|
76
|
+
hitLayer?: GrammarHitLayer;
|
|
77
|
+
}
|
|
78
|
+
/** Internal handle used by the mount to push fresh hit-tests in. */
|
|
79
|
+
export interface SeriesReadoutInternal extends AttachedSeriesReadout {
|
|
80
|
+
syncHits<T>(hits: readonly CompiledHitTest<T>[]): void;
|
|
81
|
+
}
|
|
82
|
+
export declare function createSeriesReadout(deps: SeriesReadoutDeps, opts: AttachSeriesReadoutOptions): SeriesReadoutInternal;
|
|
83
|
+
declare function snapshotEqual(a: SeriesReadoutSnapshot | null, b: SeriesReadoutSnapshot | null): boolean;
|
|
84
|
+
/** @internal — exposed for unit tests only. */
|
|
85
|
+
export declare const __test__: {
|
|
86
|
+
collectLayerGroups: typeof collectLayerGroups;
|
|
87
|
+
resolveGroupKey: typeof resolveGroupKey;
|
|
88
|
+
overrideGroupPick: typeof overrideGroupPick;
|
|
89
|
+
snapshotEqual: typeof snapshotEqual;
|
|
90
|
+
};
|
|
91
|
+
export {};
|