@opendata-ai/openchart-vanilla 8.0.0-rc.8 → 8.0.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/dist/{chunk-W34KN7FD.js → chunk-2NAQRP66.js} +2 -2
- package/dist/{chunk-UZ7J3NOF.js → chunk-6BUCYCLD.js} +7314 -5605
- package/dist/chunk-6BUCYCLD.js.map +1 -0
- 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-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 +309 -27
- package/dist/index.js +2020 -836
- package/dist/index.js.map +1 -1
- package/dist/{mount-CUKQLeqD.d.ts → mount-CL-nA0f-.d.ts} +85 -2
- package/dist/simulation-worker.js +83 -2
- package/dist/static.d.ts +2 -0
- package/dist/static.js +8 -69
- package/dist/static.js.map +1 -1
- package/dist/story/index.d.ts +25 -9
- package/dist/story/index.js +9 -7
- 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-UZ7J3NOF.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 -950
- 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 -636
- 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 -1792
- package/src/__tests__/update-scrolly-matrix.test.ts +0 -563
- 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 -111
- package/src/map-mount.ts +0 -792
- package/src/map-renderer.ts +0 -460
- package/src/map-transition.ts +0 -99
- 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,
|
|
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, b as exportJPG, d as exportPNG, f as exportSVG, g as exportSVGWithFonts } from './mount-
|
|
2
|
+
import { BarListSpec, BarListLayout, ThemeConfig, DarkMode, ChartLayout, ChartSpec, LayerSpec, AnimationEase, GraphSpec, TooltipContent, GeoMapSpec, GeoMapLayout, 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-CL-nA0f-.js';
|
|
4
|
+
export { a as ChartInstance, E as ExportOptions, M as MountOptions, P as PNGExportOptions, U as UpdateOptions, c as createChart, e as exportCSV, b as exportJPG, d as exportPNG, f as exportSVG, g as exportSVGWithFonts } from './mount-CL-nA0f-.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,142 @@ 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
|
+
* Rendering backend for point marks; see `MountOptions.renderer`. Pass the
|
|
131
|
+
* SAME value your on-screen chart mounts with so the export matches.
|
|
132
|
+
*/
|
|
133
|
+
renderer?: 'auto' | 'svg' | 'canvas';
|
|
134
|
+
/**
|
|
135
|
+
* Theme overrides applied when rendering, exactly as a consumer's live wrapper
|
|
136
|
+
* would apply them. Pass the SAME theme your on-screen chart uses (e.g. the
|
|
137
|
+
* blog's `blogChartTheme(isDark)`), or the export won't match — its background,
|
|
138
|
+
* gridlines, and chrome colors fall back to openchart's raw defaults.
|
|
139
|
+
*/
|
|
140
|
+
theme?: ThemeConfig;
|
|
141
|
+
/** Embed fonts as base64 so text matches on-screen. Defaults to true. */
|
|
142
|
+
embedFonts?: boolean;
|
|
143
|
+
/** Opaque background fill. Defaults to the chart's own background (white if transparent). */
|
|
144
|
+
backgroundColor?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Render an ordered list of specs to an animated GIF Blob. Holds the first spec,
|
|
148
|
+
* then tweens to each subsequent spec (openchart's update transition, driven
|
|
149
|
+
* frame-by-frame) and holds it — reproducing the on-screen bar grow/shrink.
|
|
150
|
+
*
|
|
151
|
+
* @param specs - Ordered specs, one per keyframe (e.g. one per year).
|
|
152
|
+
* @param options - dpi, fps, dwell, loop, size (required), dark mode, theme, fonts.
|
|
153
|
+
* @returns A Promise resolving to the GIF Blob.
|
|
154
|
+
*/
|
|
155
|
+
declare function exportSpecSequence(specs: Array<ChartSpec | LayerSpec>, options: SpecSequenceOptions): Promise<Blob>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Animated camera for the graph.
|
|
159
|
+
*
|
|
160
|
+
* Flights interpolate between two `ZoomTransform`s along d3's geodesic
|
|
161
|
+
* `interpolateZoom` path (smooth zoom-and-pan that pulls back to see both
|
|
162
|
+
* endpoints before diving in). A flight is a {@link GraphAnimation}, driven by
|
|
163
|
+
* the mount's AnimationScheduler.
|
|
164
|
+
*
|
|
165
|
+
* `interpolateZoom` operates on a `[cx, cy, width]` "view" — the graph-space
|
|
166
|
+
* center and the graph-space width visible across the viewport. We convert the
|
|
167
|
+
* ZoomTransform ⇄ view around a fixed viewport size.
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
/** Options controlling a camera flight. */
|
|
171
|
+
interface CameraFlightOptions {
|
|
172
|
+
/** Duration in ms, or `'auto'` to derive from the zoom distance. */
|
|
173
|
+
duration?: number | 'auto';
|
|
174
|
+
/** Easing preset. Default `'smooth'`. */
|
|
175
|
+
ease?: AnimationEase;
|
|
176
|
+
}
|
|
177
|
+
|
|
41
178
|
/**
|
|
42
179
|
* Creates a Web Worker running the force simulation.
|
|
43
180
|
*
|
|
@@ -58,21 +195,99 @@ declare function createSimulationWorker(): Worker;
|
|
|
58
195
|
* simulation ticks. Returns a GraphInstance with update/search/zoom/destroy.
|
|
59
196
|
*/
|
|
60
197
|
|
|
198
|
+
/**
|
|
199
|
+
* A programmatic highlight target. Resolved once at call time into a node id set
|
|
200
|
+
* and rendered through the focus model (eased crossfade). See {@link GraphInstance.highlight}.
|
|
201
|
+
*/
|
|
202
|
+
type GraphHighlightTarget = {
|
|
203
|
+
nodeIds: string[];
|
|
204
|
+
} | {
|
|
205
|
+
category: {
|
|
206
|
+
field: string;
|
|
207
|
+
value: string | string[];
|
|
208
|
+
};
|
|
209
|
+
} | {
|
|
210
|
+
neighborsOf: string;
|
|
211
|
+
includeSelf?: boolean;
|
|
212
|
+
};
|
|
213
|
+
/** A hovered node or edge, passed to a tooltip formatter. */
|
|
214
|
+
interface GraphTooltipItem {
|
|
215
|
+
kind: 'node' | 'edge';
|
|
216
|
+
/** The raw datum (node record, or edge record with source/target). */
|
|
217
|
+
data: Record<string, unknown>;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Custom tooltip content builder. Receives the hovered item and the library's
|
|
221
|
+
* default {@link TooltipContent}, returns replacement content.
|
|
222
|
+
*
|
|
223
|
+
* Safety contract:
|
|
224
|
+
* - A returned `TooltipContent` or `string` is escaped by the library (strings
|
|
225
|
+
* are inserted via `textContent`, never `innerHTML`).
|
|
226
|
+
* - A returned `HTMLElement` is trusted verbatim — the host owns sanitization.
|
|
227
|
+
* - `null` suppresses the tooltip for that item.
|
|
228
|
+
*/
|
|
229
|
+
type GraphTooltipFormatter = (item: GraphTooltipItem, defaults: TooltipContent) => TooltipContent | string | HTMLElement | null;
|
|
230
|
+
/** Built-in legend data (headless mirror of the rendered legend). */
|
|
231
|
+
interface GraphLegendData {
|
|
232
|
+
field: string | null;
|
|
233
|
+
nodes: Array<{
|
|
234
|
+
label: string;
|
|
235
|
+
color: string;
|
|
236
|
+
count?: number;
|
|
237
|
+
active: boolean;
|
|
238
|
+
}>;
|
|
239
|
+
edges: Array<{
|
|
240
|
+
label: string;
|
|
241
|
+
color: string;
|
|
242
|
+
count?: number;
|
|
243
|
+
}>;
|
|
244
|
+
}
|
|
61
245
|
interface GraphMountOptions {
|
|
62
246
|
theme?: ThemeConfig;
|
|
63
247
|
darkMode?: DarkMode;
|
|
64
248
|
responsive?: boolean;
|
|
65
249
|
/** Show the tryOpenData.ai watermark. Defaults to true. */
|
|
66
250
|
watermark?: boolean;
|
|
67
|
-
/** Show the built-in tooltip
|
|
68
|
-
tooltip?: boolean
|
|
69
|
-
|
|
70
|
-
|
|
251
|
+
/** Show the built-in tooltip; pass an object for a custom formatter. Defaults to true. */
|
|
252
|
+
tooltip?: boolean | {
|
|
253
|
+
formatter?: GraphTooltipFormatter;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Built-in legend. `true` (default) renders an interactive legend with counts.
|
|
257
|
+
* `false` renders none (set this if you render your own legend). An object
|
|
258
|
+
* toggles interactivity/counts.
|
|
259
|
+
*/
|
|
260
|
+
legend?: boolean | {
|
|
261
|
+
interactive?: boolean;
|
|
262
|
+
counts?: boolean;
|
|
263
|
+
};
|
|
71
264
|
onNodeClick?: (node: Record<string, unknown>) => void;
|
|
72
265
|
onNodeDoubleClick?: (node: Record<string, unknown>) => void;
|
|
73
266
|
onNodeHover?: (node: Record<string, unknown> | null) => void;
|
|
74
267
|
onEdgeHover?: (edge: Record<string, unknown> | null) => void;
|
|
75
268
|
onSelectionChange?: (nodeIds: string[]) => void;
|
|
269
|
+
/** Fired when the user hovers a legend entry (null on leave). */
|
|
270
|
+
onLegendHover?: (entry: {
|
|
271
|
+
field: string;
|
|
272
|
+
value: string;
|
|
273
|
+
} | null) => void;
|
|
274
|
+
/** Fired when legend toggle state changes; `activeValues` is the active category set (empty = all). */
|
|
275
|
+
onLegendToggle?: (activeValues: string[]) => void;
|
|
276
|
+
/** Fired whenever the highlight set changes (programmatic or legend), null when cleared. */
|
|
277
|
+
onHighlightChange?: (nodeIds: string[] | null) => void;
|
|
278
|
+
/**
|
|
279
|
+
* Fit the graph to the viewport on the first tick. Default true. Set false to
|
|
280
|
+
* restore a saved camera (e.g. getCamera() + flyTo) without the initial fit.
|
|
281
|
+
*/
|
|
282
|
+
fitOnLoad?: boolean;
|
|
283
|
+
/** Camera change callback, rAF-coalesced (fires at most once per rendered frame). */
|
|
284
|
+
onCameraChange?: (camera: {
|
|
285
|
+
x: number;
|
|
286
|
+
y: number;
|
|
287
|
+
k: number;
|
|
288
|
+
}) => void;
|
|
289
|
+
/** 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. */
|
|
290
|
+
suppressEntrance?: boolean;
|
|
76
291
|
}
|
|
77
292
|
interface GraphInstance {
|
|
78
293
|
update(spec: GraphSpec): void;
|
|
@@ -80,10 +295,49 @@ interface GraphInstance {
|
|
|
80
295
|
updateVisuals(spec: GraphSpec): void;
|
|
81
296
|
search(query: string): void;
|
|
82
297
|
clearSearch(): void;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
298
|
+
/** Fit all nodes into the viewport. Animated by default; `{ duration: 0 }` snaps. */
|
|
299
|
+
zoomToFit(opts?: CameraFlightOptions & {
|
|
300
|
+
padding?: number;
|
|
301
|
+
}): void;
|
|
302
|
+
/** Fly to a node and zoom in (default scale 2). Tracks the node while it settles. */
|
|
303
|
+
zoomToNode(nodeId: string, opts?: CameraFlightOptions & {
|
|
304
|
+
scale?: number;
|
|
305
|
+
}): void;
|
|
306
|
+
/** Fly the camera to a graph-space target. */
|
|
307
|
+
flyTo(target: {
|
|
308
|
+
x: number;
|
|
309
|
+
y: number;
|
|
310
|
+
k?: number;
|
|
311
|
+
}, opts?: CameraFlightOptions): void;
|
|
312
|
+
/** Center the camera on a graph-space point (keeps current zoom). */
|
|
313
|
+
centerAt(x: number, y: number, opts?: CameraFlightOptions): void;
|
|
314
|
+
/** Current camera (graph-space center-ish transform components). */
|
|
315
|
+
getCamera(): {
|
|
316
|
+
x: number;
|
|
317
|
+
y: number;
|
|
318
|
+
k: number;
|
|
319
|
+
};
|
|
320
|
+
/** Select a node; `{ fly: true }` also flies to it (default follows interaction.select.flyTo). */
|
|
321
|
+
selectNode(nodeId: string, opts?: {
|
|
322
|
+
fly?: boolean;
|
|
323
|
+
} & CameraFlightOptions): void;
|
|
86
324
|
getSelectedNodes(): string[];
|
|
325
|
+
/** Node ids currently matching the active search query. */
|
|
326
|
+
getSearchMatches(): string[];
|
|
327
|
+
/** Emphasize a set of nodes; eased via the focus model. Resets legend toggles. */
|
|
328
|
+
highlight(target: GraphHighlightTarget, opts?: {
|
|
329
|
+
dimOpacity?: number;
|
|
330
|
+
}): void;
|
|
331
|
+
/** Clear any programmatic highlight (and legend toggles). */
|
|
332
|
+
clearHighlight(): void;
|
|
333
|
+
/** The currently highlighted node ids, or null when nothing is highlighted. */
|
|
334
|
+
getHighlight(): string[] | null;
|
|
335
|
+
/** Headless snapshot of the legend (node categories + edge categories). */
|
|
336
|
+
getLegend(): GraphLegendData;
|
|
337
|
+
/** Set the active category filter declaratively (replaces legend toggle state). */
|
|
338
|
+
setActiveCategories(values: string[]): void;
|
|
339
|
+
/** Current active category values (empty = all active, no filter). */
|
|
340
|
+
getActiveCategories(): string[];
|
|
87
341
|
resize(): void;
|
|
88
342
|
destroy(): void;
|
|
89
343
|
}
|
|
@@ -105,7 +359,7 @@ declare function createGraph(container: HTMLElement, spec: GraphSpec, options?:
|
|
|
105
359
|
* on the `[data-oc-map-camera]` group, never as a CSS transform.
|
|
106
360
|
*/
|
|
107
361
|
|
|
108
|
-
interface
|
|
362
|
+
interface GeoMapCameraOptions {
|
|
109
363
|
/** Transition duration in ms. 0 snaps instantly. Default 600. */
|
|
110
364
|
duration?: number;
|
|
111
365
|
/** Padding in map-local units around the target. Default 16. */
|
|
@@ -115,18 +369,18 @@ interface MapCameraOptions {
|
|
|
115
369
|
/**
|
|
116
370
|
* Map mount API: the main entry point for vanilla JS map usage.
|
|
117
371
|
*
|
|
118
|
-
*
|
|
372
|
+
* createGeoMap() takes a container, GeoMapSpec, and options, compiles the
|
|
119
373
|
* map, renders it as SVG, sets up responsive resizing, tooltip interaction,
|
|
120
|
-
* and returns a
|
|
374
|
+
* and returns a GeoMapInstance with update/resize/export/destroy.
|
|
121
375
|
*/
|
|
122
376
|
|
|
123
|
-
type
|
|
377
|
+
type GeoMapMarkEvent = {
|
|
124
378
|
kind: 'feature' | 'point';
|
|
125
379
|
id: string | number;
|
|
126
380
|
name?: string;
|
|
127
381
|
data: Record<string, unknown> | null;
|
|
128
382
|
};
|
|
129
|
-
interface
|
|
383
|
+
interface GeoMapMountOptions {
|
|
130
384
|
/** Theme overrides. */
|
|
131
385
|
theme?: ThemeConfig;
|
|
132
386
|
/** Dark mode setting: "auto" (system pref), "force", or "off". */
|
|
@@ -138,13 +392,13 @@ interface MapMountOptions {
|
|
|
138
392
|
/** Show tooltips on hover. Defaults to true. */
|
|
139
393
|
tooltip?: boolean;
|
|
140
394
|
/** Callback when a feature or point is clicked. */
|
|
141
|
-
onMarkClick?: (event:
|
|
395
|
+
onMarkClick?: (event: GeoMapMarkEvent) => void;
|
|
142
396
|
/** Callback when a feature or point is hovered (null on mouse leave). */
|
|
143
|
-
onMarkHover?: (event:
|
|
397
|
+
onMarkHover?: (event: GeoMapMarkEvent | null) => void;
|
|
144
398
|
}
|
|
145
|
-
interface
|
|
399
|
+
interface GeoMapInstance {
|
|
146
400
|
/** Re-compile and re-render with a new spec. */
|
|
147
|
-
update(spec:
|
|
401
|
+
update(spec: GeoMapSpec): void;
|
|
148
402
|
/** Re-compile at current container dimensions. */
|
|
149
403
|
resize(): void;
|
|
150
404
|
/** Export the map. */
|
|
@@ -152,11 +406,11 @@ interface MapInstance {
|
|
|
152
406
|
/** Remove all DOM elements and disconnect observers. */
|
|
153
407
|
destroy(): void;
|
|
154
408
|
/** The current compiled layout. */
|
|
155
|
-
readonly layout:
|
|
409
|
+
readonly layout: GeoMapLayout;
|
|
156
410
|
/** Zoom to one or more features by ID. */
|
|
157
|
-
zoomTo(featureId: string | number | Array<string | number>, opts?:
|
|
411
|
+
zoomTo(featureId: string | number | Array<string | number>, opts?: GeoMapCameraOptions): void;
|
|
158
412
|
/** Pan to a feature keeping the current zoom level. */
|
|
159
|
-
panTo(featureId: string | number, opts?:
|
|
413
|
+
panTo(featureId: string | number, opts?: GeoMapCameraOptions): void;
|
|
160
414
|
/** Fit the camera to an arbitrary bounding box, or reset to full view if no target. */
|
|
161
415
|
fitBounds(target?: {
|
|
162
416
|
x: number;
|
|
@@ -164,9 +418,9 @@ interface MapInstance {
|
|
|
164
418
|
width: number;
|
|
165
419
|
height: number;
|
|
166
420
|
padding?: number;
|
|
167
|
-
}, opts?:
|
|
421
|
+
}, opts?: GeoMapCameraOptions): void;
|
|
168
422
|
/** Reset the camera to the full map view. */
|
|
169
|
-
resetView(opts?:
|
|
423
|
+
resetView(opts?: GeoMapCameraOptions): void;
|
|
170
424
|
/** Get a snapshot of the current camera state. */
|
|
171
425
|
getCamera(): Camera;
|
|
172
426
|
/** Set the camera to an exact state (no animation). */
|
|
@@ -175,7 +429,23 @@ interface MapInstance {
|
|
|
175
429
|
/**
|
|
176
430
|
* Create a map instance from a spec and mount it into a container.
|
|
177
431
|
*/
|
|
178
|
-
declare function
|
|
432
|
+
declare function createGeoMap(container: HTMLElement, spec: GeoMapSpec, options?: GeoMapMountOptions): GeoMapInstance;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Default cap on the mark count that still runs a tweened data-update
|
|
436
|
+
* transition. Override per chart with `animation.update.maxMarks`.
|
|
437
|
+
*/
|
|
438
|
+
declare const DEFAULT_UPDATE_MAX_MARKS = 500;
|
|
439
|
+
/**
|
|
440
|
+
* Default cap when the destination layout renders its points on canvas.
|
|
441
|
+
*
|
|
442
|
+
* Two orders of magnitude above the SVG cap because the cost model is
|
|
443
|
+
* different: a canvas frame writes into typed arrays and issues one batched
|
|
444
|
+
* fill per color bucket, where the SVG path writes attributes on one DOM
|
|
445
|
+
* element per mark. The cap that keeps low-end devices honest for DOM writes
|
|
446
|
+
* would veto exactly the high-cardinality morphs canvas mode exists to serve.
|
|
447
|
+
*/
|
|
448
|
+
declare const CANVAS_DEFAULT_UPDATE_MAX_MARKS = 20000;
|
|
179
449
|
|
|
180
450
|
/**
|
|
181
451
|
* Mark rendering: dispatches to per-mark-type sub-renderers (line, area, rect,
|
|
@@ -307,6 +577,7 @@ declare function createSankey(container: HTMLElement, spec: SankeySpec, options?
|
|
|
307
577
|
declare function renderChartSVG(layout: ChartLayout, container: HTMLElement, opts?: {
|
|
308
578
|
animate?: boolean;
|
|
309
579
|
crosshair?: boolean;
|
|
580
|
+
canvasMarks?: boolean;
|
|
310
581
|
}): SVGElement;
|
|
311
582
|
|
|
312
583
|
/**
|
|
@@ -499,9 +770,20 @@ interface TooltipShowOptions {
|
|
|
499
770
|
*/
|
|
500
771
|
placement?: Placement;
|
|
501
772
|
}
|
|
773
|
+
/**
|
|
774
|
+
* Content accepted by {@link TooltipManager.show}. A structured
|
|
775
|
+
* {@link TooltipContent} is rendered by the manager; `{ text }` is inserted as
|
|
776
|
+
* plain text (escaped via textContent); `{ element }` is a caller-owned node
|
|
777
|
+
* trusted verbatim (the host owns sanitization).
|
|
778
|
+
*/
|
|
779
|
+
type TooltipInput = TooltipContent | {
|
|
780
|
+
text: string;
|
|
781
|
+
} | {
|
|
782
|
+
element: HTMLElement;
|
|
783
|
+
};
|
|
502
784
|
interface TooltipManager {
|
|
503
785
|
/** Show the tooltip with content at a given position. */
|
|
504
|
-
show(content:
|
|
786
|
+
show(content: TooltipInput, x: number, y: number, opts?: TooltipShowOptions): void;
|
|
505
787
|
/** Hide the tooltip. */
|
|
506
788
|
hide(): void;
|
|
507
789
|
/** Remove the tooltip element and clean up event listeners. */
|
|
@@ -565,4 +847,4 @@ interface YouDrawItController {
|
|
|
565
847
|
*/
|
|
566
848
|
declare function createYouDrawIt(options: YouDrawItOptions): YouDrawItController;
|
|
567
849
|
|
|
568
|
-
export { type BarListInstance, type BarListMountOptions, Camera, type
|
|
850
|
+
export { type BarListInstance, type BarListMountOptions, CANVAS_DEFAULT_UPDATE_MAX_MARKS, Camera, type CameraFlightOptions, DEFAULT_UPDATE_MAX_MARKS, type GeoMapCameraOptions, type GeoMapInstance, type GeoMapMarkEvent, type GeoMapMountOptions, type GraphHighlightTarget, type GraphInstance, type GraphLegendData, type GraphMountOptions, type GraphTooltipFormatter, type GraphTooltipItem, JPGExportOptions, type KeyboardNavOptions, 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, createGeoMap, createGraph, createSankey, createSimulationWorker, createTable, createTextEditOverlay, createTileMap, createTooltipManager, createYouDrawIt, exportSpecSequence, materializeCanvasModeSVG, observeResize, rectPathWithCorners, registerMarkRenderer, renderBarCell, renderCategoryCell, renderCell, renderChartSVG, renderFlagCell, renderHeatmapCell, renderImageCell, renderSparklineCell, renderTable, renderTextCell };
|