@opendata-ai/openchart-vue 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/index.js CHANGED
@@ -1,15 +1,23 @@
1
1
  // src/index.ts
2
2
  export * from "@opendata-ai/openchart-core";
3
- import { exportCSV, exportJPG, exportPNG, exportSVG } from "@opendata-ai/openchart-vanilla";
3
+ import {
4
+ exportCSV,
5
+ exportJPG,
6
+ exportPNG,
7
+ exportSpecSequence,
8
+ exportSVG,
9
+ exportSVGWithFonts
10
+ } from "@opendata-ai/openchart-vanilla";
4
11
  import {
5
12
  clearRenderers,
6
13
  compile,
7
14
  compileBarList,
8
15
  compileChart,
16
+ compileGeoMap,
9
17
  compileGraph,
10
- compileMap,
11
18
  compileSankey,
12
19
  compileTable,
20
+ compileTileMap,
13
21
  getChartRenderer,
14
22
  normalizeSpec,
15
23
  registerChartRenderer,
@@ -175,6 +183,10 @@ var Chart = defineComponent2({
175
183
  type: String,
176
184
  default: void 0
177
185
  },
186
+ renderer: {
187
+ type: String,
188
+ default: void 0
189
+ },
178
190
  class: {
179
191
  type: String,
180
192
  default: void 0
@@ -190,6 +202,10 @@ var Chart = defineComponent2({
190
202
  highlight: {
191
203
  type: [Array, null],
192
204
  default: void 0
205
+ },
206
+ editable: {
207
+ type: Boolean,
208
+ default: void 0
193
209
  }
194
210
  },
195
211
  emits: {
@@ -230,6 +246,7 @@ var Chart = defineComponent2({
230
246
  const options = {
231
247
  theme: resolveTheme(),
232
248
  darkMode: resolveDarkMode(),
249
+ renderer: props.renderer,
233
250
  onDataPointClick: (data) => emit("data-point-click", data),
234
251
  onMarkClick: (event) => emit("mark-click", event),
235
252
  onMarkHover: (event) => emit("mark-hover", event),
@@ -247,6 +264,7 @@ var Chart = defineComponent2({
247
264
  ...hasTextEditListener ? {
248
265
  onTextEdit: (element, oldText, newText) => emit("text-edit", element, oldText, newText)
249
266
  } : {},
267
+ ...props.editable != null ? { editable: props.editable } : {},
250
268
  ...props.selectedElement ? { selectedElement: props.selectedElement } : {},
251
269
  responsive: true
252
270
  };
@@ -313,6 +331,8 @@ var Chart = defineComponent2({
313
331
  [
314
332
  () => props.theme,
315
333
  () => props.darkMode,
334
+ () => props.renderer,
335
+ () => props.editable,
316
336
  () => contextTheme?.value,
317
337
  () => contextDarkMode?.value
318
338
  ],
@@ -491,7 +511,8 @@ function useChart(spec, options) {
491
511
  theme: options?.theme,
492
512
  darkMode: options?.darkMode,
493
513
  onDataPointClick: options?.onDataPointClick,
494
- responsive: options?.responsive
514
+ responsive: options?.responsive,
515
+ renderer: options?.renderer
495
516
  };
496
517
  const instance = createChart2(container, spec.value, mountOpts);
497
518
  chart.value = instance;
@@ -574,26 +595,66 @@ function useGraph() {
574
595
  function clearSearch() {
575
596
  graphRef.value?.clearSearch();
576
597
  }
577
- function zoomToFit() {
578
- graphRef.value?.zoomToFit();
598
+ function getSearchMatches() {
599
+ return graphRef.value?.getSearchMatches() ?? [];
600
+ }
601
+ function zoomToFit(opts) {
602
+ graphRef.value?.zoomToFit(opts);
579
603
  }
580
- function zoomToNode(nodeId) {
581
- graphRef.value?.zoomToNode(nodeId);
604
+ function zoomToNode(nodeId, opts) {
605
+ graphRef.value?.zoomToNode(nodeId, opts);
582
606
  }
583
- function selectNode(nodeId) {
584
- graphRef.value?.selectNode(nodeId);
607
+ function flyTo(target, opts) {
608
+ graphRef.value?.flyTo(target, opts);
609
+ }
610
+ function centerAt(x, y, opts) {
611
+ graphRef.value?.centerAt(x, y, opts);
612
+ }
613
+ function getCamera() {
614
+ return graphRef.value?.getCamera() ?? { x: 0, y: 0, k: 1 };
615
+ }
616
+ function selectNode(nodeId, opts) {
617
+ graphRef.value?.selectNode(nodeId, opts);
585
618
  }
586
619
  function getSelectedNodes() {
587
620
  return graphRef.value?.getSelectedNodes() ?? [];
588
621
  }
622
+ function highlight(target, opts) {
623
+ graphRef.value?.highlight(target, opts);
624
+ }
625
+ function clearHighlight() {
626
+ graphRef.value?.clearHighlight();
627
+ }
628
+ function getHighlight() {
629
+ return graphRef.value?.getHighlight() ?? null;
630
+ }
631
+ function getLegend() {
632
+ return graphRef.value?.getLegend() ?? null;
633
+ }
634
+ function setActiveCategories(values) {
635
+ graphRef.value?.setActiveCategories(values);
636
+ }
637
+ function getActiveCategories() {
638
+ return graphRef.value?.getActiveCategories() ?? [];
639
+ }
589
640
  return {
590
641
  graphRef,
591
642
  search,
592
643
  clearSearch,
644
+ getSearchMatches,
593
645
  zoomToFit,
594
646
  zoomToNode,
647
+ flyTo,
648
+ centerAt,
649
+ getCamera,
595
650
  selectNode,
596
- getSelectedNodes
651
+ getSelectedNodes,
652
+ highlight,
653
+ clearHighlight,
654
+ getHighlight,
655
+ getLegend,
656
+ setActiveCategories,
657
+ getActiveCategories
597
658
  };
598
659
  }
599
660
 
@@ -828,9 +889,9 @@ var DataTable = defineComponent4({
828
889
  }
829
890
  });
830
891
 
831
- // src/Graph.ts
892
+ // src/GeoMap.ts
832
893
  import {
833
- createGraph
894
+ createGeoMap
834
895
  } from "@opendata-ai/openchart-vanilla";
835
896
  import {
836
897
  defineComponent as defineComponent5,
@@ -841,8 +902,8 @@ import {
841
902
  ref as ref10,
842
903
  watch as watch8
843
904
  } from "vue";
844
- var Graph = defineComponent5({
845
- name: "Graph",
905
+ var GeoMap = defineComponent5({
906
+ name: "GeoMap",
846
907
  props: {
847
908
  spec: {
848
909
  type: Object,
@@ -866,9 +927,8 @@ var Graph = defineComponent5({
866
927
  }
867
928
  },
868
929
  emits: {
869
- "node-click": (_node) => true,
870
- "node-double-click": (_node) => true,
871
- "selection-change": (_nodeIds) => true
930
+ "mark-click": (_event) => true,
931
+ "mark-hover": (_event) => true
872
932
  },
873
933
  setup(props, { emit, expose }) {
874
934
  const containerRef = ref10(null);
@@ -882,53 +942,34 @@ var Graph = defineComponent5({
882
942
  function resolveDarkMode() {
883
943
  return props.darkMode ?? contextDarkMode?.value;
884
944
  }
885
- function mountGraph() {
945
+ function mountMap() {
886
946
  const container = containerRef.value;
887
947
  if (!container) return;
888
948
  const options = {
889
949
  theme: resolveTheme(),
890
950
  darkMode: resolveDarkMode(),
891
- onNodeClick: (node) => emit("node-click", node),
892
- onNodeDoubleClick: (node) => emit("node-double-click", node),
893
- onSelectionChange: (nodeIds) => emit("selection-change", nodeIds),
951
+ onMarkClick: (feature) => emit("mark-click", feature),
952
+ onMarkHover: (feature) => emit("mark-hover", feature),
894
953
  responsive: true
895
954
  };
896
- instance = createGraph(container, props.spec, options);
955
+ instance = createGeoMap(container, props.spec, options);
897
956
  prevSpec = JSON.stringify(props.spec);
898
957
  }
899
- function destroyGraph() {
958
+ function destroyMap() {
900
959
  instance?.destroy();
901
960
  instance = null;
902
961
  prevSpec = "";
903
962
  }
904
963
  expose({
905
- search(query) {
906
- instance?.search(query);
907
- },
908
- clearSearch() {
909
- instance?.clearSearch();
910
- },
911
- zoomToFit() {
912
- instance?.zoomToFit();
913
- },
914
- zoomToNode(nodeId) {
915
- instance?.zoomToNode(nodeId);
916
- },
917
- selectNode(nodeId) {
918
- instance?.selectNode(nodeId);
919
- },
920
- getSelectedNodes() {
921
- return instance?.getSelectedNodes() ?? [];
922
- },
923
964
  get instance() {
924
965
  return instance;
925
966
  }
926
967
  });
927
968
  onMounted7(() => {
928
- mountGraph();
969
+ mountMap();
929
970
  });
930
971
  onUnmounted8(() => {
931
- destroyGraph();
972
+ destroyMap();
932
973
  });
933
974
  watch8(
934
975
  () => JSON.stringify(props.spec),
@@ -949,12 +990,12 @@ var Graph = defineComponent5({
949
990
  ],
950
991
  () => {
951
992
  if (!containerRef.value) return;
952
- destroyGraph();
953
- mountGraph();
993
+ destroyMap();
994
+ mountMap();
954
995
  }
955
996
  );
956
997
  const rootClass = () => {
957
- const base = "oc-graph-root";
998
+ const base = "oc-map-root";
958
999
  return props.class ? `${base} ${props.class}` : base;
959
1000
  };
960
1001
  return () => h5("div", {
@@ -965,9 +1006,9 @@ var Graph = defineComponent5({
965
1006
  }
966
1007
  });
967
1008
 
968
- // src/Map.ts
1009
+ // src/Graph.ts
969
1010
  import {
970
- createMap
1011
+ createGraph
971
1012
  } from "@opendata-ai/openchart-vanilla";
972
1013
  import {
973
1014
  defineComponent as defineComponent6,
@@ -978,8 +1019,11 @@ import {
978
1019
  ref as ref11,
979
1020
  watch as watch9
980
1021
  } from "vue";
981
- var GeoMap = defineComponent6({
982
- name: "GeoMap",
1022
+ function tooltipOn(tooltip) {
1023
+ return tooltip !== false;
1024
+ }
1025
+ var Graph = defineComponent6({
1026
+ name: "Graph",
983
1027
  props: {
984
1028
  spec: {
985
1029
  type: Object,
@@ -993,6 +1037,18 @@ var GeoMap = defineComponent6({
993
1037
  type: String,
994
1038
  default: void 0
995
1039
  },
1040
+ tooltip: {
1041
+ type: [Boolean, Object],
1042
+ default: void 0
1043
+ },
1044
+ legend: {
1045
+ type: [Boolean, Object],
1046
+ default: void 0
1047
+ },
1048
+ fitOnLoad: {
1049
+ type: Boolean,
1050
+ default: void 0
1051
+ },
996
1052
  class: {
997
1053
  type: String,
998
1054
  default: void 0
@@ -1003,13 +1059,21 @@ var GeoMap = defineComponent6({
1003
1059
  }
1004
1060
  },
1005
1061
  emits: {
1006
- "mark-click": (_event) => true,
1007
- "mark-hover": (_event) => true
1062
+ "node-click": (_node) => true,
1063
+ "node-double-click": (_node) => true,
1064
+ "node-hover": (_node) => true,
1065
+ "edge-hover": (_edge) => true,
1066
+ "selection-change": (_nodeIds) => true,
1067
+ "legend-hover": (_entry) => true,
1068
+ "legend-toggle": (_activeValues) => true,
1069
+ "highlight-change": (_nodeIds) => true,
1070
+ "camera-change": (_camera) => true
1008
1071
  },
1009
1072
  setup(props, { emit, expose }) {
1010
1073
  const containerRef = ref11(null);
1011
1074
  let instance = null;
1012
1075
  let prevSpec = "";
1076
+ let mountedOnce = false;
1013
1077
  const contextTheme = inject6(VizThemeKey, void 0);
1014
1078
  const contextDarkMode = inject6(VizDarkModeKey, void 0);
1015
1079
  function resolveTheme() {
@@ -1018,34 +1082,103 @@ var GeoMap = defineComponent6({
1018
1082
  function resolveDarkMode() {
1019
1083
  return props.darkMode ?? contextDarkMode?.value;
1020
1084
  }
1021
- function mountMap() {
1085
+ const stableTooltipFormatter = (item, defaults) => {
1086
+ const t = props.tooltip;
1087
+ const fn = t && typeof t === "object" ? t.formatter : void 0;
1088
+ return fn ? fn(item, defaults) : defaults;
1089
+ };
1090
+ function mountGraph() {
1022
1091
  const container = containerRef.value;
1023
1092
  if (!container) return;
1093
+ const tooltipOption = tooltipOn(props.tooltip) ? { formatter: stableTooltipFormatter } : false;
1024
1094
  const options = {
1025
1095
  theme: resolveTheme(),
1026
1096
  darkMode: resolveDarkMode(),
1027
- onMarkClick: (feature) => emit("mark-click", feature),
1028
- onMarkHover: (feature) => emit("mark-hover", feature),
1029
- responsive: true
1097
+ tooltip: tooltipOption,
1098
+ legend: props.legend,
1099
+ fitOnLoad: props.fitOnLoad,
1100
+ onNodeClick: (node) => emit("node-click", node),
1101
+ onNodeDoubleClick: (node) => emit("node-double-click", node),
1102
+ onNodeHover: (node) => emit("node-hover", node),
1103
+ onEdgeHover: (edge) => emit("edge-hover", edge),
1104
+ onSelectionChange: (nodeIds) => emit("selection-change", nodeIds),
1105
+ onLegendHover: (entry) => emit("legend-hover", entry),
1106
+ onLegendToggle: (activeValues) => emit("legend-toggle", activeValues),
1107
+ onHighlightChange: (nodeIds) => emit("highlight-change", nodeIds),
1108
+ onCameraChange: (camera) => emit("camera-change", camera),
1109
+ responsive: true,
1110
+ suppressEntrance: mountedOnce
1030
1111
  };
1031
- instance = createMap(container, props.spec, options);
1112
+ instance = createGraph(container, props.spec, options);
1032
1113
  prevSpec = JSON.stringify(props.spec);
1114
+ mountedOnce = true;
1033
1115
  }
1034
- function destroyMap() {
1116
+ function destroyGraph() {
1035
1117
  instance?.destroy();
1036
1118
  instance = null;
1037
1119
  prevSpec = "";
1038
1120
  }
1039
1121
  expose({
1122
+ search(query) {
1123
+ instance?.search(query);
1124
+ },
1125
+ clearSearch() {
1126
+ instance?.clearSearch();
1127
+ },
1128
+ getSearchMatches() {
1129
+ return instance?.getSearchMatches() ?? [];
1130
+ },
1131
+ zoomToFit(opts) {
1132
+ instance?.zoomToFit(opts);
1133
+ },
1134
+ zoomToNode(nodeId, opts) {
1135
+ instance?.zoomToNode(nodeId, opts);
1136
+ },
1137
+ flyTo(target, opts) {
1138
+ instance?.flyTo(target, opts);
1139
+ },
1140
+ centerAt(x, y, opts) {
1141
+ instance?.centerAt(x, y, opts);
1142
+ },
1143
+ getCamera() {
1144
+ return instance?.getCamera() ?? { x: 0, y: 0, k: 1 };
1145
+ },
1146
+ selectNode(nodeId, opts) {
1147
+ instance?.selectNode(nodeId, opts);
1148
+ },
1149
+ getSelectedNodes() {
1150
+ return instance?.getSelectedNodes() ?? [];
1151
+ },
1152
+ highlight(target, opts) {
1153
+ instance?.highlight(target, opts);
1154
+ },
1155
+ clearHighlight() {
1156
+ instance?.clearHighlight();
1157
+ },
1158
+ getHighlight() {
1159
+ return instance?.getHighlight() ?? null;
1160
+ },
1161
+ getLegend() {
1162
+ return instance?.getLegend() ?? null;
1163
+ },
1164
+ setActiveCategories(values) {
1165
+ instance?.setActiveCategories(values);
1166
+ },
1167
+ getActiveCategories() {
1168
+ return instance?.getActiveCategories() ?? [];
1169
+ },
1170
+ updateVisuals(spec) {
1171
+ instance?.updateVisuals(spec);
1172
+ },
1040
1173
  get instance() {
1041
1174
  return instance;
1042
1175
  }
1043
1176
  });
1044
1177
  onMounted8(() => {
1045
- mountMap();
1178
+ mountGraph();
1046
1179
  });
1047
1180
  onUnmounted9(() => {
1048
- destroyMap();
1181
+ destroyGraph();
1049
1182
  });
1050
1183
  watch9(
1051
1184
  () => JSON.stringify(props.spec),
@@ -1066,12 +1199,12 @@ var GeoMap = defineComponent6({
1066
1199
  ],
1067
1200
  () => {
1068
1201
  if (!containerRef.value) return;
1069
- destroyMap();
1070
- mountMap();
1202
+ destroyGraph();
1203
+ mountGraph();
1071
1204
  }
1072
1205
  );
1073
1206
  const rootClass = () => {
1074
- const base = "oc-map-root";
1207
+ const base = "oc-graph-root";
1075
1208
  return props.class ? `${base} ${props.class}` : base;
1076
1209
  };
1077
1210
  return () => h6("div", {
@@ -1346,8 +1479,8 @@ var TileMap = defineComponent9({
1346
1479
  // src/Visualization.ts
1347
1480
  import {
1348
1481
  isBarListSpec,
1482
+ isGeoMapSpec,
1349
1483
  isGraphSpec,
1350
- isMapSpec,
1351
1484
  isSankeySpec,
1352
1485
  isTableSpec,
1353
1486
  isTileMapSpec
@@ -1396,7 +1529,7 @@ var Visualization = defineComponent10({
1396
1529
  if (isBarListSpec(spec)) {
1397
1530
  return h9(BarList, { ...sharedProps, spec });
1398
1531
  }
1399
- if (isMapSpec(spec)) {
1532
+ if (isGeoMapSpec(spec)) {
1400
1533
  return h9(GeoMap, { ...sharedProps, spec });
1401
1534
  }
1402
1535
  return h9(Chart, { ...sharedProps, spec });
@@ -1420,14 +1553,17 @@ export {
1420
1553
  compile,
1421
1554
  compileBarList,
1422
1555
  compileChart,
1556
+ compileGeoMap,
1423
1557
  compileGraph,
1424
- compileMap,
1425
1558
  compileSankey,
1426
1559
  compileTable,
1560
+ compileTileMap,
1427
1561
  exportCSV,
1428
1562
  exportJPG,
1429
1563
  exportPNG,
1430
1564
  exportSVG,
1565
+ exportSVGWithFonts,
1566
+ exportSpecSequence,
1431
1567
  getChartRenderer,
1432
1568
  normalizeSpec,
1433
1569
  registerChartRenderer,