@opendata-ai/openchart-vanilla 8.0.0-rc.2 → 8.0.0-rc.21
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/dist/{chunk-W34KN7FD.js → chunk-2NAQRP66.js} +2 -2
- package/dist/chunk-DCODCLWI.js +234 -0
- package/dist/chunk-DCODCLWI.js.map +1 -0
- package/dist/{chunk-5EOV5JQZ.js → chunk-EKAUQAAX.js} +50 -46
- package/dist/chunk-EKAUQAAX.js.map +1 -0
- package/dist/{chunk-ENXSUXC5.js → chunk-KNT5AZ2O.js} +7309 -5490
- package/dist/chunk-KNT5AZ2O.js.map +1 -0
- package/dist/chunk-RM5XS6NR.js +113 -0
- package/dist/chunk-RM5XS6NR.js.map +1 -0
- package/dist/chunk-T32UHMZA.js +282 -0
- package/dist/chunk-T32UHMZA.js.map +1 -0
- package/dist/export-gif.d.ts +113 -0
- package/dist/export-gif.js +21 -0
- package/dist/export-gif.js.map +1 -0
- package/dist/index.d.ts +283 -24
- package/dist/index.js +2012 -763
- package/dist/index.js.map +1 -1
- package/dist/{mount-CUKQLeqD.d.ts → mount-Dvv8NYIv.d.ts} +117 -3
- package/dist/simulation-worker.js +83 -2
- package/dist/static.js +7 -69
- package/dist/static.js.map +1 -1
- package/dist/story/index.d.ts +3 -2
- package/dist/story/index.js +5 -3
- package/dist/story/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +14 -6
- package/dist/chunk-5EOV5JQZ.js.map +0 -1
- package/dist/chunk-ENXSUXC5.js.map +0 -1
- package/src/__test-fixtures__/dom.ts +0 -70
- package/src/__test-fixtures__/specs.ts +0 -214
- package/src/__tests__/animation.test.ts +0 -358
- package/src/__tests__/annotations-render.test.ts +0 -201
- package/src/__tests__/compound-labels.test.ts +0 -122
- package/src/__tests__/continuous-legend.test.ts +0 -91
- package/src/__tests__/crosshair.test.ts +0 -130
- package/src/__tests__/edit-events.test.ts +0 -902
- package/src/__tests__/events.test.ts +0 -387
- package/src/__tests__/export.test.ts +0 -241
- package/src/__tests__/font-race.test.ts +0 -199
- package/src/__tests__/gradient-ids.test.ts +0 -159
- package/src/__tests__/gradient-utils.test.ts +0 -125
- package/src/__tests__/known-bugs-render.test.ts +0 -183
- package/src/__tests__/map.test.ts +0 -293
- package/src/__tests__/mount.test.ts +0 -357
- package/src/__tests__/pattern-fills.test.ts +0 -105
- package/src/__tests__/resize-timing.test.ts +0 -218
- package/src/__tests__/sankey.test.ts +0 -133
- package/src/__tests__/selection-events.test.ts +0 -869
- package/src/__tests__/series-search.test.ts +0 -311
- package/src/__tests__/static.test.ts +0 -141
- package/src/__tests__/svg-renderer.test.ts +0 -895
- package/src/__tests__/table-keyboard.test.ts +0 -361
- package/src/__tests__/table-mount.test.ts +0 -639
- package/src/__tests__/tilemap.test.ts +0 -158
- package/src/__tests__/tooltip.test.ts +0 -337
- package/src/__tests__/transition.test.ts +0 -1777
- package/src/__tests__/you-draw-it.test.ts +0 -273
- package/src/animation-vars.ts +0 -42
- package/src/animation.ts +0 -76
- package/src/barlist-mount.ts +0 -383
- package/src/barlist-renderer.ts +0 -267
- package/src/dom-helpers.ts +0 -17
- package/src/export.ts +0 -482
- package/src/gradient-utils.ts +0 -138
- package/src/graph/__tests__/canvas-renderer.test.ts +0 -713
- package/src/graph/__tests__/graph-mount.test.ts +0 -213
- package/src/graph/__tests__/interaction.test.ts +0 -205
- package/src/graph/__tests__/keyboard.test.ts +0 -653
- package/src/graph/__tests__/search.test.ts +0 -88
- package/src/graph/__tests__/simulation.test.ts +0 -233
- package/src/graph/__tests__/spatial-index.test.ts +0 -142
- package/src/graph/__tests__/zoom.test.ts +0 -203
- package/src/graph/canvas-renderer.ts +0 -747
- package/src/graph/interaction.ts +0 -367
- package/src/graph/keyboard.ts +0 -208
- package/src/graph/search.ts +0 -50
- package/src/graph/simulation-worker-url.ts +0 -12
- package/src/graph/simulation-worker.ts +0 -278
- package/src/graph/simulation.ts +0 -422
- package/src/graph/spatial-index.ts +0 -121
- package/src/graph/types.ts +0 -47
- package/src/graph/worker-protocol.ts +0 -70
- package/src/graph/zoom.ts +0 -134
- package/src/graph-mount.ts +0 -888
- package/src/index.ts +0 -76
- package/src/interactions/chart-events.ts +0 -139
- package/src/interactions/crosshair.ts +0 -233
- package/src/interactions/drag-handler.ts +0 -175
- package/src/interactions/editing-drags.ts +0 -515
- package/src/interactions/index.ts +0 -25
- package/src/interactions/keyboard-nav.ts +0 -111
- package/src/interactions/legend-interaction.ts +0 -46
- package/src/interactions/selection.ts +0 -280
- package/src/interactions/tooltip-events.ts +0 -72
- package/src/map-camera.ts +0 -88
- package/src/map-mount.ts +0 -701
- package/src/map-renderer.ts +0 -338
- package/src/map-transition.ts +0 -83
- package/src/measure-text.ts +0 -134
- package/src/mount.ts +0 -1382
- package/src/pattern-utils.ts +0 -110
- package/src/renderers/annotations.ts +0 -388
- package/src/renderers/axes.ts +0 -351
- package/src/renderers/brand.ts +0 -87
- package/src/renderers/chrome.ts +0 -196
- package/src/renderers/endpoint-labels.ts +0 -150
- package/src/renderers/legend.ts +0 -311
- package/src/renderers/marks.ts +0 -561
- package/src/renderers/metrics.ts +0 -63
- package/src/renderers/svg-dom.ts +0 -40
- package/src/renderers/table-cells.ts +0 -446
- package/src/resize-observer.ts +0 -46
- package/src/sankey-mount.ts +0 -622
- package/src/sankey-renderer.ts +0 -614
- package/src/series-search.ts +0 -392
- package/src/static.ts +0 -251
- package/src/story/__tests__/camera-math.test.ts +0 -145
- package/src/story/__tests__/create-chart-story.test.ts +0 -317
- package/src/story/__tests__/progress-math.test.ts +0 -95
- package/src/story/__tests__/scroll-driver.test.ts +0 -130
- package/src/story/__tests__/tween.test.ts +0 -159
- package/src/story/camera-math.ts +0 -125
- package/src/story/create-chart-story.ts +0 -353
- package/src/story/crossfade.ts +0 -70
- package/src/story/index.ts +0 -39
- package/src/story/progress-math.ts +0 -85
- package/src/story/resolve-camera-target.ts +0 -119
- package/src/story/scroll-driver.ts +0 -206
- package/src/story/story-camera.ts +0 -49
- package/src/story/tween.ts +0 -112
- package/src/story/types.ts +0 -76
- package/src/svg-ids.ts +0 -23
- package/src/svg-renderer.ts +0 -383
- package/src/table-keyboard.ts +0 -266
- package/src/table-mount.ts +0 -567
- package/src/table-renderer.ts +0 -414
- package/src/text-edit-overlay.ts +0 -255
- package/src/theme-tokens.ts +0 -51
- package/src/tilemap-mount.ts +0 -511
- package/src/tilemap-renderer.ts +0 -396
- package/src/tooltip.ts +0 -177
- package/src/transition.ts +0 -2816
- package/src/you-draw-it.ts +0 -480
- /package/dist/{chunk-W34KN7FD.js.map → chunk-2NAQRP66.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { ChartLayout, ChartSpec, CompileOptions, TableLayout, TableSpec, VizSpec } from '@opendata-ai/openchart-engine';
|
|
2
|
-
import { BarListSpec, BarListLayout, ThemeConfig, DarkMode, GraphSpec, MapSpec, MapLayout, RectMark, Mark, BarTableCell, CategoryTableCell, TableCell, FlagTableCell, HeatmapTableCell, ImageTableCell, SparklineTableCell, TextTableCell, SankeySpec, SankeyLayout,
|
|
3
|
-
import { J as JPGExportOptions, S as SVGExportOptions, C as Camera } from './mount-
|
|
4
|
-
export { a as ChartInstance, E as ExportOptions, M as MountOptions, P as PNGExportOptions, U as UpdateOptions, c as createChart, e as exportCSV,
|
|
2
|
+
import { BarListSpec, BarListLayout, ThemeConfig, DarkMode, ChartLayout, ChartSpec, LayerSpec, AnimationEase, GraphSpec, TooltipContent, MapSpec, MapLayout, RectMark, Mark, BarTableCell, CategoryTableCell, TableCell, FlagTableCell, HeatmapTableCell, ImageTableCell, SparklineTableCell, TextTableCell, SankeySpec, SankeyLayout, TableSpec, SortState, TableLayout, TileMapSpec, TileMapLayout, ResolvedYouDrawIt } from '@opendata-ai/openchart-core';
|
|
3
|
+
import { J as JPGExportOptions, S as SVGExportOptions, C as Camera } from './mount-Dvv8NYIv.js';
|
|
4
|
+
export { a as CANVAS_DEFAULT_UPDATE_MAX_MARKS, b as ChartInstance, D as DEFAULT_UPDATE_MAX_MARKS, E as ExportOptions, M as MountOptions, P as PNGExportOptions, U as UpdateOptions, c as createChart, e as exportCSV, d as exportJPG, f as exportPNG, g as exportSVG, h as exportSVGWithFonts } from './mount-Dvv8NYIv.js';
|
|
5
5
|
import { Placement } from '@floating-ui/dom';
|
|
6
|
+
import './export-gif.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* BarList mount API: the main entry point for vanilla JS barlist usage.
|
|
@@ -38,6 +39,137 @@ interface BarListInstance {
|
|
|
38
39
|
}
|
|
39
40
|
declare function createBarList(container: HTMLElement, spec: BarListSpec, options?: BarListMountOptions): BarListInstance;
|
|
40
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Exports for charts rendered in canvas mark mode.
|
|
44
|
+
*
|
|
45
|
+
* On screen, canvas mode splits the figure across two surfaces: a `<canvas>`
|
|
46
|
+
* painting background, gridlines and dots, and an SVG carrying axes, trendline,
|
|
47
|
+
* annotations and chrome. Serializing the SVG alone would export a chart with
|
|
48
|
+
* no data in it, so every format has to re-materialize the missing half.
|
|
49
|
+
*
|
|
50
|
+
* Two strategies, chosen by point count:
|
|
51
|
+
*
|
|
52
|
+
* - **Vector** (at or below `VECTOR_EXPORT_MAX_POINTS`): re-render the layout
|
|
53
|
+
* as if canvas mode had never been asked for. `renderChartSVG` keys ONLY on
|
|
54
|
+
* `opts.canvasMarks`, never on `layout.markRenderMode`, so simply omitting
|
|
55
|
+
* the option yields a full-fidelity SVG by construction -- true gradients,
|
|
56
|
+
* vector gridlines, real background rect, one `<circle>` per dot. Pixel-
|
|
57
|
+
* identical to what an SVG-mode chart of the same spec exports.
|
|
58
|
+
*
|
|
59
|
+
* - **Raster marks** (above it): keep the SVG vector for everything except the
|
|
60
|
+
* dots, and inline one canvas pass of the marks as an `<image>`. 50,000
|
|
61
|
+
* `<circle>` elements is not a file anyone wants; the gridlines, axes and
|
|
62
|
+
* text stay crisp and only the dot cloud rasterizes.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Point count above which SVG/PNG export inlines the marks as a raster
|
|
67
|
+
* `<image>` instead of emitting one `<circle>` each.
|
|
68
|
+
*
|
|
69
|
+
* A judgment cap. Below it the per-element cost is worth full vector fidelity;
|
|
70
|
+
* above it the file size and the consuming editor's patience are not.
|
|
71
|
+
*/
|
|
72
|
+
declare const VECTOR_EXPORT_MAX_POINTS = 5000;
|
|
73
|
+
/**
|
|
74
|
+
* Materialize a canvas-mode layout into a single self-contained SVG element.
|
|
75
|
+
*
|
|
76
|
+
* This is what every export format consumes: SVG serializes it directly, and
|
|
77
|
+
* PNG/JPG/GIF rasterize it. Raster formats always take the vector path
|
|
78
|
+
* regardless of point count -- they are becoming pixels anyway, so the one-shot
|
|
79
|
+
* cost of the full SVG buys pixel-parity with SVG mode for free.
|
|
80
|
+
*
|
|
81
|
+
* This is also why the GIF path needs no canvas compositing. Handing the
|
|
82
|
+
* encoder a complete SVG means the existing frame pipeline works unchanged: no
|
|
83
|
+
* per-frame `drawImage` of the live mark canvas, no background sourced from a
|
|
84
|
+
* suppressed rect, no second code path to keep in sync with the first.
|
|
85
|
+
*/
|
|
86
|
+
declare function materializeCanvasModeSVG(layout: ChartLayout, opts?: {
|
|
87
|
+
forceVector?: boolean;
|
|
88
|
+
}): SVGElement;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Multi-spec ("keyframe") GIF export.
|
|
92
|
+
*
|
|
93
|
+
* The single-chart GIF export (`exportGIF`) reproduces ONE chart's entrance
|
|
94
|
+
* animation. Some charts animate a different way: a component swaps in a whole
|
|
95
|
+
* new spec on a timer (e.g. a year-by-year stepper), and the on-screen chart
|
|
96
|
+
* tweens between them via `chart.update()` (bars grow/shrink smoothly). The DATA
|
|
97
|
+
* changes across frames, and the motion is the update transition — neither of
|
|
98
|
+
* which `exportGIF` can express.
|
|
99
|
+
*
|
|
100
|
+
* `exportSpecSequence` reproduces that. It mounts one offscreen chart, holds the
|
|
101
|
+
* first spec, then walks the rest by driving `chart.beginManualUpdate(spec)` and
|
|
102
|
+
* stepping the returned transition frame-by-frame (no rAF clock), rasterizing
|
|
103
|
+
* each step. Between transitions it holds the settled frame for `dwellMs`. The
|
|
104
|
+
* result is the same bar tween the reader sees on screen, captured to GIF.
|
|
105
|
+
*
|
|
106
|
+
* `gifenc` is an optional peer dependency, loaded dynamically.
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
interface SpecSequenceOptions {
|
|
110
|
+
/** DPI scaling factor, matching PNG export. Defaults to 2. */
|
|
111
|
+
dpi?: number;
|
|
112
|
+
/** Frames per second for the tween between specs. Defaults to 25. */
|
|
113
|
+
fps?: number;
|
|
114
|
+
/** How long to hold each spec's settled frame, in ms. Defaults to 1200 (the common stepper cadence). */
|
|
115
|
+
dwellMs?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Loop behavior, same semantics as `exportGIF`:
|
|
118
|
+
* - `false` / omitted: play once, then hold the final frame
|
|
119
|
+
* - `true`: loop forever
|
|
120
|
+
* - a number: loop that many times, then hold
|
|
121
|
+
*/
|
|
122
|
+
loop?: boolean | number;
|
|
123
|
+
/** Render width in CSS px. Required — pass the on-screen chart width so the export matches. */
|
|
124
|
+
width: number;
|
|
125
|
+
/** Render height in CSS px. Required — pass the on-screen chart height so the export matches. */
|
|
126
|
+
height: number;
|
|
127
|
+
/** Dark mode for the rendered charts. Defaults to 'off' (light). */
|
|
128
|
+
darkMode?: 'auto' | 'force' | 'off';
|
|
129
|
+
/**
|
|
130
|
+
* Theme overrides applied when rendering, exactly as a consumer's live wrapper
|
|
131
|
+
* would apply them. Pass the SAME theme your on-screen chart uses (e.g. the
|
|
132
|
+
* blog's `blogChartTheme(isDark)`), or the export won't match — its background,
|
|
133
|
+
* gridlines, and chrome colors fall back to openchart's raw defaults.
|
|
134
|
+
*/
|
|
135
|
+
theme?: ThemeConfig;
|
|
136
|
+
/** Embed fonts as base64 so text matches on-screen. Defaults to true. */
|
|
137
|
+
embedFonts?: boolean;
|
|
138
|
+
/** Opaque background fill. Defaults to the chart's own background (white if transparent). */
|
|
139
|
+
backgroundColor?: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Render an ordered list of specs to an animated GIF Blob. Holds the first spec,
|
|
143
|
+
* then tweens to each subsequent spec (openchart's update transition, driven
|
|
144
|
+
* frame-by-frame) and holds it — reproducing the on-screen bar grow/shrink.
|
|
145
|
+
*
|
|
146
|
+
* @param specs - Ordered specs, one per keyframe (e.g. one per year).
|
|
147
|
+
* @param options - dpi, fps, dwell, loop, size (required), dark mode, theme, fonts.
|
|
148
|
+
* @returns A Promise resolving to the GIF Blob.
|
|
149
|
+
*/
|
|
150
|
+
declare function exportSpecSequence(specs: Array<ChartSpec | LayerSpec>, options: SpecSequenceOptions): Promise<Blob>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Animated camera for the graph.
|
|
154
|
+
*
|
|
155
|
+
* Flights interpolate between two `ZoomTransform`s along d3's geodesic
|
|
156
|
+
* `interpolateZoom` path (smooth zoom-and-pan that pulls back to see both
|
|
157
|
+
* endpoints before diving in). A flight is a {@link GraphAnimation}, driven by
|
|
158
|
+
* the mount's AnimationScheduler.
|
|
159
|
+
*
|
|
160
|
+
* `interpolateZoom` operates on a `[cx, cy, width]` "view" — the graph-space
|
|
161
|
+
* center and the graph-space width visible across the viewport. We convert the
|
|
162
|
+
* ZoomTransform ⇄ view around a fixed viewport size.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
/** Options controlling a camera flight. */
|
|
166
|
+
interface CameraFlightOptions {
|
|
167
|
+
/** Duration in ms, or `'auto'` to derive from the zoom distance. */
|
|
168
|
+
duration?: number | 'auto';
|
|
169
|
+
/** Easing preset. Default `'smooth'`. */
|
|
170
|
+
ease?: AnimationEase;
|
|
171
|
+
}
|
|
172
|
+
|
|
41
173
|
/**
|
|
42
174
|
* Creates a Web Worker running the force simulation.
|
|
43
175
|
*
|
|
@@ -58,21 +190,99 @@ declare function createSimulationWorker(): Worker;
|
|
|
58
190
|
* simulation ticks. Returns a GraphInstance with update/search/zoom/destroy.
|
|
59
191
|
*/
|
|
60
192
|
|
|
193
|
+
/**
|
|
194
|
+
* A programmatic highlight target. Resolved once at call time into a node id set
|
|
195
|
+
* and rendered through the focus model (eased crossfade). See {@link GraphInstance.highlight}.
|
|
196
|
+
*/
|
|
197
|
+
type GraphHighlightTarget = {
|
|
198
|
+
nodeIds: string[];
|
|
199
|
+
} | {
|
|
200
|
+
category: {
|
|
201
|
+
field: string;
|
|
202
|
+
value: string | string[];
|
|
203
|
+
};
|
|
204
|
+
} | {
|
|
205
|
+
neighborsOf: string;
|
|
206
|
+
includeSelf?: boolean;
|
|
207
|
+
};
|
|
208
|
+
/** A hovered node or edge, passed to a tooltip formatter. */
|
|
209
|
+
interface GraphTooltipItem {
|
|
210
|
+
kind: 'node' | 'edge';
|
|
211
|
+
/** The raw datum (node record, or edge record with source/target). */
|
|
212
|
+
data: Record<string, unknown>;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Custom tooltip content builder. Receives the hovered item and the library's
|
|
216
|
+
* default {@link TooltipContent}, returns replacement content.
|
|
217
|
+
*
|
|
218
|
+
* Safety contract:
|
|
219
|
+
* - A returned `TooltipContent` or `string` is escaped by the library (strings
|
|
220
|
+
* are inserted via `textContent`, never `innerHTML`).
|
|
221
|
+
* - A returned `HTMLElement` is trusted verbatim — the host owns sanitization.
|
|
222
|
+
* - `null` suppresses the tooltip for that item.
|
|
223
|
+
*/
|
|
224
|
+
type GraphTooltipFormatter = (item: GraphTooltipItem, defaults: TooltipContent) => TooltipContent | string | HTMLElement | null;
|
|
225
|
+
/** Built-in legend data (headless mirror of the rendered legend). */
|
|
226
|
+
interface GraphLegendData {
|
|
227
|
+
field: string | null;
|
|
228
|
+
nodes: Array<{
|
|
229
|
+
label: string;
|
|
230
|
+
color: string;
|
|
231
|
+
count?: number;
|
|
232
|
+
active: boolean;
|
|
233
|
+
}>;
|
|
234
|
+
edges: Array<{
|
|
235
|
+
label: string;
|
|
236
|
+
color: string;
|
|
237
|
+
count?: number;
|
|
238
|
+
}>;
|
|
239
|
+
}
|
|
61
240
|
interface GraphMountOptions {
|
|
62
241
|
theme?: ThemeConfig;
|
|
63
242
|
darkMode?: DarkMode;
|
|
64
243
|
responsive?: boolean;
|
|
65
244
|
/** Show the tryOpenData.ai watermark. Defaults to true. */
|
|
66
245
|
watermark?: boolean;
|
|
67
|
-
/** Show the built-in tooltip
|
|
68
|
-
tooltip?: boolean
|
|
69
|
-
|
|
70
|
-
|
|
246
|
+
/** Show the built-in tooltip; pass an object for a custom formatter. Defaults to true. */
|
|
247
|
+
tooltip?: boolean | {
|
|
248
|
+
formatter?: GraphTooltipFormatter;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Built-in legend. `true` (default) renders an interactive legend with counts.
|
|
252
|
+
* `false` renders none (set this if you render your own legend). An object
|
|
253
|
+
* toggles interactivity/counts.
|
|
254
|
+
*/
|
|
255
|
+
legend?: boolean | {
|
|
256
|
+
interactive?: boolean;
|
|
257
|
+
counts?: boolean;
|
|
258
|
+
};
|
|
71
259
|
onNodeClick?: (node: Record<string, unknown>) => void;
|
|
72
260
|
onNodeDoubleClick?: (node: Record<string, unknown>) => void;
|
|
73
261
|
onNodeHover?: (node: Record<string, unknown> | null) => void;
|
|
74
262
|
onEdgeHover?: (edge: Record<string, unknown> | null) => void;
|
|
75
263
|
onSelectionChange?: (nodeIds: string[]) => void;
|
|
264
|
+
/** Fired when the user hovers a legend entry (null on leave). */
|
|
265
|
+
onLegendHover?: (entry: {
|
|
266
|
+
field: string;
|
|
267
|
+
value: string;
|
|
268
|
+
} | null) => void;
|
|
269
|
+
/** Fired when legend toggle state changes; `activeValues` is the active category set (empty = all). */
|
|
270
|
+
onLegendToggle?: (activeValues: string[]) => void;
|
|
271
|
+
/** Fired whenever the highlight set changes (programmatic or legend), null when cleared. */
|
|
272
|
+
onHighlightChange?: (nodeIds: string[] | null) => void;
|
|
273
|
+
/**
|
|
274
|
+
* Fit the graph to the viewport on the first tick. Default true. Set false to
|
|
275
|
+
* restore a saved camera (e.g. getCamera() + flyTo) without the initial fit.
|
|
276
|
+
*/
|
|
277
|
+
fitOnLoad?: boolean;
|
|
278
|
+
/** Camera change callback, rAF-coalesced (fires at most once per rendered frame). */
|
|
279
|
+
onCameraChange?: (camera: {
|
|
280
|
+
x: number;
|
|
281
|
+
y: number;
|
|
282
|
+
k: number;
|
|
283
|
+
}) => void;
|
|
284
|
+
/** Skip the entrance reveal/flight on mount (spec unchanged; used by wrappers when recreating for a theme/darkMode-only change so the entrance doesn't replay). Warmup still runs. */
|
|
285
|
+
suppressEntrance?: boolean;
|
|
76
286
|
}
|
|
77
287
|
interface GraphInstance {
|
|
78
288
|
update(spec: GraphSpec): void;
|
|
@@ -80,10 +290,49 @@ interface GraphInstance {
|
|
|
80
290
|
updateVisuals(spec: GraphSpec): void;
|
|
81
291
|
search(query: string): void;
|
|
82
292
|
clearSearch(): void;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
293
|
+
/** Fit all nodes into the viewport. Animated by default; `{ duration: 0 }` snaps. */
|
|
294
|
+
zoomToFit(opts?: CameraFlightOptions & {
|
|
295
|
+
padding?: number;
|
|
296
|
+
}): void;
|
|
297
|
+
/** Fly to a node and zoom in (default scale 2). Tracks the node while it settles. */
|
|
298
|
+
zoomToNode(nodeId: string, opts?: CameraFlightOptions & {
|
|
299
|
+
scale?: number;
|
|
300
|
+
}): void;
|
|
301
|
+
/** Fly the camera to a graph-space target. */
|
|
302
|
+
flyTo(target: {
|
|
303
|
+
x: number;
|
|
304
|
+
y: number;
|
|
305
|
+
k?: number;
|
|
306
|
+
}, opts?: CameraFlightOptions): void;
|
|
307
|
+
/** Center the camera on a graph-space point (keeps current zoom). */
|
|
308
|
+
centerAt(x: number, y: number, opts?: CameraFlightOptions): void;
|
|
309
|
+
/** Current camera (graph-space center-ish transform components). */
|
|
310
|
+
getCamera(): {
|
|
311
|
+
x: number;
|
|
312
|
+
y: number;
|
|
313
|
+
k: number;
|
|
314
|
+
};
|
|
315
|
+
/** Select a node; `{ fly: true }` also flies to it (default follows interaction.select.flyTo). */
|
|
316
|
+
selectNode(nodeId: string, opts?: {
|
|
317
|
+
fly?: boolean;
|
|
318
|
+
} & CameraFlightOptions): void;
|
|
86
319
|
getSelectedNodes(): string[];
|
|
320
|
+
/** Node ids currently matching the active search query. */
|
|
321
|
+
getSearchMatches(): string[];
|
|
322
|
+
/** Emphasize a set of nodes; eased via the focus model. Resets legend toggles. */
|
|
323
|
+
highlight(target: GraphHighlightTarget, opts?: {
|
|
324
|
+
dimOpacity?: number;
|
|
325
|
+
}): void;
|
|
326
|
+
/** Clear any programmatic highlight (and legend toggles). */
|
|
327
|
+
clearHighlight(): void;
|
|
328
|
+
/** The currently highlighted node ids, or null when nothing is highlighted. */
|
|
329
|
+
getHighlight(): string[] | null;
|
|
330
|
+
/** Headless snapshot of the legend (node categories + edge categories). */
|
|
331
|
+
getLegend(): GraphLegendData;
|
|
332
|
+
/** Set the active category filter declaratively (replaces legend toggle state). */
|
|
333
|
+
setActiveCategories(values: string[]): void;
|
|
334
|
+
/** Current active category values (empty = all active, no filter). */
|
|
335
|
+
getActiveCategories(): string[];
|
|
87
336
|
resize(): void;
|
|
88
337
|
destroy(): void;
|
|
89
338
|
}
|
|
@@ -120,6 +369,12 @@ interface MapCameraOptions {
|
|
|
120
369
|
* and returns a MapInstance with update/resize/export/destroy.
|
|
121
370
|
*/
|
|
122
371
|
|
|
372
|
+
type MapMarkEvent = {
|
|
373
|
+
kind: 'feature' | 'point';
|
|
374
|
+
id: string | number;
|
|
375
|
+
name?: string;
|
|
376
|
+
data: Record<string, unknown> | null;
|
|
377
|
+
};
|
|
123
378
|
interface MapMountOptions {
|
|
124
379
|
/** Theme overrides. */
|
|
125
380
|
theme?: ThemeConfig;
|
|
@@ -131,18 +386,10 @@ interface MapMountOptions {
|
|
|
131
386
|
watermark?: boolean;
|
|
132
387
|
/** Show tooltips on hover. Defaults to true. */
|
|
133
388
|
tooltip?: boolean;
|
|
134
|
-
/** Callback when a feature is clicked. */
|
|
135
|
-
onMarkClick?: (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
data: Record<string, unknown> | null;
|
|
139
|
-
}) => void;
|
|
140
|
-
/** Callback when a feature is hovered (null on mouse leave). */
|
|
141
|
-
onMarkHover?: (feature: {
|
|
142
|
-
id: string | number;
|
|
143
|
-
name?: string;
|
|
144
|
-
data: Record<string, unknown> | null;
|
|
145
|
-
} | null) => void;
|
|
389
|
+
/** Callback when a feature or point is clicked. */
|
|
390
|
+
onMarkClick?: (event: MapMarkEvent) => void;
|
|
391
|
+
/** Callback when a feature or point is hovered (null on mouse leave). */
|
|
392
|
+
onMarkHover?: (event: MapMarkEvent | null) => void;
|
|
146
393
|
}
|
|
147
394
|
interface MapInstance {
|
|
148
395
|
/** Re-compile and re-render with a new spec. */
|
|
@@ -309,6 +556,7 @@ declare function createSankey(container: HTMLElement, spec: SankeySpec, options?
|
|
|
309
556
|
declare function renderChartSVG(layout: ChartLayout, container: HTMLElement, opts?: {
|
|
310
557
|
animate?: boolean;
|
|
311
558
|
crosshair?: boolean;
|
|
559
|
+
canvasMarks?: boolean;
|
|
312
560
|
}): SVGElement;
|
|
313
561
|
|
|
314
562
|
/**
|
|
@@ -501,9 +749,20 @@ interface TooltipShowOptions {
|
|
|
501
749
|
*/
|
|
502
750
|
placement?: Placement;
|
|
503
751
|
}
|
|
752
|
+
/**
|
|
753
|
+
* Content accepted by {@link TooltipManager.show}. A structured
|
|
754
|
+
* {@link TooltipContent} is rendered by the manager; `{ text }` is inserted as
|
|
755
|
+
* plain text (escaped via textContent); `{ element }` is a caller-owned node
|
|
756
|
+
* trusted verbatim (the host owns sanitization).
|
|
757
|
+
*/
|
|
758
|
+
type TooltipInput = TooltipContent | {
|
|
759
|
+
text: string;
|
|
760
|
+
} | {
|
|
761
|
+
element: HTMLElement;
|
|
762
|
+
};
|
|
504
763
|
interface TooltipManager {
|
|
505
764
|
/** Show the tooltip with content at a given position. */
|
|
506
|
-
show(content:
|
|
765
|
+
show(content: TooltipInput, x: number, y: number, opts?: TooltipShowOptions): void;
|
|
507
766
|
/** Hide the tooltip. */
|
|
508
767
|
hide(): void;
|
|
509
768
|
/** Remove the tooltip element and clean up event listeners. */
|
|
@@ -567,4 +826,4 @@ interface YouDrawItController {
|
|
|
567
826
|
*/
|
|
568
827
|
declare function createYouDrawIt(options: YouDrawItOptions): YouDrawItController;
|
|
569
828
|
|
|
570
|
-
export { type BarListInstance, type BarListMountOptions, Camera, type GraphInstance, type GraphMountOptions, JPGExportOptions, type KeyboardNavOptions, type MapCameraOptions, type MapInstance, type MapMountOptions, SVGExportOptions, type SankeyInstance, type SankeyMountOptions, type TableInstance, type TableMountOptions, type TableState, type TextEditOverlayConfig, type TileMapInstance, type TileMapMountOptions, type TooltipManager, type YouDrawItController, type YouDrawItOptions, attachKeyboardNav, createBarList, createGraph, createMap, createSankey, createSimulationWorker, createTable, createTextEditOverlay, createTileMap, createTooltipManager, createYouDrawIt, observeResize, rectPathWithCorners, registerMarkRenderer, renderBarCell, renderCategoryCell, renderCell, renderChartSVG, renderFlagCell, renderHeatmapCell, renderImageCell, renderSparklineCell, renderTable, renderTextCell };
|
|
829
|
+
export { type BarListInstance, type BarListMountOptions, Camera, type CameraFlightOptions, type GraphHighlightTarget, type GraphInstance, type GraphLegendData, type GraphMountOptions, type GraphTooltipFormatter, type GraphTooltipItem, JPGExportOptions, type KeyboardNavOptions, type MapCameraOptions, type MapInstance, type MapMarkEvent, type MapMountOptions, SVGExportOptions, type SankeyInstance, type SankeyMountOptions, type SpecSequenceOptions, type TableInstance, type TableMountOptions, type TableState, type TextEditOverlayConfig, type TileMapInstance, type TileMapMountOptions, type TooltipManager, VECTOR_EXPORT_MAX_POINTS, type YouDrawItController, type YouDrawItOptions, attachKeyboardNav, createBarList, createGraph, createMap, createSankey, createSimulationWorker, createTable, createTextEditOverlay, createTileMap, createTooltipManager, createYouDrawIt, exportSpecSequence, materializeCanvasModeSVG, observeResize, rectPathWithCorners, registerMarkRenderer, renderBarCell, renderCategoryCell, renderCell, renderChartSVG, renderFlagCell, renderHeatmapCell, renderImageCell, renderSparklineCell, renderTable, renderTextCell };
|