@antv/gpt-vis 1.0.0-beta.1 → 1.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.
Files changed (159) hide show
  1. package/README.md +223 -47
  2. package/README.zh-CN.md +227 -51
  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 +3 -3
  18. package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
  19. package/dist/cjs/vis/fishbone-diagram/index.js +191 -0
  20. package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
  21. package/dist/cjs/vis/flow-diagram/index.js +287 -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 +385 -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 +222 -0
  30. package/dist/cjs/vis/network-graph/index.d.ts +59 -0
  31. package/dist/cjs/vis/network-graph/index.js +175 -0
  32. package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
  33. package/dist/cjs/vis/organization-chart/index.js +200 -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.d.ts +2 -0
  39. package/dist/cjs/vis/scatter/index.js +9 -4
  40. package/dist/cjs/vis/summary/index.js +17 -3
  41. package/dist/cjs/vis/table/index.d.ts +1 -0
  42. package/dist/cjs/vis/table/index.js +37 -1
  43. package/dist/cjs/vis/treemap/index.js +2 -1
  44. package/dist/cjs/vis/venn/index.d.ts +2 -1
  45. package/dist/cjs/vis/venn/index.js +18 -3
  46. package/dist/cjs/vis/violin/index.js +2 -1
  47. package/dist/cjs/vis/waterfall/index.d.ts +6 -9
  48. package/dist/cjs/vis/waterfall/index.js +29 -6
  49. package/dist/cjs/vis/word-cloud/index.js +2 -1
  50. package/dist/cjs/vis-wrapper/icons.js +2 -2
  51. package/dist/cjs/vis-wrapper/index.d.ts +1 -0
  52. package/dist/cjs/vis-wrapper/index.js +27 -16
  53. package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
  54. package/dist/cjs/vis-wrapper/styles.js +8 -1
  55. package/dist/esm/gpt-vis/index.d.ts +8 -1
  56. package/dist/esm/gpt-vis/index.js +47 -26
  57. package/dist/esm/index.d.ts +15 -2
  58. package/dist/esm/index.js +7 -1
  59. package/dist/esm/syntax/parser.d.ts +17 -2
  60. package/dist/esm/syntax/parser.js +248 -90
  61. package/dist/esm/util/container.d.ts +5 -0
  62. package/dist/esm/util/container.js +20 -0
  63. package/dist/esm/util/theme.d.ts +5 -0
  64. package/dist/esm/util/theme.js +9 -0
  65. package/dist/esm/vis/area/index.js +3 -2
  66. package/dist/esm/vis/bar/index.js +7 -6
  67. package/dist/esm/vis/boxplot/index.js +17 -4
  68. package/dist/esm/vis/column/index.js +7 -6
  69. package/dist/esm/vis/dual-axes/index.js +13 -5
  70. package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
  71. package/dist/esm/vis/fishbone-diagram/index.js +219 -0
  72. package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
  73. package/dist/esm/vis/flow-diagram/index.js +349 -0
  74. package/dist/esm/vis/funnel/index.js +3 -2
  75. package/dist/esm/vis/histogram/index.js +6 -7
  76. package/dist/esm/vis/indented-tree/index.d.ts +40 -0
  77. package/dist/esm/vis/indented-tree/index.js +569 -0
  78. package/dist/esm/vis/line/index.js +3 -2
  79. package/dist/esm/vis/liquid/index.js +3 -2
  80. package/dist/esm/vis/mindmap/index.d.ts +32 -0
  81. package/dist/esm/vis/mindmap/index.js +316 -0
  82. package/dist/esm/vis/network-graph/index.d.ts +59 -0
  83. package/dist/esm/vis/network-graph/index.js +242 -0
  84. package/dist/esm/vis/organization-chart/index.d.ts +64 -0
  85. package/dist/esm/vis/organization-chart/index.js +271 -0
  86. package/dist/esm/vis/pie/index.js +4 -8
  87. package/dist/esm/vis/radar/index.d.ts +1 -0
  88. package/dist/esm/vis/radar/index.js +20 -4
  89. package/dist/esm/vis/sankey/index.js +3 -2
  90. package/dist/esm/vis/scatter/index.d.ts +2 -0
  91. package/dist/esm/vis/scatter/index.js +15 -4
  92. package/dist/esm/vis/summary/index.js +25 -4
  93. package/dist/esm/vis/table/index.d.ts +1 -0
  94. package/dist/esm/vis/table/index.js +9 -2
  95. package/dist/esm/vis/treemap/index.js +3 -2
  96. package/dist/esm/vis/venn/index.d.ts +2 -1
  97. package/dist/esm/vis/venn/index.js +29 -4
  98. package/dist/esm/vis/violin/index.js +3 -2
  99. package/dist/esm/vis/waterfall/index.d.ts +6 -9
  100. package/dist/esm/vis/waterfall/index.js +33 -13
  101. package/dist/esm/vis/word-cloud/index.js +3 -2
  102. package/dist/esm/vis-wrapper/icons.js +2 -2
  103. package/dist/esm/vis-wrapper/index.d.ts +1 -0
  104. package/dist/esm/vis-wrapper/index.js +15 -10
  105. package/dist/esm/vis-wrapper/styles.d.ts +1 -1
  106. package/dist/esm/vis-wrapper/styles.js +1 -1
  107. package/dist/umd/index.min.js +1 -1
  108. package/package.json +17 -21
  109. package/src/gpt-vis/index.ts +0 -283
  110. package/src/index.ts +0 -44
  111. package/src/readme.md +0 -37
  112. package/src/syntax/index.ts +0 -2
  113. package/src/syntax/parser.ts +0 -411
  114. package/src/types/index.ts +0 -29
  115. package/src/util/theme.ts +0 -167
  116. package/src/vis/area/README.md +0 -143
  117. package/src/vis/area/index.ts +0 -212
  118. package/src/vis/bar/README.md +0 -158
  119. package/src/vis/bar/index.ts +0 -186
  120. package/src/vis/boxplot/README.md +0 -168
  121. package/src/vis/boxplot/index.ts +0 -162
  122. package/src/vis/column/README.md +0 -158
  123. package/src/vis/column/index.ts +0 -185
  124. package/src/vis/dual-axes/README.md +0 -191
  125. package/src/vis/dual-axes/index.ts +0 -218
  126. package/src/vis/funnel/README.md +0 -143
  127. package/src/vis/funnel/index.ts +0 -238
  128. package/src/vis/histogram/README.md +0 -130
  129. package/src/vis/histogram/index.ts +0 -153
  130. package/src/vis/line/README.md +0 -138
  131. package/src/vis/line/index.ts +0 -159
  132. package/src/vis/liquid/README.md +0 -150
  133. package/src/vis/liquid/index.ts +0 -130
  134. package/src/vis/pie/README.md +0 -127
  135. package/src/vis/pie/index.ts +0 -163
  136. package/src/vis/radar/README.md +0 -184
  137. package/src/vis/radar/index.ts +0 -214
  138. package/src/vis/sankey/README.md +0 -144
  139. package/src/vis/sankey/index.ts +0 -144
  140. package/src/vis/scatter/README.md +0 -145
  141. package/src/vis/scatter/index.ts +0 -147
  142. package/src/vis/summary/README.md +0 -272
  143. package/src/vis/summary/index.ts +0 -91
  144. package/src/vis/table/README.md +0 -174
  145. package/src/vis/table/index.ts +0 -241
  146. package/src/vis/treemap/README.md +0 -199
  147. package/src/vis/treemap/index.ts +0 -167
  148. package/src/vis/venn/README.md +0 -153
  149. package/src/vis/venn/index.ts +0 -149
  150. package/src/vis/violin/README.md +0 -168
  151. package/src/vis/violin/index.ts +0 -216
  152. package/src/vis/waterfall/README.md +0 -178
  153. package/src/vis/waterfall/index.ts +0 -258
  154. package/src/vis/word-cloud/README.md +0 -137
  155. package/src/vis/word-cloud/index.ts +0 -137
  156. package/src/vis-wrapper/README.md +0 -159
  157. package/src/vis-wrapper/icons.ts +0 -35
  158. package/src/vis-wrapper/index.ts +0 -276
  159. package/src/vis-wrapper/styles.ts +0 -195
@@ -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,271 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ import { Graph } from '@antv/g6';
8
+ import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
9
+
10
+ /**
11
+ * OrganizationChartConfig defines the configuration for rendering the organization chart.
12
+ */
13
+
14
+ /**
15
+ * OrganizationChartInstance represents a chart instance with render and destroy methods.
16
+ */
17
+
18
+ var NODE_WIDTH = 160;
19
+ // Keep stable layout height when description exists.
20
+ var NODE_HEIGHT_WITH_DESC = 72;
21
+ var NODE_HEIGHT_NO_DESC = 40;
22
+ var FONT_FAMILY = 'system-ui,-apple-system,BlinkMacSystemFont,sans-serif';
23
+ var LABEL_MAX_WIDTH = NODE_WIDTH - 16; // padding
24
+
25
+ /** Business data stored in each G6 node's `data` field. */
26
+
27
+ /** Shorthand for the G6 node style callback argument shape. */
28
+
29
+ /**
30
+ * Recursively flatten a tree into flat nodes and edges arrays for G6.
31
+ * Uses path-index IDs instead of names to prevent duplicate-name collisions.
32
+ */
33
+ function flattenTree(node, depth, pathId, nodes, edges) {
34
+ var _node$children;
35
+ nodes.push({
36
+ id: pathId,
37
+ name: node.name,
38
+ description: node.description,
39
+ depth: depth
40
+ });
41
+ ((_node$children = node.children) !== null && _node$children !== void 0 ? _node$children : []).forEach(function (child, index) {
42
+ // Use an underscore separator to avoid ambiguity with auto-generated edge IDs.
43
+ // Some render/layout internals may derive edge IDs by concatenating source/target with "-",
44
+ // and using "-" inside node IDs can lead to collisions in rare cases.
45
+ var childId = "".concat(pathId, "_").concat(index);
46
+ edges.push({
47
+ source: pathId,
48
+ target: childId
49
+ });
50
+ flattenTree(child, depth + 1, childId, nodes, edges);
51
+ });
52
+ }
53
+
54
+ /**
55
+ * OrganizationChart component using G6 5.0.
56
+ * - dagre (TB) layout for hierarchical structure
57
+ * - custom rect node with name + description labels
58
+ * - depth-based color cycling
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const chart = OrganizationChart({ container: '#container', width: 600, height: 400 });
63
+ *
64
+ * chart.render({
65
+ * type: 'organization-chart',
66
+ * data: {
67
+ * name: 'Alice Johnson',
68
+ * description: 'Chief Technology Officer',
69
+ * children: [
70
+ * {
71
+ * name: 'Bob Smith',
72
+ * description: 'Senior Software Engineer',
73
+ * children: [
74
+ * { name: 'Charlie Brown', description: 'Software Engineer' },
75
+ * { name: 'Diana White', description: 'Software Engineer' },
76
+ * ],
77
+ * },
78
+ * {
79
+ * name: 'Eve Black',
80
+ * description: 'IT Support Department Head',
81
+ * children: [
82
+ * { name: 'Frank Green', description: 'IT Support Specialist' },
83
+ * { name: 'Grace Blue', description: 'IT Support Specialist' },
84
+ * ],
85
+ * },
86
+ * ],
87
+ * },
88
+ * });
89
+ *
90
+ * chart.destroy();
91
+ * ```
92
+ */
93
+ export var OrganizationChart = function OrganizationChart(options) {
94
+ var container = options.container,
95
+ width = options.width,
96
+ height = options.height,
97
+ _options$theme = options.theme,
98
+ chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
99
+ var graph = null;
100
+ var render = function render(config) {
101
+ var data = config.data,
102
+ _config$theme = config.theme,
103
+ theme = _config$theme === void 0 ? chartTheme : _config$theme,
104
+ title = config.title,
105
+ _config$style = config.style,
106
+ style = _config$style === void 0 ? {} : _config$style;
107
+ if (!data || !data.name) {
108
+ throw new Error('OrganizationChart: data with a name field is required');
109
+ }
110
+ if (graph) {
111
+ graph.destroy();
112
+ graph = null;
113
+ }
114
+ var containerEl = typeof container === 'string' ? document.querySelector(container) : container;
115
+ if (!containerEl) {
116
+ throw new Error('OrganizationChart: container element not found');
117
+ }
118
+ containerEl.innerHTML = '';
119
+ var colors = normalizePalette(style.palette, theme);
120
+ var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
121
+ var isDark = theme === 'dark';
122
+ containerEl.style.background = backgroundColor;
123
+ containerEl.style.borderRadius = '4px';
124
+ containerEl.style.overflow = 'hidden';
125
+
126
+ // Flatten tree structure into G6 flat nodes + edges
127
+ var flatNodes = [];
128
+ var flatEdges = [];
129
+ flattenTree(data, 0, '0', flatNodes, flatEdges);
130
+
131
+ // Store node business data in the `data` field so style functions can access it via d.data.*
132
+ var nodeData = flatNodes.map(function (node) {
133
+ return {
134
+ id: node.id,
135
+ data: {
136
+ name: node.name,
137
+ description: node.description,
138
+ depth: node.depth
139
+ }
140
+ };
141
+ });
142
+ var edgeData = flatEdges.map(function (edge) {
143
+ return {
144
+ id: "e__".concat(edge.source, "__").concat(edge.target),
145
+ source: edge.source,
146
+ target: edge.target
147
+ };
148
+ });
149
+ graph = new Graph({
150
+ animation: false,
151
+ container: containerEl,
152
+ width: width,
153
+ height: height,
154
+ autoFit: 'view',
155
+ autoResize: true,
156
+ theme: getTheme(theme),
157
+ padding: title ? [46, 20, 20, 20] : 20,
158
+ data: {
159
+ nodes: nodeData,
160
+ edges: edgeData
161
+ },
162
+ plugins: [{
163
+ type: 'tooltip',
164
+ trigger: 'hover',
165
+ enable: function enable(e) {
166
+ return (e === null || e === void 0 ? void 0 : e.targetType) === 'node';
167
+ },
168
+ offset: [10, 10],
169
+ getContent: function getContent(e, items) {
170
+ var _biz$name;
171
+ var item = items === null || items === void 0 ? void 0 : items[0];
172
+ var biz = item === null || item === void 0 ? void 0 : item.data;
173
+ if (!biz) return '';
174
+ var name = escapeHtml(String((_biz$name = biz.name) !== null && _biz$name !== void 0 ? _biz$name : ''));
175
+ var desc = biz.description ? escapeHtml(String(biz.description)) : '';
176
+ return "\n <div style=\"max-width:260px;font-family:".concat(FONT_FAMILY, ";\">\n <div style=\"font-weight:700;font-size:12px;line-height:1.2;margin-bottom:").concat(desc ? '4px' : '0', ";\">\n ").concat(name, "\n </div>\n ").concat(desc ? "<div style=\"font-size:12px;line-height:1.35;opacity:".concat(isDark ? '0.86' : '0.78', ";\">").concat(desc, "</div>") : '', "\n </div>\n ");
177
+ },
178
+ style: {
179
+ '.tooltip': {
180
+ background: isDark ? 'rgba(20,20,20,0.92)' : 'rgba(255,255,255,0.96)',
181
+ color: isDark ? '#f2f2f2' : '#1f1f1f',
182
+ border: "1px solid ".concat(isDark ? 'rgba(255,255,255,0.12)' : 'rgba(0,0,0,0.10)'),
183
+ borderRadius: 8,
184
+ boxShadow: '0 12px 28px rgba(0,0,0,0.16)',
185
+ padding: '8px 10px',
186
+ pointerEvents: 'none'
187
+ }
188
+ }
189
+ }].concat(_toConsumableArray(title ? [{
190
+ key: 'title',
191
+ type: 'title',
192
+ title: title,
193
+ titleFill: isDark ? '#e0e6ed' : '#000',
194
+ titleFontFamily: 'sans-serif'
195
+ }] : [])),
196
+ node: {
197
+ type: 'rect',
198
+ style: {
199
+ // size: [width, height] is the correct API for rect nodes in G6 v5
200
+ size: function size(d) {
201
+ return [NODE_WIDTH, d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC];
202
+ },
203
+ fill: function fill(d) {
204
+ return colors[d.data.depth % colors.length];
205
+ },
206
+ stroke: isDark ? '#555' : '#e8ebf0',
207
+ lineWidth: 1,
208
+ radius: theme === 'academy' ? 0 : 8,
209
+ // Use official label wrapping/ellipsis for BOTH name & description.
210
+ // 1 line name + up to 2 lines description => total maxLines = 3.
211
+ labelText: function labelText(d) {
212
+ return d.data.description ? "".concat(d.data.name, "\n").concat(d.data.description) : d.data.name;
213
+ },
214
+ labelFill: '#ffffff',
215
+ labelFontSize: 12,
216
+ labelFontWeight: 600,
217
+ labelWordWrap: true,
218
+ labelWordWrapWidth: LABEL_MAX_WIDTH,
219
+ labelMaxLines: function labelMaxLines(d) {
220
+ return d.data.description ? 3 : 1;
221
+ },
222
+ labelLineHeight: 14,
223
+ labelPlacement: 'center'
224
+ }
225
+ },
226
+ edge: {
227
+ // Use a tree-friendly edge type that does not depend on node ports.
228
+ type: 'cubic-vertical',
229
+ style: {
230
+ stroke: isDark ? '#4a4a4a' : '#d0d7e0',
231
+ lineWidth: 1.5,
232
+ endArrow: false,
233
+ startArrow: false
234
+ }
235
+ },
236
+ layout: {
237
+ type: 'dagre',
238
+ rankdir: 'TB',
239
+ nodesep: 40,
240
+ ranksep: 60,
241
+ // Dynamic nodeSize lets dagre calculate accurate per-node spacing
242
+ nodeSize: function nodeSize(d) {
243
+ return [NODE_WIDTH, d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC];
244
+ }
245
+ },
246
+ behaviors: ['drag-canvas']
247
+ });
248
+ graph.render();
249
+ };
250
+ var destroy = function destroy() {
251
+ if (graph) {
252
+ graph.destroy();
253
+ graph = null;
254
+ }
255
+ };
256
+ return {
257
+ render: render,
258
+ destroy: destroy,
259
+ zoomTo: function zoomTo(zoom) {
260
+ var _graph;
261
+ return (_graph = graph) === null || _graph === void 0 ? void 0 : _graph.zoomTo(zoom);
262
+ },
263
+ getZoom: function getZoom() {
264
+ var _graph2;
265
+ return (_graph2 = graph) === null || _graph2 === void 0 ? void 0 : _graph2.getZoom();
266
+ }
267
+ };
268
+ };
269
+ function escapeHtml(input) {
270
+ return String(input).replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&#039;');
271
+ }
@@ -1,5 +1,5 @@
1
1
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
2
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
3
3
 
4
4
  /**
5
5
  * PieDataItem is the type for each data item in the pie chart.
@@ -68,7 +68,7 @@ export var Pie = function Pie(options) {
68
68
  }
69
69
 
70
70
  // Get colors from style.palette or theme defaults
71
- var colors = style.palette || getThemeColors(theme);
71
+ var colors = normalizePalette(style.palette, theme);
72
72
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
73
73
 
74
74
  // Calculate sum for percentage labels
@@ -88,6 +88,7 @@ export var Pie = function Pie(options) {
88
88
  // Note: Using 'any' type due to G2's complex type system with transformations
89
89
  // This is consistent with how G2 5.0 is used elsewhere in the codebase (e.g., Radar component)
90
90
  var chartOptions = {
91
+ animate: false,
91
92
  type: 'interval',
92
93
  data: data,
93
94
  title: title !== null && title !== void 0 ? title : '',
@@ -141,12 +142,7 @@ export var Pie = function Pie(options) {
141
142
  viewStyle: {
142
143
  viewFill: backgroundColor
143
144
  },
144
- theme: getThemeObject(theme),
145
- animate: {
146
- enter: {
147
- type: 'waveIn'
148
- }
149
- }
145
+ theme: getThemeObject(theme)
150
146
  };
151
147
  chart.options(chartOptions);
152
148
  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;
@@ -1,4 +1,8 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
2
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
8
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -11,7 +15,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
15
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
17
  import { Chart } from '@antv/g2';
14
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
18
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
15
19
 
16
20
  /**
17
21
  * RadarDataItem is the type for each data item in the radar chart.
@@ -104,6 +108,8 @@ export var Radar = function Radar(options) {
104
108
  _config$theme = config.theme,
105
109
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
106
110
  title = config.title,
111
+ _config$align = config.align,
112
+ align = _config$align === void 0 ? false : _config$align,
107
113
  _config$style = config.style,
108
114
  style = _config$style === void 0 ? {} : _config$style;
109
115
 
@@ -113,7 +119,7 @@ export var Radar = function Radar(options) {
113
119
  }
114
120
  var _style$lineWidth = style.lineWidth,
115
121
  lineWidth = _style$lineWidth === void 0 ? 2 : _style$lineWidth;
116
- var colors = style.palette || getThemeColors(theme);
122
+ var colors = normalizePalette(style.palette, theme);
117
123
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
118
124
 
119
125
  // Transform data to parallel format
@@ -134,6 +140,7 @@ export var Radar = function Radar(options) {
134
140
  // Note: Using 'any' type due to G2's complex type system with transformations
135
141
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
136
142
  var chartOptions = {
143
+ animate: false,
137
144
  type: 'line',
138
145
  data: parallelData,
139
146
  title: title !== null && title !== void 0 ? title : '',
@@ -148,10 +155,19 @@ export var Radar = function Radar(options) {
148
155
  scale: _objectSpread(_objectSpread({}, Object.fromEntries(Array.from({
149
156
  length: position.length
150
157
  }, function (_, i) {
151
- return ["position".concat(i === 0 ? '' : i), {
158
+ var scaleConfig = {
152
159
  domainMin: 0,
153
160
  nice: true
154
- }];
161
+ };
162
+ if (align) {
163
+ var allValues = data.map(function (d) {
164
+ return d.value;
165
+ }).filter(function (v) {
166
+ return v != null;
167
+ });
168
+ scaleConfig.domainMax = Math.max.apply(Math, _toConsumableArray(allValues));
169
+ }
170
+ return ["position".concat(i === 0 ? '' : i), scaleConfig];
155
171
  }))), {}, {
156
172
  color: {
157
173
  range: colors
@@ -1,5 +1,5 @@
1
1
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
2
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
3
3
 
4
4
  /**
5
5
  * SankeyDataItem is the type for each data item in the sankey chart.
@@ -66,7 +66,7 @@ export var Sankey = function Sankey(options) {
66
66
  }
67
67
 
68
68
  // Get colors from style.palette or theme defaults
69
- var colors = style.palette || getThemeColors(theme);
69
+ var colors = normalizePalette(style.palette, theme);
70
70
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
71
71
 
72
72
  // Create chart
@@ -81,6 +81,7 @@ export var Sankey = function Sankey(options) {
81
81
  // Note: Using 'any' type due to G2's complex type system with transformations
82
82
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
83
83
  var chartOptions = {
84
+ animate: false,
84
85
  type: 'sankey',
85
86
  data: {
86
87
  value: data,
@@ -14,6 +14,8 @@ export interface ScatterConfig {
14
14
  type?: 'scatter';
15
15
  data: ScatterDataItem[];
16
16
  title?: string;
17
+ axisXTitle?: string;
18
+ axisYTitle?: string;
17
19
  theme?: 'default' | 'academy' | 'dark';
18
20
  style?: {
19
21
  backgroundColor?: string;
@@ -1,5 +1,5 @@
1
1
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
2
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
3
3
 
4
4
  /**
5
5
  * ScatterDataItem is the type for each data item in the scatter chart.
@@ -55,6 +55,8 @@ export var Scatter = function Scatter(options) {
55
55
  _config$theme = config.theme,
56
56
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
57
57
  title = config.title,
58
+ axisXTitle = config.axisXTitle,
59
+ axisYTitle = config.axisYTitle,
58
60
  _config$style = config.style,
59
61
  style = _config$style === void 0 ? {} : _config$style;
60
62
 
@@ -64,7 +66,7 @@ export var Scatter = function Scatter(options) {
64
66
  }
65
67
 
66
68
  // Get colors from style.palette or theme defaults
67
- var colors = style.palette || getThemeColors(theme);
69
+ var colors = normalizePalette(style.palette, theme);
68
70
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
69
71
 
70
72
  // Check if data has group field
@@ -108,6 +110,7 @@ export var Scatter = function Scatter(options) {
108
110
  // Note: Using 'any' type due to G2's complex type system with transformations
109
111
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
110
112
  var chartOptions = {
113
+ animate: false,
111
114
  type: 'point',
112
115
  data: data,
113
116
  title: title !== null && title !== void 0 ? title : '',
@@ -118,6 +121,14 @@ export var Scatter = function Scatter(options) {
118
121
  }
119
122
  } : false,
120
123
  scale: scaleConfig,
124
+ axis: {
125
+ x: {
126
+ title: axisXTitle !== null && axisXTitle !== void 0 ? axisXTitle : 'x'
127
+ },
128
+ y: {
129
+ title: axisYTitle !== null && axisYTitle !== void 0 ? axisYTitle : 'y'
130
+ }
131
+ },
121
132
  style: {
122
133
  lineWidth: 1
123
134
  },
@@ -127,10 +138,10 @@ export var Scatter = function Scatter(options) {
127
138
  },
128
139
  items: [{
129
140
  channel: 'x',
130
- name: 'x'
141
+ name: axisXTitle !== null && axisXTitle !== void 0 ? axisXTitle : 'x'
131
142
  }, {
132
143
  channel: 'y',
133
- name: 'y'
144
+ name: axisYTitle !== null && axisYTitle !== void 0 ? axisYTitle : 'y'
134
145
  }]
135
146
  },
136
147
  viewStyle: {
@@ -1,4 +1,5 @@
1
1
  import { Text } from '@antv/t8';
2
+ import { getBackgroundColor } from "../../util/theme";
2
3
 
3
4
  /**
4
5
  * SummaryConfig is a T8 Syntax string for narrative text visualization.
@@ -37,7 +38,7 @@ import { Text } from '@antv/t8';
37
38
  * ```
38
39
  */
39
40
  export var Summary = function Summary(options) {
40
- // T8 only supports 'light' and 'dark', so map 'academy' to 'light'
41
+ // T8 only supports 'light' and 'dark', so map 'academy'/'default' to 'light'
41
42
  var _options$theme = options.theme,
42
43
  theme = _options$theme === void 0 ? 'light' : _options$theme;
43
44
  if (theme === 'academy' || theme === 'default') theme = 'light';
@@ -45,10 +46,16 @@ export var Summary = function Summary(options) {
45
46
  if (!container) {
46
47
  throw new Error('Container not found');
47
48
  }
49
+
50
+ // Create a wrapper element for padding and theme background
51
+ var wrapper = document.createElement('div');
52
+ wrapper.className = 'gpt-vis-summary';
53
+ container.appendChild(wrapper);
48
54
  var text = null;
49
55
 
50
56
  /**
51
57
  * Render the summary with the given T8 syntax string.
58
+ * Supports an optional `theme <value>` line in the syntax to override the theme.
52
59
  */
53
60
  var render = function render(syntax) {
54
61
  // Clean up previous instance if exists
@@ -56,12 +63,23 @@ export var Summary = function Summary(options) {
56
63
  text.unmount();
57
64
  }
58
65
 
66
+ // Extract optional `theme <value>` line from syntax
67
+ var activeTheme = theme;
68
+ var cleanedSyntax = syntax.replace(/^theme\s+(light|dark)\s*$/im, function (_, t) {
69
+ activeTheme = t;
70
+ return '';
71
+ });
72
+
59
73
  // Create T8 Text instance
60
- text = new Text(container);
74
+ text = new Text(wrapper);
75
+
76
+ // Set background color and padding on the wrapper
77
+ wrapper.style.backgroundColor = activeTheme === 'dark' ? getBackgroundColor('dark') : '';
78
+ wrapper.style.padding = '16px';
61
79
 
62
80
  // Set theme and render syntax
63
- text.theme(theme);
64
- text.render(syntax);
81
+ text.theme(activeTheme);
82
+ text.render(cleanedSyntax.trim());
65
83
  };
66
84
 
67
85
  /**
@@ -72,6 +90,9 @@ export var Summary = function Summary(options) {
72
90
  text.unmount();
73
91
  text = null;
74
92
  }
93
+ if (wrapper.parentNode) {
94
+ wrapper.parentNode.removeChild(wrapper);
95
+ }
75
96
  };
76
97
  return {
77
98
  render: 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.
@@ -14,7 +14,7 @@ var CELL_PADDING = 16; // 8px * 2
14
14
  var MIN_WIDTH_MULTIPLIER = 1.1;
15
15
 
16
16
  // CSS styles for the table component
17
- var TABLE_STYLES = "\n .".concat(SCOPE_ID, " {\n font-family: ").concat(FONT_FAMILY, ";\n overflow: auto;\n height: 100%;\n }\n\n .").concat(SCOPE_ID, " .table-title {\n font-size: 16px;\n font-weight: 500;\n margin-bottom: 12px;\n color: #1d2129;\n }\n\n .").concat(SCOPE_ID, " table {\n border-collapse: separate;\n border-spacing: 0;\n background: #fff;\n border-radius: 8px;\n overflow: hidden;\n }\n\n .").concat(SCOPE_ID, " th,\n .").concat(SCOPE_ID, " td {\n border-bottom: 1px solid #f0f0f0;\n padding: 8px;\n text-align: left;\n font-size: 14px;\n color: #333;\n white-space: nowrap;\n }\n\n .").concat(SCOPE_ID, " th {\n background: #f5f5f5;\n font-weight: 600;\n color: #000000e0;\n position: relative;\n }\n\n .").concat(SCOPE_ID, " th:not(:last-child)::after {\n content: '';\n position: absolute;\n top: 25%;\n right: 0;\n width: 1px;\n height: 50%;\n background: #e0e0e0;\n }\n\n .").concat(SCOPE_ID, " tr {\n transition: background 0.2s;\n }\n\n .").concat(SCOPE_ID, " tbody tr:hover {\n background: #f5f5f5;\n cursor: pointer;\n }\n");
17
+ var TABLE_STYLES = "\n .".concat(SCOPE_ID, " {\n font-family: ").concat(FONT_FAMILY, ";\n overflow: auto;\n height: 100%;\n padding: 16px;\n }\n\n .").concat(SCOPE_ID, " .table-title {\n font-size: 16px;\n font-weight: 500;\n margin-bottom: 12px;\n color: #1d2129;\n }\n\n .").concat(SCOPE_ID, " table {\n border-collapse: separate;\n border-spacing: 0;\n background: #fff;\n border-radius: 8px;\n overflow: hidden;\n }\n\n .").concat(SCOPE_ID, " th,\n .").concat(SCOPE_ID, " td {\n border-bottom: 1px solid #f0f0f0;\n padding: 8px;\n text-align: left;\n font-size: 14px;\n color: #333;\n white-space: nowrap;\n }\n\n .").concat(SCOPE_ID, " th {\n background: #f5f5f5;\n font-weight: 600;\n color: #000000e0;\n position: relative;\n }\n\n .").concat(SCOPE_ID, " th:not(:last-child)::after {\n content: '';\n position: absolute;\n top: 25%;\n right: 0;\n width: 1px;\n height: 50%;\n background: #e0e0e0;\n }\n\n .").concat(SCOPE_ID, " tr {\n transition: background 0.2s;\n }\n\n .").concat(SCOPE_ID, " tbody tr:hover {\n background: #f5f5f5;\n cursor: pointer;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] {\n background: #000;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] .table-title {\n color: #ffffffd9;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] table {\n background: #141414;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] th,\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] td {\n border-bottom: 1px solid #303030;\n color: #ffffffd9;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] th {\n background: #1f1f1f;\n color: #ffffffa6;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] th:not(:last-child)::after {\n background: #303030;\n }\n\n .").concat(SCOPE_ID, "[data-theme=\"dark\"] tbody tr:hover {\n background: #1f1f1f;\n }\n");
18
18
 
19
19
  /**
20
20
  * Calculate the minimum width needed for a table based on its data.
@@ -90,6 +90,8 @@ var injectStyles = function injectStyles() {
90
90
  * ```
91
91
  */
92
92
  export var Table = function Table(options) {
93
+ var _options$theme = options.theme,
94
+ chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
93
95
  var container = typeof options.container === 'string' ? document.querySelector(options.container) : options.container;
94
96
  if (!container) {
95
97
  throw new Error('Container not found');
@@ -102,7 +104,9 @@ export var Table = function Table(options) {
102
104
  var render = function render(config) {
103
105
  var _config$data = config.data,
104
106
  data = _config$data === void 0 ? [] : _config$data,
105
- title = config.title;
107
+ title = config.title,
108
+ _config$theme = config.theme,
109
+ theme = _config$theme === void 0 ? chartTheme : _config$theme;
106
110
 
107
111
  // Inject styles if not already present
108
112
  injectStyles();
@@ -115,6 +119,9 @@ export var Table = function Table(options) {
115
119
  // Create wrapper element
116
120
  tableWrapper = document.createElement('div');
117
121
  tableWrapper.className = SCOPE_ID;
122
+ if (theme === 'dark') {
123
+ tableWrapper.setAttribute('data-theme', 'dark');
124
+ }
118
125
 
119
126
  // Handle empty data case
120
127
  if (data.length === 0) {