@opendata-ai/openchart-vue 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/index.d.ts +153 -22
- package/dist/index.js +136 -16
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +5 -6
- package/src/BarList.ts +0 -155
- package/src/Chart.ts +0 -257
- package/src/ChartStory.ts +0 -184
- package/src/DataTable.ts +0 -194
- package/src/Graph.ts +0 -179
- package/src/Map.ts +0 -160
- package/src/Sankey.ts +0 -161
- package/src/ThemeProvider.ts +0 -41
- package/src/TileMap.ts +0 -164
- package/src/Visualization.ts +0 -84
- package/src/__tests__/Chart.test.ts +0 -139
- package/src/__tests__/ChartStory.test.ts +0 -70
- package/src/__tests__/DataTable.test.ts +0 -131
- package/src/__tests__/Graph.test.ts +0 -133
- package/src/__tests__/ThemeContext.test.ts +0 -266
- package/src/__tests__/composables.test.ts +0 -158
- package/src/__tests__/useTableState.test.ts +0 -256
- package/src/composables/useChart.ts +0 -96
- package/src/composables/useDarkMode.ts +0 -71
- package/src/composables/useGraph.ts +0 -89
- package/src/composables/useTable.ts +0 -88
- package/src/composables/useTableState.ts +0 -80
- package/src/context.ts +0 -33
- package/src/index.ts +0 -95
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BarListSpec, ThemeConfig, DarkMode, ChartSpec, LayerSpec, GraphSpec, ElementRef, MarkEvent, Annotation, TextAnnotation, AnnotationOffset, ElementEdit, MapSpec, ChartLayout, TableSpec, SortState, SankeySpec, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
|
|
2
2
|
export * from '@opendata-ai/openchart-core';
|
|
3
|
-
import { MountOptions, ChartInstance, GraphInstance, TableInstance, TableState, TableMountOptions } from '@opendata-ai/openchart-vanilla';
|
|
3
|
+
import { MountOptions, ChartInstance, CameraFlightOptions, GraphHighlightTarget, GraphLegendData, GraphInstance, TableInstance, TableState, TableMountOptions, GraphTooltipFormatter, MapMarkEvent } from '@opendata-ai/openchart-vanilla';
|
|
4
4
|
export { JPGExportOptions, PNGExportOptions, exportCSV, exportJPG, exportPNG, exportSVG } from '@opendata-ai/openchart-vanilla';
|
|
5
5
|
export { ChartRenderer, CompileResult, CompiledGraphEdge, CompiledGraphNode, GraphCompilation, NormalizedBarListSpec, NormalizedChartSpec, NormalizedChrome, NormalizedGraphSpec, NormalizedMapSpec, NormalizedSankeySpec, NormalizedSpec, NormalizedTableSpec, SimulationConfig, ValidationError, ValidationErrorCode, ValidationResult, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileMap, compileSankey, compileTable, getChartRenderer, normalizeSpec, registerChartRenderer, validateSpec } from '@opendata-ai/openchart-engine';
|
|
6
6
|
import * as vue from 'vue';
|
|
@@ -112,6 +112,10 @@ declare const Chart: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
112
112
|
type: PropType<string[] | null>;
|
|
113
113
|
default: undefined;
|
|
114
114
|
};
|
|
115
|
+
editable: {
|
|
116
|
+
type: PropType<boolean>;
|
|
117
|
+
default: undefined;
|
|
118
|
+
};
|
|
115
119
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
116
120
|
[key: string]: any;
|
|
117
121
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
@@ -155,6 +159,10 @@ declare const Chart: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
155
159
|
type: PropType<string[] | null>;
|
|
156
160
|
default: undefined;
|
|
157
161
|
};
|
|
162
|
+
editable: {
|
|
163
|
+
type: PropType<boolean>;
|
|
164
|
+
default: undefined;
|
|
165
|
+
};
|
|
158
166
|
}>> & Readonly<{
|
|
159
167
|
onSelect?: ((_element: ElementRef) => any) | undefined;
|
|
160
168
|
"onMark-click"?: ((_event: MarkEvent) => any) | undefined;
|
|
@@ -174,6 +182,7 @@ declare const Chart: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
174
182
|
style: string | CSSProperties;
|
|
175
183
|
selectedElement: ElementRef;
|
|
176
184
|
highlight: string[] | null;
|
|
185
|
+
editable: boolean;
|
|
177
186
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
178
187
|
|
|
179
188
|
interface ChartStoryProps {
|
|
@@ -308,17 +317,48 @@ declare function useDarkMode(mode: Ref<DarkMode | undefined>): Ref<boolean>;
|
|
|
308
317
|
* useGraph: composable for imperative graph control.
|
|
309
318
|
*
|
|
310
319
|
* Provides a template ref to pass to <Graph /> and exposes graph methods
|
|
311
|
-
* (search, zoom, select) for programmatic control of the
|
|
320
|
+
* (search, zoom, select, fly, highlight) for programmatic control of the
|
|
321
|
+
* graph instance. The full vanilla GraphInstance API is threaded through.
|
|
312
322
|
*/
|
|
313
323
|
|
|
324
|
+
/** Camera transform components (graph-space). */
|
|
325
|
+
type GraphCamera = {
|
|
326
|
+
x: number;
|
|
327
|
+
y: number;
|
|
328
|
+
k: number;
|
|
329
|
+
};
|
|
314
330
|
/** Handle exposed by Graph component via expose(). */
|
|
315
331
|
interface GraphHandle {
|
|
316
332
|
search: (query: string) => void;
|
|
317
333
|
clearSearch: () => void;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
334
|
+
getSearchMatches: () => string[];
|
|
335
|
+
zoomToFit: (opts?: CameraFlightOptions & {
|
|
336
|
+
padding?: number;
|
|
337
|
+
}) => void;
|
|
338
|
+
zoomToNode: (nodeId: string, opts?: CameraFlightOptions & {
|
|
339
|
+
scale?: number;
|
|
340
|
+
}) => void;
|
|
341
|
+
flyTo: (target: {
|
|
342
|
+
x: number;
|
|
343
|
+
y: number;
|
|
344
|
+
k?: number;
|
|
345
|
+
}, opts?: CameraFlightOptions) => void;
|
|
346
|
+
centerAt: (x: number, y: number, opts?: CameraFlightOptions) => void;
|
|
347
|
+
getCamera: () => GraphCamera;
|
|
348
|
+
selectNode: (nodeId: string, opts?: {
|
|
349
|
+
fly?: boolean;
|
|
350
|
+
} & CameraFlightOptions) => void;
|
|
321
351
|
getSelectedNodes: () => string[];
|
|
352
|
+
highlight: (target: GraphHighlightTarget, opts?: {
|
|
353
|
+
dimOpacity?: number;
|
|
354
|
+
}) => void;
|
|
355
|
+
clearHighlight: () => void;
|
|
356
|
+
getHighlight: () => string[] | null;
|
|
357
|
+
getLegend: () => GraphLegendData | null;
|
|
358
|
+
setActiveCategories: (values: string[]) => void;
|
|
359
|
+
getActiveCategories: () => string[];
|
|
360
|
+
/** Re-compile encoding/legend/chrome without restarting the simulation. */
|
|
361
|
+
updateVisuals: (spec: GraphSpec) => void;
|
|
322
362
|
/** The underlying GraphInstance from the vanilla adapter. */
|
|
323
363
|
instance: GraphInstance | null;
|
|
324
364
|
}
|
|
@@ -329,14 +369,46 @@ interface UseGraphReturn {
|
|
|
329
369
|
search: (query: string) => void;
|
|
330
370
|
/** Clear the current search. */
|
|
331
371
|
clearSearch: () => void;
|
|
332
|
-
/**
|
|
333
|
-
|
|
334
|
-
/** Zoom
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
372
|
+
/** Node ids currently matching the active search query. */
|
|
373
|
+
getSearchMatches: () => string[];
|
|
374
|
+
/** Zoom to fit all nodes in view. Animated by default; `{ duration: 0 }` snaps. */
|
|
375
|
+
zoomToFit: (opts?: CameraFlightOptions & {
|
|
376
|
+
padding?: number;
|
|
377
|
+
}) => void;
|
|
378
|
+
/** Fly to a node and zoom in (default scale 2). */
|
|
379
|
+
zoomToNode: (nodeId: string, opts?: CameraFlightOptions & {
|
|
380
|
+
scale?: number;
|
|
381
|
+
}) => void;
|
|
382
|
+
/** Fly the camera to a graph-space target. */
|
|
383
|
+
flyTo: (target: {
|
|
384
|
+
x: number;
|
|
385
|
+
y: number;
|
|
386
|
+
k?: number;
|
|
387
|
+
}, opts?: CameraFlightOptions) => void;
|
|
388
|
+
/** Center the camera on a graph-space point (keeps current zoom). */
|
|
389
|
+
centerAt: (x: number, y: number, opts?: CameraFlightOptions) => void;
|
|
390
|
+
/** Current camera transform. */
|
|
391
|
+
getCamera: () => GraphCamera;
|
|
392
|
+
/** Select a node by id; `{ fly: true }` also flies to it. */
|
|
393
|
+
selectNode: (nodeId: string, opts?: {
|
|
394
|
+
fly?: boolean;
|
|
395
|
+
} & CameraFlightOptions) => void;
|
|
338
396
|
/** Get the currently selected node ids. */
|
|
339
397
|
getSelectedNodes: () => string[];
|
|
398
|
+
/** Emphasize a set of nodes; eased via the focus model. */
|
|
399
|
+
highlight: (target: GraphHighlightTarget, opts?: {
|
|
400
|
+
dimOpacity?: number;
|
|
401
|
+
}) => void;
|
|
402
|
+
/** Clear any programmatic highlight (and legend toggles). */
|
|
403
|
+
clearHighlight: () => void;
|
|
404
|
+
/** The currently highlighted node ids, or null when nothing is highlighted. */
|
|
405
|
+
getHighlight: () => string[] | null;
|
|
406
|
+
/** Headless snapshot of the legend. */
|
|
407
|
+
getLegend: () => GraphLegendData | null;
|
|
408
|
+
/** Set the active category filter declaratively (replaces legend toggle state). */
|
|
409
|
+
setActiveCategories: (values: string[]) => void;
|
|
410
|
+
/** Current active category values (empty = all active, no filter). */
|
|
411
|
+
getActiveCategories: () => string[];
|
|
340
412
|
}
|
|
341
413
|
/**
|
|
342
414
|
* Composable for imperative graph control.
|
|
@@ -540,10 +612,22 @@ declare const DataTable: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
540
612
|
page: number;
|
|
541
613
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
542
614
|
|
|
615
|
+
/** Tooltip prop: `false` off, `true` default, or an object with a formatter. */
|
|
616
|
+
type GraphTooltipProp = boolean | {
|
|
617
|
+
formatter?: GraphTooltipFormatter;
|
|
618
|
+
};
|
|
619
|
+
/** Legend prop: `false` off, `true` default, or an object toggling interactivity/counts. */
|
|
620
|
+
type GraphLegendProp = boolean | {
|
|
621
|
+
interactive?: boolean;
|
|
622
|
+
counts?: boolean;
|
|
623
|
+
};
|
|
543
624
|
interface GraphProps {
|
|
544
625
|
spec: GraphSpec;
|
|
545
626
|
theme?: ThemeConfig;
|
|
546
627
|
darkMode?: DarkMode;
|
|
628
|
+
tooltip?: GraphTooltipProp;
|
|
629
|
+
legend?: GraphLegendProp;
|
|
630
|
+
fitOnLoad?: boolean;
|
|
547
631
|
class?: string;
|
|
548
632
|
style?: string | CSSProperties;
|
|
549
633
|
}
|
|
@@ -560,6 +644,18 @@ declare const Graph: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
560
644
|
type: PropType<DarkMode>;
|
|
561
645
|
default: undefined;
|
|
562
646
|
};
|
|
647
|
+
tooltip: {
|
|
648
|
+
type: PropType<GraphTooltipProp>;
|
|
649
|
+
default: undefined;
|
|
650
|
+
};
|
|
651
|
+
legend: {
|
|
652
|
+
type: PropType<GraphLegendProp>;
|
|
653
|
+
default: undefined;
|
|
654
|
+
};
|
|
655
|
+
fitOnLoad: {
|
|
656
|
+
type: BooleanConstructor;
|
|
657
|
+
default: undefined;
|
|
658
|
+
};
|
|
563
659
|
class: {
|
|
564
660
|
type: StringConstructor;
|
|
565
661
|
default: undefined;
|
|
@@ -573,7 +669,20 @@ declare const Graph: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
573
669
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
574
670
|
'node-click': (_node: Record<string, unknown>) => true;
|
|
575
671
|
'node-double-click': (_node: Record<string, unknown>) => true;
|
|
672
|
+
'node-hover': (_node: Record<string, unknown> | null) => true;
|
|
673
|
+
'edge-hover': (_edge: Record<string, unknown> | null) => true;
|
|
576
674
|
'selection-change': (_nodeIds: string[]) => true;
|
|
675
|
+
'legend-hover': (_entry: {
|
|
676
|
+
field: string;
|
|
677
|
+
value: string;
|
|
678
|
+
} | null) => true;
|
|
679
|
+
'legend-toggle': (_activeValues: string[]) => true;
|
|
680
|
+
'highlight-change': (_nodeIds: string[] | null) => true;
|
|
681
|
+
'camera-change': (_camera: {
|
|
682
|
+
x: number;
|
|
683
|
+
y: number;
|
|
684
|
+
k: number;
|
|
685
|
+
}) => true;
|
|
577
686
|
}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
578
687
|
spec: {
|
|
579
688
|
type: PropType<GraphSpec>;
|
|
@@ -587,6 +696,18 @@ declare const Graph: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
587
696
|
type: PropType<DarkMode>;
|
|
588
697
|
default: undefined;
|
|
589
698
|
};
|
|
699
|
+
tooltip: {
|
|
700
|
+
type: PropType<GraphTooltipProp>;
|
|
701
|
+
default: undefined;
|
|
702
|
+
};
|
|
703
|
+
legend: {
|
|
704
|
+
type: PropType<GraphLegendProp>;
|
|
705
|
+
default: undefined;
|
|
706
|
+
};
|
|
707
|
+
fitOnLoad: {
|
|
708
|
+
type: BooleanConstructor;
|
|
709
|
+
default: undefined;
|
|
710
|
+
};
|
|
590
711
|
class: {
|
|
591
712
|
type: StringConstructor;
|
|
592
713
|
default: undefined;
|
|
@@ -596,22 +717,32 @@ declare const Graph: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
596
717
|
default: undefined;
|
|
597
718
|
};
|
|
598
719
|
}>> & Readonly<{
|
|
720
|
+
"onLegend-toggle"?: ((_activeValues: string[]) => any) | undefined;
|
|
599
721
|
"onNode-click"?: ((_node: Record<string, unknown>) => any) | undefined;
|
|
600
722
|
"onNode-double-click"?: ((_node: Record<string, unknown>) => any) | undefined;
|
|
723
|
+
"onNode-hover"?: ((_node: Record<string, unknown> | null) => any) | undefined;
|
|
724
|
+
"onEdge-hover"?: ((_edge: Record<string, unknown> | null) => any) | undefined;
|
|
601
725
|
"onSelection-change"?: ((_nodeIds: string[]) => any) | undefined;
|
|
726
|
+
"onLegend-hover"?: ((_entry: {
|
|
727
|
+
field: string;
|
|
728
|
+
value: string;
|
|
729
|
+
} | null) => any) | undefined;
|
|
730
|
+
"onHighlight-change"?: ((_nodeIds: string[] | null) => any) | undefined;
|
|
731
|
+
"onCamera-change"?: ((_camera: {
|
|
732
|
+
x: number;
|
|
733
|
+
y: number;
|
|
734
|
+
k: number;
|
|
735
|
+
}) => any) | undefined;
|
|
602
736
|
}>, {
|
|
603
737
|
theme: ThemeConfig;
|
|
604
738
|
darkMode: DarkMode;
|
|
605
739
|
class: string;
|
|
606
740
|
style: string | CSSProperties;
|
|
741
|
+
legend: GraphLegendProp;
|
|
742
|
+
tooltip: GraphTooltipProp;
|
|
743
|
+
fitOnLoad: boolean;
|
|
607
744
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
608
745
|
|
|
609
|
-
type MapFeatureEvent = {
|
|
610
|
-
id: string | number;
|
|
611
|
-
name?: string;
|
|
612
|
-
data: Record<string, unknown> | null;
|
|
613
|
-
};
|
|
614
|
-
|
|
615
746
|
interface MapProps {
|
|
616
747
|
spec: MapSpec;
|
|
617
748
|
theme?: ThemeConfig;
|
|
@@ -643,8 +774,8 @@ declare const GeoMap: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
643
774
|
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
644
775
|
[key: string]: any;
|
|
645
776
|
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
646
|
-
'mark-click': (_event:
|
|
647
|
-
'mark-hover': (_event:
|
|
777
|
+
'mark-click': (_event: MapMarkEvent) => true;
|
|
778
|
+
'mark-hover': (_event: MapMarkEvent | null) => true;
|
|
648
779
|
}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
649
780
|
spec: {
|
|
650
781
|
type: PropType<MapSpec>;
|
|
@@ -667,8 +798,8 @@ declare const GeoMap: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
667
798
|
default: undefined;
|
|
668
799
|
};
|
|
669
800
|
}>> & Readonly<{
|
|
670
|
-
"onMark-click"?: ((_event:
|
|
671
|
-
"onMark-hover"?: ((_event:
|
|
801
|
+
"onMark-click"?: ((_event: MapMarkEvent) => any) | undefined;
|
|
802
|
+
"onMark-hover"?: ((_event: MapMarkEvent | null) => any) | undefined;
|
|
672
803
|
}>, {
|
|
673
804
|
theme: ThemeConfig;
|
|
674
805
|
darkMode: DarkMode;
|
|
@@ -734,8 +865,8 @@ declare const Sankey: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
734
865
|
};
|
|
735
866
|
}>> & Readonly<{
|
|
736
867
|
"onNode-click"?: ((_node: Record<string, unknown>) => any) | undefined;
|
|
737
|
-
"onLink-click"?: ((_link: Record<string, unknown>) => any) | undefined;
|
|
738
868
|
"onNode-hover"?: ((_node: Record<string, unknown> | null) => any) | undefined;
|
|
869
|
+
"onLink-click"?: ((_link: Record<string, unknown>) => any) | undefined;
|
|
739
870
|
"onLink-hover"?: ((_link: Record<string, unknown> | null) => any) | undefined;
|
|
740
871
|
}>, {
|
|
741
872
|
theme: ThemeConfig;
|
package/dist/index.js
CHANGED
|
@@ -190,6 +190,10 @@ var Chart = defineComponent2({
|
|
|
190
190
|
highlight: {
|
|
191
191
|
type: [Array, null],
|
|
192
192
|
default: void 0
|
|
193
|
+
},
|
|
194
|
+
editable: {
|
|
195
|
+
type: Boolean,
|
|
196
|
+
default: void 0
|
|
193
197
|
}
|
|
194
198
|
},
|
|
195
199
|
emits: {
|
|
@@ -247,6 +251,7 @@ var Chart = defineComponent2({
|
|
|
247
251
|
...hasTextEditListener ? {
|
|
248
252
|
onTextEdit: (element, oldText, newText) => emit("text-edit", element, oldText, newText)
|
|
249
253
|
} : {},
|
|
254
|
+
...props.editable != null ? { editable: props.editable } : {},
|
|
250
255
|
...props.selectedElement ? { selectedElement: props.selectedElement } : {},
|
|
251
256
|
responsive: true
|
|
252
257
|
};
|
|
@@ -313,6 +318,7 @@ var Chart = defineComponent2({
|
|
|
313
318
|
[
|
|
314
319
|
() => props.theme,
|
|
315
320
|
() => props.darkMode,
|
|
321
|
+
() => props.editable,
|
|
316
322
|
() => contextTheme?.value,
|
|
317
323
|
() => contextDarkMode?.value
|
|
318
324
|
],
|
|
@@ -574,26 +580,66 @@ function useGraph() {
|
|
|
574
580
|
function clearSearch() {
|
|
575
581
|
graphRef.value?.clearSearch();
|
|
576
582
|
}
|
|
577
|
-
function
|
|
578
|
-
graphRef.value?.
|
|
583
|
+
function getSearchMatches() {
|
|
584
|
+
return graphRef.value?.getSearchMatches() ?? [];
|
|
585
|
+
}
|
|
586
|
+
function zoomToFit(opts) {
|
|
587
|
+
graphRef.value?.zoomToFit(opts);
|
|
588
|
+
}
|
|
589
|
+
function zoomToNode(nodeId, opts) {
|
|
590
|
+
graphRef.value?.zoomToNode(nodeId, opts);
|
|
591
|
+
}
|
|
592
|
+
function flyTo(target, opts) {
|
|
593
|
+
graphRef.value?.flyTo(target, opts);
|
|
579
594
|
}
|
|
580
|
-
function
|
|
581
|
-
graphRef.value?.
|
|
595
|
+
function centerAt(x, y, opts) {
|
|
596
|
+
graphRef.value?.centerAt(x, y, opts);
|
|
582
597
|
}
|
|
583
|
-
function
|
|
584
|
-
graphRef.value?.
|
|
598
|
+
function getCamera() {
|
|
599
|
+
return graphRef.value?.getCamera() ?? { x: 0, y: 0, k: 1 };
|
|
600
|
+
}
|
|
601
|
+
function selectNode(nodeId, opts) {
|
|
602
|
+
graphRef.value?.selectNode(nodeId, opts);
|
|
585
603
|
}
|
|
586
604
|
function getSelectedNodes() {
|
|
587
605
|
return graphRef.value?.getSelectedNodes() ?? [];
|
|
588
606
|
}
|
|
607
|
+
function highlight(target, opts) {
|
|
608
|
+
graphRef.value?.highlight(target, opts);
|
|
609
|
+
}
|
|
610
|
+
function clearHighlight() {
|
|
611
|
+
graphRef.value?.clearHighlight();
|
|
612
|
+
}
|
|
613
|
+
function getHighlight() {
|
|
614
|
+
return graphRef.value?.getHighlight() ?? null;
|
|
615
|
+
}
|
|
616
|
+
function getLegend() {
|
|
617
|
+
return graphRef.value?.getLegend() ?? null;
|
|
618
|
+
}
|
|
619
|
+
function setActiveCategories(values) {
|
|
620
|
+
graphRef.value?.setActiveCategories(values);
|
|
621
|
+
}
|
|
622
|
+
function getActiveCategories() {
|
|
623
|
+
return graphRef.value?.getActiveCategories() ?? [];
|
|
624
|
+
}
|
|
589
625
|
return {
|
|
590
626
|
graphRef,
|
|
591
627
|
search,
|
|
592
628
|
clearSearch,
|
|
629
|
+
getSearchMatches,
|
|
593
630
|
zoomToFit,
|
|
594
631
|
zoomToNode,
|
|
632
|
+
flyTo,
|
|
633
|
+
centerAt,
|
|
634
|
+
getCamera,
|
|
595
635
|
selectNode,
|
|
596
|
-
getSelectedNodes
|
|
636
|
+
getSelectedNodes,
|
|
637
|
+
highlight,
|
|
638
|
+
clearHighlight,
|
|
639
|
+
getHighlight,
|
|
640
|
+
getLegend,
|
|
641
|
+
setActiveCategories,
|
|
642
|
+
getActiveCategories
|
|
597
643
|
};
|
|
598
644
|
}
|
|
599
645
|
|
|
@@ -841,6 +887,9 @@ import {
|
|
|
841
887
|
ref as ref10,
|
|
842
888
|
watch as watch8
|
|
843
889
|
} from "vue";
|
|
890
|
+
function tooltipOn(tooltip) {
|
|
891
|
+
return tooltip !== false;
|
|
892
|
+
}
|
|
844
893
|
var Graph = defineComponent5({
|
|
845
894
|
name: "Graph",
|
|
846
895
|
props: {
|
|
@@ -856,6 +905,18 @@ var Graph = defineComponent5({
|
|
|
856
905
|
type: String,
|
|
857
906
|
default: void 0
|
|
858
907
|
},
|
|
908
|
+
tooltip: {
|
|
909
|
+
type: [Boolean, Object],
|
|
910
|
+
default: void 0
|
|
911
|
+
},
|
|
912
|
+
legend: {
|
|
913
|
+
type: [Boolean, Object],
|
|
914
|
+
default: void 0
|
|
915
|
+
},
|
|
916
|
+
fitOnLoad: {
|
|
917
|
+
type: Boolean,
|
|
918
|
+
default: void 0
|
|
919
|
+
},
|
|
859
920
|
class: {
|
|
860
921
|
type: String,
|
|
861
922
|
default: void 0
|
|
@@ -868,12 +929,19 @@ var Graph = defineComponent5({
|
|
|
868
929
|
emits: {
|
|
869
930
|
"node-click": (_node) => true,
|
|
870
931
|
"node-double-click": (_node) => true,
|
|
871
|
-
"
|
|
932
|
+
"node-hover": (_node) => true,
|
|
933
|
+
"edge-hover": (_edge) => true,
|
|
934
|
+
"selection-change": (_nodeIds) => true,
|
|
935
|
+
"legend-hover": (_entry) => true,
|
|
936
|
+
"legend-toggle": (_activeValues) => true,
|
|
937
|
+
"highlight-change": (_nodeIds) => true,
|
|
938
|
+
"camera-change": (_camera) => true
|
|
872
939
|
},
|
|
873
940
|
setup(props, { emit, expose }) {
|
|
874
941
|
const containerRef = ref10(null);
|
|
875
942
|
let instance = null;
|
|
876
943
|
let prevSpec = "";
|
|
944
|
+
let mountedOnce = false;
|
|
877
945
|
const contextTheme = inject5(VizThemeKey, void 0);
|
|
878
946
|
const contextDarkMode = inject5(VizDarkModeKey, void 0);
|
|
879
947
|
function resolveTheme() {
|
|
@@ -882,19 +950,36 @@ var Graph = defineComponent5({
|
|
|
882
950
|
function resolveDarkMode() {
|
|
883
951
|
return props.darkMode ?? contextDarkMode?.value;
|
|
884
952
|
}
|
|
953
|
+
const stableTooltipFormatter = (item, defaults) => {
|
|
954
|
+
const t = props.tooltip;
|
|
955
|
+
const fn = t && typeof t === "object" ? t.formatter : void 0;
|
|
956
|
+
return fn ? fn(item, defaults) : defaults;
|
|
957
|
+
};
|
|
885
958
|
function mountGraph() {
|
|
886
959
|
const container = containerRef.value;
|
|
887
960
|
if (!container) return;
|
|
961
|
+
const tooltipOption = tooltipOn(props.tooltip) ? { formatter: stableTooltipFormatter } : false;
|
|
888
962
|
const options = {
|
|
889
963
|
theme: resolveTheme(),
|
|
890
964
|
darkMode: resolveDarkMode(),
|
|
965
|
+
tooltip: tooltipOption,
|
|
966
|
+
legend: props.legend,
|
|
967
|
+
fitOnLoad: props.fitOnLoad,
|
|
891
968
|
onNodeClick: (node) => emit("node-click", node),
|
|
892
969
|
onNodeDoubleClick: (node) => emit("node-double-click", node),
|
|
970
|
+
onNodeHover: (node) => emit("node-hover", node),
|
|
971
|
+
onEdgeHover: (edge) => emit("edge-hover", edge),
|
|
893
972
|
onSelectionChange: (nodeIds) => emit("selection-change", nodeIds),
|
|
894
|
-
|
|
973
|
+
onLegendHover: (entry) => emit("legend-hover", entry),
|
|
974
|
+
onLegendToggle: (activeValues) => emit("legend-toggle", activeValues),
|
|
975
|
+
onHighlightChange: (nodeIds) => emit("highlight-change", nodeIds),
|
|
976
|
+
onCameraChange: (camera) => emit("camera-change", camera),
|
|
977
|
+
responsive: true,
|
|
978
|
+
suppressEntrance: mountedOnce
|
|
895
979
|
};
|
|
896
980
|
instance = createGraph(container, props.spec, options);
|
|
897
981
|
prevSpec = JSON.stringify(props.spec);
|
|
982
|
+
mountedOnce = true;
|
|
898
983
|
}
|
|
899
984
|
function destroyGraph() {
|
|
900
985
|
instance?.destroy();
|
|
@@ -908,18 +993,51 @@ var Graph = defineComponent5({
|
|
|
908
993
|
clearSearch() {
|
|
909
994
|
instance?.clearSearch();
|
|
910
995
|
},
|
|
911
|
-
|
|
912
|
-
instance?.
|
|
996
|
+
getSearchMatches() {
|
|
997
|
+
return instance?.getSearchMatches() ?? [];
|
|
998
|
+
},
|
|
999
|
+
zoomToFit(opts) {
|
|
1000
|
+
instance?.zoomToFit(opts);
|
|
1001
|
+
},
|
|
1002
|
+
zoomToNode(nodeId, opts) {
|
|
1003
|
+
instance?.zoomToNode(nodeId, opts);
|
|
1004
|
+
},
|
|
1005
|
+
flyTo(target, opts) {
|
|
1006
|
+
instance?.flyTo(target, opts);
|
|
1007
|
+
},
|
|
1008
|
+
centerAt(x, y, opts) {
|
|
1009
|
+
instance?.centerAt(x, y, opts);
|
|
913
1010
|
},
|
|
914
|
-
|
|
915
|
-
instance?.
|
|
1011
|
+
getCamera() {
|
|
1012
|
+
return instance?.getCamera() ?? { x: 0, y: 0, k: 1 };
|
|
916
1013
|
},
|
|
917
|
-
selectNode(nodeId) {
|
|
918
|
-
instance?.selectNode(nodeId);
|
|
1014
|
+
selectNode(nodeId, opts) {
|
|
1015
|
+
instance?.selectNode(nodeId, opts);
|
|
919
1016
|
},
|
|
920
1017
|
getSelectedNodes() {
|
|
921
1018
|
return instance?.getSelectedNodes() ?? [];
|
|
922
1019
|
},
|
|
1020
|
+
highlight(target, opts) {
|
|
1021
|
+
instance?.highlight(target, opts);
|
|
1022
|
+
},
|
|
1023
|
+
clearHighlight() {
|
|
1024
|
+
instance?.clearHighlight();
|
|
1025
|
+
},
|
|
1026
|
+
getHighlight() {
|
|
1027
|
+
return instance?.getHighlight() ?? null;
|
|
1028
|
+
},
|
|
1029
|
+
getLegend() {
|
|
1030
|
+
return instance?.getLegend() ?? null;
|
|
1031
|
+
},
|
|
1032
|
+
setActiveCategories(values) {
|
|
1033
|
+
instance?.setActiveCategories(values);
|
|
1034
|
+
},
|
|
1035
|
+
getActiveCategories() {
|
|
1036
|
+
return instance?.getActiveCategories() ?? [];
|
|
1037
|
+
},
|
|
1038
|
+
updateVisuals(spec) {
|
|
1039
|
+
instance?.updateVisuals(spec);
|
|
1040
|
+
},
|
|
923
1041
|
get instance() {
|
|
924
1042
|
return instance;
|
|
925
1043
|
}
|
|
@@ -966,7 +1084,9 @@ var Graph = defineComponent5({
|
|
|
966
1084
|
});
|
|
967
1085
|
|
|
968
1086
|
// src/Map.ts
|
|
969
|
-
import {
|
|
1087
|
+
import {
|
|
1088
|
+
createMap
|
|
1089
|
+
} from "@opendata-ai/openchart-vanilla";
|
|
970
1090
|
import {
|
|
971
1091
|
defineComponent as defineComponent6,
|
|
972
1092
|
h as h6,
|