@opendata-ai/openchart-vanilla 6.5.2 → 6.7.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/index.d.ts +45 -2
- package/dist/index.js +757 -30
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/src/__tests__/sankey.test.ts +133 -0
- package/src/__tests__/svg-renderer.test.ts +6 -5
- package/src/graph/canvas-renderer.ts +1 -1
- package/src/index.ts +3 -0
- package/src/sankey-mount.ts +532 -0
- package/src/sankey-renderer.ts +602 -0
- package/src/svg-renderer.ts +15 -10
- package/src/table-renderer.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ChartLayout, ChartSpec, CompileOptions, TableLayout, TableSpec, VizSpec } from '@opendata-ai/openchart-engine';
|
|
2
|
-
import { GraphSpec, ThemeConfig, DarkMode, ChartSpec, LayerSpec, ElementRef, ChartLayout, ChartEventHandlers, BarTableCell, CategoryTableCell, TableCell, FlagTableCell, HeatmapTableCell, ImageTableCell, SparklineTableCell, TextTableCell, Mark, TableSpec, SortState, TableLayout, TooltipContent } from '@opendata-ai/openchart-core';
|
|
2
|
+
import { GraphSpec, ThemeConfig, DarkMode, ChartSpec, LayerSpec, ElementRef, ChartLayout, ChartEventHandlers, BarTableCell, CategoryTableCell, TableCell, FlagTableCell, HeatmapTableCell, ImageTableCell, SparklineTableCell, TextTableCell, SankeySpec, SankeyLayout, Mark, TableSpec, SortState, TableLayout, TooltipContent } from '@opendata-ai/openchart-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Export utilities: serialize charts to SVG, PNG, JPG, or CSV.
|
|
@@ -235,6 +235,49 @@ declare function renderCell(cell: TableCell): HTMLTableCellElement;
|
|
|
235
235
|
*/
|
|
236
236
|
declare function observeResize(container: HTMLElement, callback: (width: number, height: number) => void): () => void;
|
|
237
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Sankey mount API: the main entry point for vanilla JS sankey usage.
|
|
240
|
+
*
|
|
241
|
+
* createSankey() takes a container, SankeySpec, and options, compiles the
|
|
242
|
+
* sankey, renders it as SVG, sets up responsive resizing, tooltip interaction,
|
|
243
|
+
* hover highlighting, and returns a SankeyInstance with update/resize/export/destroy.
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
interface SankeyMountOptions {
|
|
247
|
+
/** Theme overrides. */
|
|
248
|
+
theme?: ThemeConfig;
|
|
249
|
+
/** Dark mode setting: "auto" (system pref), "force", or "off". */
|
|
250
|
+
darkMode?: DarkMode;
|
|
251
|
+
/** Enable responsive resizing. Defaults to true. */
|
|
252
|
+
responsive?: boolean;
|
|
253
|
+
/** Show tooltips on hover. Defaults to true. */
|
|
254
|
+
tooltip?: boolean;
|
|
255
|
+
/** Callback when a node is clicked. */
|
|
256
|
+
onNodeClick?: (node: Record<string, unknown>) => void;
|
|
257
|
+
/** Callback when a link is clicked. */
|
|
258
|
+
onLinkClick?: (link: Record<string, unknown>) => void;
|
|
259
|
+
/** Callback when a node is hovered (null on mouse leave). */
|
|
260
|
+
onNodeHover?: (node: Record<string, unknown> | null) => void;
|
|
261
|
+
/** Callback when a link is hovered (null on mouse leave). */
|
|
262
|
+
onLinkHover?: (link: Record<string, unknown> | null) => void;
|
|
263
|
+
}
|
|
264
|
+
interface SankeyInstance {
|
|
265
|
+
/** Re-compile and re-render with a new spec. */
|
|
266
|
+
update(spec: SankeySpec): void;
|
|
267
|
+
/** Re-compile at current container dimensions. */
|
|
268
|
+
resize(): void;
|
|
269
|
+
/** Export the sankey diagram. */
|
|
270
|
+
export(format: 'svg' | 'svg-with-fonts' | 'png' | 'jpg', options?: JPGExportOptions): string | Promise<Blob> | Promise<string>;
|
|
271
|
+
/** Remove all DOM elements and disconnect observers. */
|
|
272
|
+
destroy(): void;
|
|
273
|
+
/** The current compiled layout. */
|
|
274
|
+
readonly layout: SankeyLayout;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Create a sankey instance from a spec and mount it into a container.
|
|
278
|
+
*/
|
|
279
|
+
declare function createSankey(container: HTMLElement, spec: SankeySpec, options?: SankeyMountOptions): SankeyInstance;
|
|
280
|
+
|
|
238
281
|
/**
|
|
239
282
|
* SVG renderer: converts a ChartLayout into SVG DOM elements.
|
|
240
283
|
*
|
|
@@ -411,4 +454,4 @@ interface TooltipManager {
|
|
|
411
454
|
*/
|
|
412
455
|
declare function createTooltipManager(container: HTMLElement): TooltipManager;
|
|
413
456
|
|
|
414
|
-
export { type ChartInstance, type ExportOptions, type GraphInstance, type GraphMountOptions, type JPGExportOptions, type KeyboardNavOptions, type MountOptions, type PNGExportOptions, type SVGExportOptions, type TableInstance, type TableMountOptions, type TableState, type TextEditOverlayConfig, type TooltipManager, type UpdateOptions, attachKeyboardNav, createChart, createGraph, createSimulationWorker, createTable, createTextEditOverlay, createTooltipManager, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts, observeResize, registerMarkRenderer, renderBarCell, renderCategoryCell, renderCell, renderChartSVG, renderFlagCell, renderHeatmapCell, renderImageCell, renderSparklineCell, renderTable, renderTextCell };
|
|
457
|
+
export { type ChartInstance, type ExportOptions, type GraphInstance, type GraphMountOptions, type JPGExportOptions, type KeyboardNavOptions, type MountOptions, type PNGExportOptions, type SVGExportOptions, type SankeyInstance, type SankeyMountOptions, type TableInstance, type TableMountOptions, type TableState, type TextEditOverlayConfig, type TooltipManager, type UpdateOptions, attachKeyboardNav, createChart, createGraph, createSankey, createSimulationWorker, createTable, createTextEditOverlay, createTooltipManager, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts, observeResize, registerMarkRenderer, renderBarCell, renderCategoryCell, renderCell, renderChartSVG, renderFlagCell, renderHeatmapCell, renderImageCell, renderSparklineCell, renderTable, renderTextCell };
|