@opendata-ai/openchart-vanilla 8.4.1 → 8.5.1
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/README.md +59 -0
- package/dist/chunk-2OJZBMXM.js +377 -0
- package/dist/chunk-2OJZBMXM.js.map +1 -0
- package/dist/{chunk-5A2NLYUW.js → chunk-5KV3ZBBL.js} +26 -376
- package/dist/chunk-5KV3ZBBL.js.map +1 -0
- package/dist/chunk-NG7CVCI2.js +58 -0
- package/dist/chunk-NG7CVCI2.js.map +1 -0
- package/dist/{chunk-3UIUANPI.js → chunk-UAK6HWOC.js} +2 -2
- package/dist/chunk-WOLX5EZT.js +3577 -0
- package/dist/chunk-WOLX5EZT.js.map +1 -0
- package/dist/{chunk-KANNWAEA.js → chunk-XGII4ZRT.js} +4 -58
- package/dist/chunk-XGII4ZRT.js.map +1 -0
- package/dist/graph-3d/index.d.ts +272 -0
- package/dist/graph-3d/index.js +1556 -0
- package/dist/graph-3d/index.js.map +1 -0
- package/dist/index.d.ts +4 -252
- package/dist/index.js +24 -3468
- package/dist/index.js.map +1 -1
- package/dist/renderer-registry-B5tW6yAZ.d.ts +376 -0
- package/dist/static.js +3 -2
- package/dist/static.js.map +1 -1
- package/dist/story/index.js +8 -5
- package/dist/story/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +28 -6
- package/dist/chunk-5A2NLYUW.js.map +0 -1
- package/dist/chunk-KANNWAEA.js.map +0 -1
- /package/dist/{chunk-3UIUANPI.js.map → chunk-UAK6HWOC.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { ChartLayout, ChartSpec, CompileOptions, TableLayout, TableSpec, VizSpec } from '@opendata-ai/openchart-engine';
|
|
2
|
-
import { BarListSpec, BarListLayout, ThemeConfig, DarkMode, ChartLayout, ChartSpec, LayerSpec,
|
|
2
|
+
import { BarListSpec, BarListLayout, ThemeConfig, DarkMode, ChartLayout, ChartSpec, LayerSpec, 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
3
|
import { J as JPGExportOptions, S as SVGExportOptions, C as Camera } from './mount-Bs8nFSf1.js';
|
|
4
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-Bs8nFSf1.js';
|
|
5
|
-
|
|
5
|
+
export { C as CameraFlightOptions, G as GRAPH_3D_NOT_REGISTERED_ERROR, a as GraphCamera, b as GraphFlyTarget, c as GraphHighlightTarget, d as GraphInstance, e as GraphLegendData, f as GraphMountOptions, g as GraphRendererContext, h as GraphRendererFactory, i as GraphShell, j as GraphTooltipFormatter, k as GraphTooltipItem, T as TooltipManager, l as createGraph, m as createTooltipManager, r as registerGraphRenderer } from './renderer-registry-B5tW6yAZ.js';
|
|
6
6
|
import './export-gif.js';
|
|
7
|
+
import '@floating-ui/dom';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* BarList mount API: the main entry point for vanilla JS barlist usage.
|
|
@@ -154,27 +155,6 @@ interface SpecSequenceOptions {
|
|
|
154
155
|
*/
|
|
155
156
|
declare function exportSpecSequence(specs: Array<ChartSpec | LayerSpec>, options: SpecSequenceOptions): Promise<Blob>;
|
|
156
157
|
|
|
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
|
-
|
|
178
158
|
/**
|
|
179
159
|
* Creates a Web Worker running the force simulation.
|
|
180
160
|
*
|
|
@@ -186,186 +166,6 @@ interface CameraFlightOptions {
|
|
|
186
166
|
*/
|
|
187
167
|
declare function createSimulationWorker(): Worker;
|
|
188
168
|
|
|
189
|
-
/**
|
|
190
|
-
* Graph mount API: the main entry point for vanilla JS graph usage.
|
|
191
|
-
*
|
|
192
|
-
* createGraph() takes a container, GraphSpec, and options, compiles the graph,
|
|
193
|
-
* creates a force simulation, canvas renderer, spatial index, interaction
|
|
194
|
-
* manager, and search manager, then runs an animation loop driven by
|
|
195
|
-
* simulation ticks. Returns a GraphInstance with update/search/zoom/destroy.
|
|
196
|
-
*/
|
|
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
|
-
}
|
|
245
|
-
interface GraphMountOptions {
|
|
246
|
-
theme?: ThemeConfig;
|
|
247
|
-
darkMode?: DarkMode;
|
|
248
|
-
/**
|
|
249
|
-
* Sink for advisory spec warnings from the compiler (unknown `seedNode` id,
|
|
250
|
-
* deprecations, and so on). Defaults to `console.warn`. Each distinct message
|
|
251
|
-
* is emitted at most once per instance, so a warning that survives every
|
|
252
|
-
* recompile doesn't spam the console on `update()`.
|
|
253
|
-
*/
|
|
254
|
-
onWarn?: (message: string) => void;
|
|
255
|
-
responsive?: boolean;
|
|
256
|
-
/** Show the OpenData watermark. Defaults to true. */
|
|
257
|
-
watermark?: boolean;
|
|
258
|
-
/** Show the built-in tooltip; pass an object for a custom formatter. Defaults to true. */
|
|
259
|
-
tooltip?: boolean | {
|
|
260
|
-
formatter?: GraphTooltipFormatter;
|
|
261
|
-
};
|
|
262
|
-
/**
|
|
263
|
-
* Built-in legend. `true` (default) renders an interactive legend with counts.
|
|
264
|
-
* `false` renders none (set this if you render your own legend). An object
|
|
265
|
-
* toggles interactivity/counts.
|
|
266
|
-
*/
|
|
267
|
-
legend?: boolean | {
|
|
268
|
-
interactive?: boolean;
|
|
269
|
-
counts?: boolean;
|
|
270
|
-
};
|
|
271
|
-
onNodeClick?: (node: Record<string, unknown>) => void;
|
|
272
|
-
onNodeDoubleClick?: (node: Record<string, unknown>) => void;
|
|
273
|
-
onNodeHover?: (node: Record<string, unknown> | null) => void;
|
|
274
|
-
onEdgeHover?: (edge: Record<string, unknown> | null) => void;
|
|
275
|
-
onSelectionChange?: (nodeIds: string[]) => void;
|
|
276
|
-
/** Fired when the user hovers a legend entry (null on leave). */
|
|
277
|
-
onLegendHover?: (entry: {
|
|
278
|
-
field: string;
|
|
279
|
-
value: string;
|
|
280
|
-
} | null) => void;
|
|
281
|
-
/** Fired when legend toggle state changes; `activeValues` is the active category set (empty = all). */
|
|
282
|
-
onLegendToggle?: (activeValues: string[]) => void;
|
|
283
|
-
/** Fired whenever the highlight set changes (programmatic or legend), null when cleared. */
|
|
284
|
-
onHighlightChange?: (nodeIds: string[] | null) => void;
|
|
285
|
-
/**
|
|
286
|
-
* Fit the graph to the viewport on the first tick. Default true. Set false to
|
|
287
|
-
* restore a saved camera (e.g. getCamera() + flyTo) without the initial fit.
|
|
288
|
-
*/
|
|
289
|
-
fitOnLoad?: boolean;
|
|
290
|
-
/** Camera change callback, rAF-coalesced (fires at most once per rendered frame). */
|
|
291
|
-
onCameraChange?: (camera: {
|
|
292
|
-
x: number;
|
|
293
|
-
y: number;
|
|
294
|
-
k: number;
|
|
295
|
-
}) => void;
|
|
296
|
-
/** 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. */
|
|
297
|
-
suppressEntrance?: boolean;
|
|
298
|
-
}
|
|
299
|
-
interface GraphInstance {
|
|
300
|
-
update(spec: GraphSpec): void;
|
|
301
|
-
/** Re-compile encoding/legend/chrome without restarting the simulation. Preserves node positions. */
|
|
302
|
-
updateVisuals(spec: GraphSpec): void;
|
|
303
|
-
search(query: string): void;
|
|
304
|
-
clearSearch(): void;
|
|
305
|
-
/** Fit all nodes into the viewport. Animated by default; `{ duration: 0 }` snaps. */
|
|
306
|
-
zoomToFit(opts?: CameraFlightOptions & {
|
|
307
|
-
padding?: number;
|
|
308
|
-
}): void;
|
|
309
|
-
/** Fly to a node and zoom in (default scale 2). Tracks the node while it settles. */
|
|
310
|
-
zoomToNode(nodeId: string, opts?: CameraFlightOptions & {
|
|
311
|
-
scale?: number;
|
|
312
|
-
}): void;
|
|
313
|
-
/** Fly the camera to a graph-space target. */
|
|
314
|
-
flyTo(target: {
|
|
315
|
-
x: number;
|
|
316
|
-
y: number;
|
|
317
|
-
k?: number;
|
|
318
|
-
}, opts?: CameraFlightOptions): void;
|
|
319
|
-
/** Center the camera on a graph-space point (keeps current zoom). */
|
|
320
|
-
centerAt(x: number, y: number, opts?: CameraFlightOptions): void;
|
|
321
|
-
/** Current camera (graph-space center-ish transform components). */
|
|
322
|
-
getCamera(): {
|
|
323
|
-
x: number;
|
|
324
|
-
y: number;
|
|
325
|
-
k: number;
|
|
326
|
-
};
|
|
327
|
-
/** Select a node; `{ fly: true }` also flies to it (default follows interaction.select.flyTo). */
|
|
328
|
-
selectNode(nodeId: string, opts?: {
|
|
329
|
-
fly?: boolean;
|
|
330
|
-
} & CameraFlightOptions): void;
|
|
331
|
-
getSelectedNodes(): string[];
|
|
332
|
-
/** Node ids currently matching the active search query. */
|
|
333
|
-
getSearchMatches(): string[];
|
|
334
|
-
/**
|
|
335
|
-
* Emphasize a set of nodes; eased via the focus model. Layers over the
|
|
336
|
-
* standing category filter (`setActiveCategories`) rather than replacing it:
|
|
337
|
-
* the effective set is the intersection, or the highlight alone when the two
|
|
338
|
-
* are disjoint. Legend toggle state is untouched.
|
|
339
|
-
*/
|
|
340
|
-
highlight(target: GraphHighlightTarget, opts?: {
|
|
341
|
-
dimOpacity?: number;
|
|
342
|
-
}): void;
|
|
343
|
-
/**
|
|
344
|
-
* Clear the transient highlight, returning to the standing category filter.
|
|
345
|
-
* Does NOT clear the filter — use `setActiveCategories([])` for that.
|
|
346
|
-
*/
|
|
347
|
-
clearHighlight(): void;
|
|
348
|
-
/** The effective highlighted node ids, or null when nothing is highlighted. */
|
|
349
|
-
getHighlight(): string[] | null;
|
|
350
|
-
/** Headless snapshot of the legend (node categories + edge categories). */
|
|
351
|
-
getLegend(): GraphLegendData;
|
|
352
|
-
/** Set the active category filter declaratively (replaces legend toggle state). */
|
|
353
|
-
setActiveCategories(values: string[]): void;
|
|
354
|
-
/** Current active category values (empty = all active, no filter). */
|
|
355
|
-
getActiveCategories(): string[];
|
|
356
|
-
resize(): void;
|
|
357
|
-
destroy(): void;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Create a graph instance from a spec and mount it into a container.
|
|
361
|
-
*
|
|
362
|
-
* @param container - The DOM element to render into.
|
|
363
|
-
* @param spec - The graph spec.
|
|
364
|
-
* @param options - Mount options.
|
|
365
|
-
* @returns A GraphInstance with update/search/zoom/destroy methods.
|
|
366
|
-
*/
|
|
367
|
-
declare function createGraph(container: HTMLElement, spec: GraphSpec, options?: GraphMountOptions): GraphInstance;
|
|
368
|
-
|
|
369
169
|
/**
|
|
370
170
|
* Map camera utilities: zoom, pan, and focus for map visualizations.
|
|
371
171
|
*
|
|
@@ -773,54 +573,6 @@ interface TileMapInstance {
|
|
|
773
573
|
*/
|
|
774
574
|
declare function createTileMap(container: HTMLElement, spec: TileMapSpec, options?: TileMapMountOptions): TileMapInstance;
|
|
775
575
|
|
|
776
|
-
/**
|
|
777
|
-
* Tooltip manager: creates and positions a floating tooltip element.
|
|
778
|
-
*
|
|
779
|
-
* Shows tooltip content near the mouse/touch position with viewport
|
|
780
|
-
* edge avoidance via @floating-ui/dom. Touch support via tap-to-show,
|
|
781
|
-
* tap-outside-to-hide.
|
|
782
|
-
*/
|
|
783
|
-
|
|
784
|
-
interface TooltipShowOptions {
|
|
785
|
-
/**
|
|
786
|
-
* Floating-ui placement. Defaults to 'bottom-start' for mark hover
|
|
787
|
-
* (the legacy behavior). Line/area snap-tooltips pass 'right-start'
|
|
788
|
-
* so the card sits beside the snapped point and flips to 'left-start'
|
|
789
|
-
* via the flip middleware when crowding the right edge.
|
|
790
|
-
*/
|
|
791
|
-
placement?: Placement;
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Content accepted by {@link TooltipManager.show}. A structured
|
|
795
|
-
* {@link TooltipContent} is rendered by the manager; `{ text }` is inserted as
|
|
796
|
-
* plain text (escaped via textContent); `{ element }` is a caller-owned node
|
|
797
|
-
* trusted verbatim (the host owns sanitization).
|
|
798
|
-
*/
|
|
799
|
-
type TooltipInput = TooltipContent | {
|
|
800
|
-
text: string;
|
|
801
|
-
} | {
|
|
802
|
-
element: HTMLElement;
|
|
803
|
-
};
|
|
804
|
-
interface TooltipManager {
|
|
805
|
-
/** Show the tooltip with content at a given position. */
|
|
806
|
-
show(content: TooltipInput, x: number, y: number, opts?: TooltipShowOptions): void;
|
|
807
|
-
/** Hide the tooltip. */
|
|
808
|
-
hide(): void;
|
|
809
|
-
/** Remove the tooltip element and clean up event listeners. */
|
|
810
|
-
destroy(): void;
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Create a tooltip manager attached to a container element.
|
|
814
|
-
*
|
|
815
|
-
* The manager creates a floating div positioned relative to the container.
|
|
816
|
-
* Content is rendered as a title line with optional color indicator,
|
|
817
|
-
* followed by a compact list of field-value pairs.
|
|
818
|
-
*
|
|
819
|
-
* @param container - The parent element for the tooltip.
|
|
820
|
-
* @returns TooltipManager with show/hide/destroy methods.
|
|
821
|
-
*/
|
|
822
|
-
declare function createTooltipManager(container: HTMLElement): TooltipManager;
|
|
823
|
-
|
|
824
576
|
/**
|
|
825
577
|
* "You draw it" interaction layer: the DOM/SVG overlay for the `youDrawIt`
|
|
826
578
|
* spec option (NYT-style draw-then-reveal engagement format).
|
|
@@ -867,4 +619,4 @@ interface YouDrawItController {
|
|
|
867
619
|
*/
|
|
868
620
|
declare function createYouDrawIt(options: YouDrawItOptions): YouDrawItController;
|
|
869
621
|
|
|
870
|
-
export { type BarListInstance, type BarListMountOptions, CANVAS_DEFAULT_UPDATE_MAX_MARKS, Camera,
|
|
622
|
+
export { type BarListInstance, type BarListMountOptions, CANVAS_DEFAULT_UPDATE_MAX_MARKS, Camera, DEFAULT_UPDATE_MAX_MARKS, type GeoMapCameraOptions, type GeoMapInstance, type GeoMapMarkEvent, type GeoMapMountOptions, JPGExportOptions, type KeyboardNavOptions, SVGExportOptions, type SankeyInstance, type SankeyMountOptions, type SpecSequenceOptions, type TableInstance, type TableMountOptions, type TableState, type TextEditOverlayConfig, type TileMapInstance, type TileMapMountOptions, VECTOR_EXPORT_MAX_POINTS, type YouDrawItController, type YouDrawItOptions, attachKeyboardNav, createBarList, createGeoMap, createSankey, createSimulationWorker, createTable, createTextEditOverlay, createTileMap, createYouDrawIt, exportSpecSequence, materializeCanvasModeSVG, observeResize, rectPathWithCorners, registerMarkRenderer, renderBarCell, renderCategoryCell, renderCell, renderChartSVG, renderFlagCell, renderHeatmapCell, renderImageCell, renderSparklineCell, renderTable, renderTextCell };
|