@antv/gpt-vis 1.0.0-beta.1 → 1.0.0-beta.2

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.
Files changed (157) hide show
  1. package/README.md +6 -4
  2. package/README.zh-CN.md +6 -4
  3. package/dist/cjs/gpt-vis/index.d.ts +8 -1
  4. package/dist/cjs/gpt-vis/index.js +43 -20
  5. package/dist/cjs/index.d.ts +15 -2
  6. package/dist/cjs/index.js +22 -2
  7. package/dist/cjs/syntax/parser.d.ts +17 -2
  8. package/dist/cjs/syntax/parser.js +151 -38
  9. package/dist/cjs/util/container.d.ts +5 -0
  10. package/dist/cjs/util/container.js +43 -0
  11. package/dist/cjs/util/theme.d.ts +5 -0
  12. package/dist/cjs/util/theme.js +9 -2
  13. package/dist/cjs/vis/area/index.js +2 -1
  14. package/dist/cjs/vis/bar/index.js +5 -4
  15. package/dist/cjs/vis/boxplot/index.js +7 -2
  16. package/dist/cjs/vis/column/index.js +5 -4
  17. package/dist/cjs/vis/dual-axes/index.js +2 -1
  18. package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
  19. package/dist/cjs/vis/fishbone-diagram/index.js +183 -0
  20. package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
  21. package/dist/cjs/vis/flow-diagram/index.js +271 -0
  22. package/dist/cjs/vis/funnel/index.js +2 -1
  23. package/dist/cjs/vis/histogram/index.js +3 -7
  24. package/dist/cjs/vis/indented-tree/index.d.ts +40 -0
  25. package/dist/cjs/vis/indented-tree/index.js +375 -0
  26. package/dist/cjs/vis/line/index.js +2 -1
  27. package/dist/cjs/vis/liquid/index.js +2 -1
  28. package/dist/cjs/vis/mindmap/index.d.ts +32 -0
  29. package/dist/cjs/vis/mindmap/index.js +214 -0
  30. package/dist/cjs/vis/network-graph/index.d.ts +59 -0
  31. package/dist/cjs/vis/network-graph/index.js +166 -0
  32. package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
  33. package/dist/cjs/vis/organization-chart/index.js +191 -0
  34. package/dist/cjs/vis/pie/index.js +3 -3
  35. package/dist/cjs/vis/radar/index.d.ts +1 -0
  36. package/dist/cjs/vis/radar/index.js +10 -9
  37. package/dist/cjs/vis/sankey/index.js +2 -1
  38. package/dist/cjs/vis/scatter/index.js +2 -1
  39. package/dist/cjs/vis/summary/index.js +17 -3
  40. package/dist/cjs/vis/table/index.d.ts +1 -0
  41. package/dist/cjs/vis/table/index.js +37 -1
  42. package/dist/cjs/vis/treemap/index.js +2 -1
  43. package/dist/cjs/vis/venn/index.d.ts +2 -1
  44. package/dist/cjs/vis/venn/index.js +18 -3
  45. package/dist/cjs/vis/violin/index.js +2 -1
  46. package/dist/cjs/vis/waterfall/index.d.ts +6 -9
  47. package/dist/cjs/vis/waterfall/index.js +28 -5
  48. package/dist/cjs/vis/word-cloud/index.js +2 -1
  49. package/dist/cjs/vis-wrapper/icons.js +2 -2
  50. package/dist/cjs/vis-wrapper/index.d.ts +1 -0
  51. package/dist/cjs/vis-wrapper/index.js +27 -16
  52. package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
  53. package/dist/cjs/vis-wrapper/styles.js +8 -1
  54. package/dist/esm/gpt-vis/index.d.ts +8 -1
  55. package/dist/esm/gpt-vis/index.js +47 -26
  56. package/dist/esm/index.d.ts +15 -2
  57. package/dist/esm/index.js +7 -1
  58. package/dist/esm/syntax/parser.d.ts +17 -2
  59. package/dist/esm/syntax/parser.js +248 -90
  60. package/dist/esm/util/container.d.ts +5 -0
  61. package/dist/esm/util/container.js +20 -0
  62. package/dist/esm/util/theme.d.ts +5 -0
  63. package/dist/esm/util/theme.js +9 -0
  64. package/dist/esm/vis/area/index.js +3 -2
  65. package/dist/esm/vis/bar/index.js +7 -6
  66. package/dist/esm/vis/boxplot/index.js +17 -4
  67. package/dist/esm/vis/column/index.js +7 -6
  68. package/dist/esm/vis/dual-axes/index.js +3 -2
  69. package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
  70. package/dist/esm/vis/fishbone-diagram/index.js +218 -0
  71. package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
  72. package/dist/esm/vis/flow-diagram/index.js +342 -0
  73. package/dist/esm/vis/funnel/index.js +3 -2
  74. package/dist/esm/vis/histogram/index.js +6 -7
  75. package/dist/esm/vis/indented-tree/index.d.ts +40 -0
  76. package/dist/esm/vis/indented-tree/index.js +564 -0
  77. package/dist/esm/vis/line/index.js +3 -2
  78. package/dist/esm/vis/liquid/index.js +3 -2
  79. package/dist/esm/vis/mindmap/index.d.ts +32 -0
  80. package/dist/esm/vis/mindmap/index.js +315 -0
  81. package/dist/esm/vis/network-graph/index.d.ts +59 -0
  82. package/dist/esm/vis/network-graph/index.js +240 -0
  83. package/dist/esm/vis/organization-chart/index.d.ts +64 -0
  84. package/dist/esm/vis/organization-chart/index.js +269 -0
  85. package/dist/esm/vis/pie/index.js +4 -8
  86. package/dist/esm/vis/radar/index.d.ts +1 -0
  87. package/dist/esm/vis/radar/index.js +20 -4
  88. package/dist/esm/vis/sankey/index.js +3 -2
  89. package/dist/esm/vis/scatter/index.js +3 -2
  90. package/dist/esm/vis/summary/index.js +25 -4
  91. package/dist/esm/vis/table/index.d.ts +1 -0
  92. package/dist/esm/vis/table/index.js +9 -2
  93. package/dist/esm/vis/treemap/index.js +3 -2
  94. package/dist/esm/vis/venn/index.d.ts +2 -1
  95. package/dist/esm/vis/venn/index.js +29 -4
  96. package/dist/esm/vis/violin/index.js +3 -2
  97. package/dist/esm/vis/waterfall/index.d.ts +6 -9
  98. package/dist/esm/vis/waterfall/index.js +27 -9
  99. package/dist/esm/vis/word-cloud/index.js +3 -2
  100. package/dist/esm/vis-wrapper/icons.js +2 -2
  101. package/dist/esm/vis-wrapper/index.d.ts +1 -0
  102. package/dist/esm/vis-wrapper/index.js +15 -10
  103. package/dist/esm/vis-wrapper/styles.d.ts +1 -1
  104. package/dist/esm/vis-wrapper/styles.js +1 -1
  105. package/dist/umd/index.min.js +1 -1
  106. package/package.json +19 -19
  107. package/src/gpt-vis/index.ts +0 -283
  108. package/src/index.ts +0 -44
  109. package/src/readme.md +0 -37
  110. package/src/syntax/index.ts +0 -2
  111. package/src/syntax/parser.ts +0 -411
  112. package/src/types/index.ts +0 -29
  113. package/src/util/theme.ts +0 -167
  114. package/src/vis/area/README.md +0 -143
  115. package/src/vis/area/index.ts +0 -212
  116. package/src/vis/bar/README.md +0 -158
  117. package/src/vis/bar/index.ts +0 -186
  118. package/src/vis/boxplot/README.md +0 -168
  119. package/src/vis/boxplot/index.ts +0 -162
  120. package/src/vis/column/README.md +0 -158
  121. package/src/vis/column/index.ts +0 -185
  122. package/src/vis/dual-axes/README.md +0 -191
  123. package/src/vis/dual-axes/index.ts +0 -218
  124. package/src/vis/funnel/README.md +0 -143
  125. package/src/vis/funnel/index.ts +0 -238
  126. package/src/vis/histogram/README.md +0 -130
  127. package/src/vis/histogram/index.ts +0 -153
  128. package/src/vis/line/README.md +0 -138
  129. package/src/vis/line/index.ts +0 -159
  130. package/src/vis/liquid/README.md +0 -150
  131. package/src/vis/liquid/index.ts +0 -130
  132. package/src/vis/pie/README.md +0 -127
  133. package/src/vis/pie/index.ts +0 -163
  134. package/src/vis/radar/README.md +0 -184
  135. package/src/vis/radar/index.ts +0 -214
  136. package/src/vis/sankey/README.md +0 -144
  137. package/src/vis/sankey/index.ts +0 -144
  138. package/src/vis/scatter/README.md +0 -145
  139. package/src/vis/scatter/index.ts +0 -147
  140. package/src/vis/summary/README.md +0 -272
  141. package/src/vis/summary/index.ts +0 -91
  142. package/src/vis/table/README.md +0 -174
  143. package/src/vis/table/index.ts +0 -241
  144. package/src/vis/treemap/README.md +0 -199
  145. package/src/vis/treemap/index.ts +0 -167
  146. package/src/vis/venn/README.md +0 -153
  147. package/src/vis/venn/index.ts +0 -149
  148. package/src/vis/violin/README.md +0 -168
  149. package/src/vis/violin/index.ts +0 -216
  150. package/src/vis/waterfall/README.md +0 -178
  151. package/src/vis/waterfall/index.ts +0 -258
  152. package/src/vis/word-cloud/README.md +0 -137
  153. package/src/vis/word-cloud/index.ts +0 -137
  154. package/src/vis-wrapper/README.md +0 -159
  155. package/src/vis-wrapper/icons.ts +0 -35
  156. package/src/vis-wrapper/index.ts +0 -276
  157. package/src/vis-wrapper/styles.ts +0 -195
@@ -0,0 +1,59 @@
1
+ import type { GraphData, VisualizationOptions } from '../../types';
2
+ export type NetworkGraphNode = GraphData['nodes'][number];
3
+ export type NetworkGraphEdge = GraphData['edges'][number];
4
+ export type NetworkGraphData = GraphData;
5
+ /**
6
+ * NetworkGraphConfig defines the configuration for rendering the network graph.
7
+ */
8
+ export interface NetworkGraphConfig {
9
+ type?: 'network-graph';
10
+ data: NetworkGraphData;
11
+ layout?: 'force' | 'circular' | 'grid' | 'radial' | 'concentric' | 'dagre';
12
+ theme?: 'default' | 'academy' | 'dark';
13
+ title?: string;
14
+ style?: {
15
+ backgroundColor?: string;
16
+ palette?: string[];
17
+ };
18
+ }
19
+ /**
20
+ * NetworkGraphInstance represents a network graph instance with render and destroy methods.
21
+ */
22
+ export interface NetworkGraphInstance {
23
+ render: (config: NetworkGraphConfig) => void;
24
+ destroy: () => void;
25
+ zoomTo: (zoom: number) => void;
26
+ getZoom: () => number | undefined;
27
+ }
28
+ /**
29
+ * NetworkGraph component using G6 5.0.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const graph = NetworkGraph({
34
+ * container: '#container',
35
+ * width: 600,
36
+ * height: 400,
37
+ * });
38
+ *
39
+ * graph.render({
40
+ * type: 'network-graph',
41
+ * data: {
42
+ * nodes: [
43
+ * { name: '哈利·波特' },
44
+ * { name: '赫敏·格兰杰' },
45
+ * { name: '伏地魔' },
46
+ * ],
47
+ * edges: [
48
+ * { source: '哈利·波特', target: '赫敏·格兰杰', name: '朋友' },
49
+ * { source: '哈利·波特', target: '伏地魔', name: '敌人' },
50
+ * ],
51
+ * },
52
+ * layout: 'force',
53
+ * theme: 'academy',
54
+ * });
55
+ *
56
+ * graph.destroy();
57
+ * ```
58
+ */
59
+ export declare const NetworkGraph: (options: VisualizationOptions) => NetworkGraphInstance;
@@ -0,0 +1,166 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/vis/network-graph/index.ts
20
+ var network_graph_exports = {};
21
+ __export(network_graph_exports, {
22
+ NetworkGraph: () => NetworkGraph
23
+ });
24
+ module.exports = __toCommonJS(network_graph_exports);
25
+ var import_g6 = require("@antv/g6");
26
+ var import_theme = require("../../util/theme");
27
+ var NetworkGraph = (options) => {
28
+ const { container, width, height, theme: chartTheme = "default" } = options;
29
+ let graph = null;
30
+ const render = (config) => {
31
+ const {
32
+ data = { nodes: [], edges: [] },
33
+ layout = "force",
34
+ theme = chartTheme,
35
+ title,
36
+ style = {}
37
+ } = config;
38
+ const { nodes = [], edges = [] } = data;
39
+ if (graph) {
40
+ graph.destroy();
41
+ graph = null;
42
+ }
43
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
44
+ const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
45
+ const isDark = theme === "dark";
46
+ const containerEl = typeof container === "string" ? document.querySelector(container) : container;
47
+ if (!containerEl) {
48
+ throw new Error("NetworkGraph: container element not found");
49
+ }
50
+ containerEl.innerHTML = "";
51
+ containerEl.style.background = backgroundColor;
52
+ containerEl.style.borderRadius = "4px";
53
+ containerEl.style.overflow = "hidden";
54
+ const nodeData = nodes.map((node, index) => ({
55
+ id: node.name,
56
+ data: { label: node.name },
57
+ style: {
58
+ fill: colors[index % colors.length],
59
+ stroke: isDark ? "#444" : "#fff",
60
+ lineWidth: 2,
61
+ labelText: node.name,
62
+ labelFill: isDark ? "#e0e0e0" : "#333",
63
+ labelFontSize: 12,
64
+ size: 28
65
+ }
66
+ }));
67
+ const edgeData = edges.map((edge) => ({
68
+ source: edge.source,
69
+ target: edge.target,
70
+ data: { label: edge.name ?? "" },
71
+ style: {
72
+ stroke: isDark ? "#555" : "#ccc",
73
+ lineWidth: 1.5,
74
+ endArrow: true,
75
+ labelText: edge.name ?? "",
76
+ labelFill: isDark ? "#aaa" : "#666",
77
+ labelFontSize: 11,
78
+ labelBackground: !!edge.name,
79
+ labelBackgroundFill: backgroundColor,
80
+ labelBackgroundOpacity: 0.8
81
+ }
82
+ }));
83
+ const layoutConfig = {
84
+ force: {
85
+ type: "force",
86
+ preventOverlap: true,
87
+ nodeSize: 32,
88
+ linkDistance: 150,
89
+ gravity: 10
90
+ },
91
+ circular: {
92
+ type: "circular"
93
+ },
94
+ grid: {
95
+ type: "grid",
96
+ rows: Math.max(1, Math.ceil(Math.sqrt(nodes.length)))
97
+ },
98
+ radial: {
99
+ type: "radial",
100
+ preventOverlap: true,
101
+ nodeSize: 32
102
+ },
103
+ concentric: {
104
+ type: "concentric",
105
+ preventOverlap: true,
106
+ nodeSize: 32
107
+ },
108
+ dagre: {
109
+ type: "dagre",
110
+ rankdir: "TB",
111
+ nodesep: 50,
112
+ ranksep: 80
113
+ }
114
+ };
115
+ graph = new import_g6.Graph({
116
+ animation: false,
117
+ container: containerEl,
118
+ width,
119
+ height,
120
+ autoFit: "view",
121
+ autoResize: true,
122
+ padding: 24,
123
+ data: {
124
+ nodes: nodeData,
125
+ edges: edgeData
126
+ },
127
+ layout: layoutConfig[layout] || layoutConfig.force,
128
+ node: {
129
+ style: {
130
+ labelPlacement: "bottom",
131
+ labelMaxWidth: 100
132
+ }
133
+ },
134
+ behaviors: ["drag-canvas", "drag-element", "click-select"],
135
+ plugins: title ? [{ key: "title", type: "title", title, titleFill: isDark ? "#e0e6ed" : "#1a1a2e" }] : []
136
+ });
137
+ graph.render();
138
+ };
139
+ const destroy = () => {
140
+ if (graph) {
141
+ graph.destroy();
142
+ graph = null;
143
+ }
144
+ };
145
+ const zoomTo = (zoom) => {
146
+ if (graph) {
147
+ graph.zoomTo(zoom);
148
+ }
149
+ };
150
+ const getZoom = () => {
151
+ if (graph) {
152
+ return graph.getZoom();
153
+ }
154
+ return 1;
155
+ };
156
+ return {
157
+ render,
158
+ destroy,
159
+ zoomTo,
160
+ getZoom
161
+ };
162
+ };
163
+ // Annotate the CommonJS export names for ESM import in node:
164
+ 0 && (module.exports = {
165
+ NetworkGraph
166
+ });
@@ -0,0 +1,64 @@
1
+ import type { TreeGraphData, VisualizationOptions } from '../../types';
2
+ export type OrganizationChartData = TreeGraphData;
3
+ /**
4
+ * OrganizationChartConfig defines the configuration for rendering the organization chart.
5
+ */
6
+ export interface OrganizationChartConfig {
7
+ type?: 'organization-chart';
8
+ data: OrganizationChartData;
9
+ theme?: 'default' | 'academy' | 'dark';
10
+ title?: string;
11
+ style?: {
12
+ backgroundColor?: string;
13
+ palette?: string[];
14
+ };
15
+ }
16
+ /**
17
+ * OrganizationChartInstance represents a chart instance with render and destroy methods.
18
+ */
19
+ export interface OrganizationChartInstance {
20
+ render: (config: OrganizationChartConfig) => void;
21
+ destroy: () => void;
22
+ zoomTo: (zoom: number) => void;
23
+ getZoom: () => number | undefined;
24
+ }
25
+ /**
26
+ * OrganizationChart component using G6 5.0.
27
+ * - dagre (TB) layout for hierarchical structure
28
+ * - custom rect node with name + description labels
29
+ * - depth-based color cycling
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const chart = OrganizationChart({ container: '#container', width: 600, height: 400 });
34
+ *
35
+ * chart.render({
36
+ * type: 'organization-chart',
37
+ * data: {
38
+ * name: 'Alice Johnson',
39
+ * description: 'Chief Technology Officer',
40
+ * children: [
41
+ * {
42
+ * name: 'Bob Smith',
43
+ * description: 'Senior Software Engineer',
44
+ * children: [
45
+ * { name: 'Charlie Brown', description: 'Software Engineer' },
46
+ * { name: 'Diana White', description: 'Software Engineer' },
47
+ * ],
48
+ * },
49
+ * {
50
+ * name: 'Eve Black',
51
+ * description: 'IT Support Department Head',
52
+ * children: [
53
+ * { name: 'Frank Green', description: 'IT Support Specialist' },
54
+ * { name: 'Grace Blue', description: 'IT Support Specialist' },
55
+ * ],
56
+ * },
57
+ * ],
58
+ * },
59
+ * });
60
+ *
61
+ * chart.destroy();
62
+ * ```
63
+ */
64
+ export declare const OrganizationChart: (options: VisualizationOptions) => OrganizationChartInstance;
@@ -0,0 +1,191 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/vis/organization-chart/index.ts
20
+ var organization_chart_exports = {};
21
+ __export(organization_chart_exports, {
22
+ OrganizationChart: () => OrganizationChart
23
+ });
24
+ module.exports = __toCommonJS(organization_chart_exports);
25
+ var import_g6 = require("@antv/g6");
26
+ var import_theme = require("../../util/theme");
27
+ var NODE_WIDTH = 160;
28
+ var NODE_HEIGHT_WITH_DESC = 72;
29
+ var NODE_HEIGHT_NO_DESC = 40;
30
+ var FONT_FAMILY = "system-ui,-apple-system,BlinkMacSystemFont,sans-serif";
31
+ var LABEL_MAX_WIDTH = NODE_WIDTH - 16;
32
+ function flattenTree(node, depth, pathId, nodes, edges) {
33
+ nodes.push({ id: pathId, name: node.name, description: node.description, depth });
34
+ (node.children ?? []).forEach((child, index) => {
35
+ const childId = `${pathId}_${index}`;
36
+ edges.push({ source: pathId, target: childId });
37
+ flattenTree(child, depth + 1, childId, nodes, edges);
38
+ });
39
+ }
40
+ var OrganizationChart = (options) => {
41
+ const { container, width, height, theme: chartTheme = "default" } = options;
42
+ let graph = null;
43
+ const render = (config) => {
44
+ const { data, theme = chartTheme, title, style = {} } = config;
45
+ if (!data || !data.name) {
46
+ throw new Error("OrganizationChart: data with a name field is required");
47
+ }
48
+ if (graph) {
49
+ graph.destroy();
50
+ graph = null;
51
+ }
52
+ const containerEl = typeof container === "string" ? document.querySelector(container) : container;
53
+ if (!containerEl) {
54
+ throw new Error("OrganizationChart: container element not found");
55
+ }
56
+ containerEl.innerHTML = "";
57
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
58
+ const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
59
+ const isDark = theme === "dark";
60
+ containerEl.style.background = backgroundColor;
61
+ containerEl.style.borderRadius = "4px";
62
+ containerEl.style.overflow = "hidden";
63
+ const flatNodes = [];
64
+ const flatEdges = [];
65
+ flattenTree(data, 0, "0", flatNodes, flatEdges);
66
+ const nodeData = flatNodes.map((node) => ({
67
+ id: node.id,
68
+ data: {
69
+ name: node.name,
70
+ description: node.description,
71
+ depth: node.depth
72
+ }
73
+ }));
74
+ const edgeData = flatEdges.map((edge) => ({
75
+ id: `e__${edge.source}__${edge.target}`,
76
+ source: edge.source,
77
+ target: edge.target
78
+ }));
79
+ graph = new import_g6.Graph({
80
+ animation: false,
81
+ container: containerEl,
82
+ width,
83
+ height,
84
+ autoFit: "view",
85
+ autoResize: true,
86
+ padding: 24,
87
+ data: { nodes: nodeData, edges: edgeData },
88
+ plugins: [
89
+ {
90
+ type: "tooltip",
91
+ trigger: "hover",
92
+ enable: (e) => (e == null ? void 0 : e.targetType) === "node",
93
+ offset: [10, 10],
94
+ getContent: (e, items) => {
95
+ const item = items == null ? void 0 : items[0];
96
+ const biz = item == null ? void 0 : item.data;
97
+ if (!biz)
98
+ return "";
99
+ const name = escapeHtml(String(biz.name ?? ""));
100
+ const desc = biz.description ? escapeHtml(String(biz.description)) : "";
101
+ return `
102
+ <div style="max-width:260px;font-family:${FONT_FAMILY};">
103
+ <div style="font-weight:700;font-size:12px;line-height:1.2;margin-bottom:${desc ? "4px" : "0"};">
104
+ ${name}
105
+ </div>
106
+ ${desc ? `<div style="font-size:12px;line-height:1.35;opacity:${isDark ? "0.86" : "0.78"};">${desc}</div>` : ""}
107
+ </div>
108
+ `;
109
+ },
110
+ style: {
111
+ ".tooltip": {
112
+ background: isDark ? "rgba(20,20,20,0.92)" : "rgba(255,255,255,0.96)",
113
+ color: isDark ? "#f2f2f2" : "#1f1f1f",
114
+ border: `1px solid ${isDark ? "rgba(255,255,255,0.12)" : "rgba(0,0,0,0.10)"}`,
115
+ borderRadius: 8,
116
+ boxShadow: "0 12px 28px rgba(0,0,0,0.16)",
117
+ padding: "8px 10px",
118
+ pointerEvents: "none"
119
+ }
120
+ }
121
+ },
122
+ ...title ? [{ key: "title", type: "title", title, titleFill: isDark ? "#e0e6ed" : "#1a1a2e" }] : []
123
+ ],
124
+ node: {
125
+ type: "rect",
126
+ style: {
127
+ // size: [width, height] is the correct API for rect nodes in G6 v5
128
+ size: (d) => [
129
+ NODE_WIDTH,
130
+ d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC
131
+ ],
132
+ fill: (d) => colors[d.data.depth % colors.length],
133
+ stroke: isDark ? "#555" : "#e8ebf0",
134
+ lineWidth: 1,
135
+ radius: 8,
136
+ // Use official label wrapping/ellipsis for BOTH name & description.
137
+ // 1 line name + up to 2 lines description => total maxLines = 3.
138
+ labelText: (d) => d.data.description ? `${d.data.name}
139
+ ${d.data.description}` : d.data.name,
140
+ labelFill: "#ffffff",
141
+ labelFontSize: 12,
142
+ labelFontWeight: 600,
143
+ labelWordWrap: true,
144
+ labelWordWrapWidth: LABEL_MAX_WIDTH,
145
+ labelMaxLines: (d) => d.data.description ? 3 : 1,
146
+ labelLineHeight: 14,
147
+ labelPlacement: "center"
148
+ }
149
+ },
150
+ edge: {
151
+ // Use a tree-friendly edge type that does not depend on node ports.
152
+ type: "cubic-vertical",
153
+ style: {
154
+ stroke: isDark ? "#4a4a4a" : "#d0d7e0",
155
+ lineWidth: 1.5,
156
+ endArrow: false,
157
+ startArrow: false
158
+ }
159
+ },
160
+ layout: {
161
+ type: "dagre",
162
+ rankdir: "TB",
163
+ nodesep: 40,
164
+ ranksep: 60,
165
+ // Dynamic nodeSize lets dagre calculate accurate per-node spacing
166
+ nodeSize: (d) => [NODE_WIDTH, d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC]
167
+ },
168
+ behaviors: ["drag-canvas"]
169
+ });
170
+ graph.render();
171
+ };
172
+ const destroy = () => {
173
+ if (graph) {
174
+ graph.destroy();
175
+ graph = null;
176
+ }
177
+ };
178
+ return {
179
+ render,
180
+ destroy,
181
+ zoomTo: (zoom) => graph == null ? void 0 : graph.zoomTo(zoom),
182
+ getZoom: () => graph == null ? void 0 : graph.getZoom()
183
+ };
184
+ };
185
+ function escapeHtml(input) {
186
+ return String(input).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#039;");
187
+ }
188
+ // Annotate the CommonJS export names for ESM import in node:
189
+ 0 && (module.exports = {
190
+ OrganizationChart
191
+ });
@@ -33,7 +33,7 @@ var Pie = (options) => {
33
33
  if (chart) {
34
34
  chart.destroy();
35
35
  }
36
- const colors = style.palette || (0, import_theme.getThemeColors)(theme);
36
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
37
37
  const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
38
38
  const sumValue = data.reduce((sum, item) => sum + item.value, 0);
39
39
  chart = new import_g2.Chart({
@@ -43,6 +43,7 @@ var Pie = (options) => {
43
43
  autoFit: true
44
44
  });
45
45
  const chartOptions = {
46
+ animate: false,
46
47
  type: "interval",
47
48
  data,
48
49
  title: title ?? "",
@@ -85,8 +86,7 @@ var Pie = (options) => {
85
86
  viewStyle: {
86
87
  viewFill: backgroundColor
87
88
  },
88
- theme: (0, import_theme.getThemeObject)(theme),
89
- animate: { enter: { type: "waveIn" } }
89
+ theme: (0, import_theme.getThemeObject)(theme)
90
90
  };
91
91
  chart.options(chartOptions);
92
92
  chart.render();
@@ -14,6 +14,7 @@ export interface RadarConfig {
14
14
  type?: 'radar';
15
15
  data: RadarDataItem[];
16
16
  title?: string;
17
+ align?: boolean;
17
18
  theme?: 'default' | 'academy' | 'dark';
18
19
  style?: {
19
20
  backgroundColor?: string;
@@ -51,12 +51,12 @@ var Radar = (options) => {
51
51
  const { container, width, height, theme: chartTheme = "default" } = options;
52
52
  let chart = null;
53
53
  const render = (config) => {
54
- const { data = [], theme = chartTheme, title, style = {} } = config;
54
+ const { data = [], theme = chartTheme, title, align = false, style = {} } = config;
55
55
  if (chart) {
56
56
  chart.destroy();
57
57
  }
58
58
  const { lineWidth = 2 } = style;
59
- const colors = style.palette || (0, import_theme.getThemeColors)(theme);
59
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
60
60
  const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
61
61
  const parallelData = transformRadarToParallel(data);
62
62
  const position = Object.keys(parallelData[0] || {}).filter((key) => key !== "group");
@@ -67,6 +67,7 @@ var Radar = (options) => {
67
67
  autoFit: true
68
68
  });
69
69
  const chartOptions = {
70
+ animate: false,
70
71
  type: "line",
71
72
  data: parallelData,
72
73
  title: title ?? "",
@@ -77,15 +78,15 @@ var Radar = (options) => {
77
78
  color: "group"
78
79
  },
79
80
  scale: {
80
- // Configure scales for each position axis
81
81
  ...Object.fromEntries(
82
- Array.from({ length: position.length }, (_, i) => [
83
- `position${i === 0 ? "" : i}`,
84
- {
85
- domainMin: 0,
86
- nice: true
82
+ Array.from({ length: position.length }, (_, i) => {
83
+ const scaleConfig = { domainMin: 0, nice: true };
84
+ if (align) {
85
+ const allValues = data.map((d) => d.value).filter((v) => v != null);
86
+ scaleConfig.domainMax = Math.max(...allValues);
87
87
  }
88
- ])
88
+ return [`position${i === 0 ? "" : i}`, scaleConfig];
89
+ })
89
90
  ),
90
91
  color: {
91
92
  range: colors
@@ -32,7 +32,7 @@ var Sankey = (options) => {
32
32
  if (chart) {
33
33
  chart.destroy();
34
34
  }
35
- const colors = style.palette || (0, import_theme.getThemeColors)(theme);
35
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
36
36
  const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
37
37
  chart = new import_g2.Chart({
38
38
  container,
@@ -41,6 +41,7 @@ var Sankey = (options) => {
41
41
  autoFit: true
42
42
  });
43
43
  const chartOptions = {
44
+ animate: false,
44
45
  type: "sankey",
45
46
  data: {
46
47
  value: data,
@@ -33,7 +33,7 @@ var Scatter = (options) => {
33
33
  if (chart) {
34
34
  chart.destroy();
35
35
  }
36
- const colors = style.palette || (0, import_theme.getThemeColors)(theme);
36
+ const colors = (0, import_theme.normalizePalette)(style.palette, theme);
37
37
  const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
38
38
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
39
39
  chart = new import_g2.Chart({
@@ -53,6 +53,7 @@ var Scatter = (options) => {
53
53
  encode = { x: "x", y: "y", color: () => "all" };
54
54
  }
55
55
  const chartOptions = {
56
+ animate: false,
56
57
  type: "point",
57
58
  data,
58
59
  title: title ?? "",
@@ -23,6 +23,7 @@ __export(summary_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(summary_exports);
25
25
  var import_t8 = require("@antv/t8");
26
+ var import_theme = require("../../util/theme");
26
27
  var Summary = (options) => {
27
28
  let { theme = "light" } = options;
28
29
  if (theme === "academy" || theme === "default")
@@ -31,20 +32,33 @@ var Summary = (options) => {
31
32
  if (!container) {
32
33
  throw new Error("Container not found");
33
34
  }
35
+ const wrapper = document.createElement("div");
36
+ wrapper.className = "gpt-vis-summary";
37
+ container.appendChild(wrapper);
34
38
  let text = null;
35
39
  const render = (syntax) => {
36
40
  if (text) {
37
41
  text.unmount();
38
42
  }
39
- text = new import_t8.Text(container);
40
- text.theme(theme);
41
- text.render(syntax);
43
+ let activeTheme = theme;
44
+ const cleanedSyntax = syntax.replace(/^theme\s+(light|dark)\s*$/im, (_, t) => {
45
+ activeTheme = t;
46
+ return "";
47
+ });
48
+ text = new import_t8.Text(wrapper);
49
+ wrapper.style.backgroundColor = activeTheme === "dark" ? (0, import_theme.getBackgroundColor)("dark") : "";
50
+ wrapper.style.padding = "16px";
51
+ text.theme(activeTheme);
52
+ text.render(cleanedSyntax.trim());
42
53
  };
43
54
  const destroy = () => {
44
55
  if (text) {
45
56
  text.unmount();
46
57
  text = null;
47
58
  }
59
+ if (wrapper.parentNode) {
60
+ wrapper.parentNode.removeChild(wrapper);
61
+ }
48
62
  };
49
63
  return {
50
64
  render,
@@ -6,6 +6,7 @@ export interface TableConfig {
6
6
  type?: 'table';
7
7
  data: Record<string, any>[];
8
8
  title?: string;
9
+ theme?: 'default' | 'dark';
9
10
  }
10
11
  /**
11
12
  * TableInstance represents a table instance with render and destroy methods.