@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,269 @@
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, 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
+ padding: 24,
157
+ data: {
158
+ nodes: nodeData,
159
+ edges: edgeData
160
+ },
161
+ plugins: [{
162
+ type: 'tooltip',
163
+ trigger: 'hover',
164
+ enable: function enable(e) {
165
+ return (e === null || e === void 0 ? void 0 : e.targetType) === 'node';
166
+ },
167
+ offset: [10, 10],
168
+ getContent: function getContent(e, items) {
169
+ var _biz$name;
170
+ var item = items === null || items === void 0 ? void 0 : items[0];
171
+ var biz = item === null || item === void 0 ? void 0 : item.data;
172
+ if (!biz) return '';
173
+ var name = escapeHtml(String((_biz$name = biz.name) !== null && _biz$name !== void 0 ? _biz$name : ''));
174
+ var desc = biz.description ? escapeHtml(String(biz.description)) : '';
175
+ 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 ");
176
+ },
177
+ style: {
178
+ '.tooltip': {
179
+ background: isDark ? 'rgba(20,20,20,0.92)' : 'rgba(255,255,255,0.96)',
180
+ color: isDark ? '#f2f2f2' : '#1f1f1f',
181
+ border: "1px solid ".concat(isDark ? 'rgba(255,255,255,0.12)' : 'rgba(0,0,0,0.10)'),
182
+ borderRadius: 8,
183
+ boxShadow: '0 12px 28px rgba(0,0,0,0.16)',
184
+ padding: '8px 10px',
185
+ pointerEvents: 'none'
186
+ }
187
+ }
188
+ }].concat(_toConsumableArray(title ? [{
189
+ key: 'title',
190
+ type: 'title',
191
+ title: title,
192
+ titleFill: isDark ? '#e0e6ed' : '#1a1a2e'
193
+ }] : [])),
194
+ node: {
195
+ type: 'rect',
196
+ style: {
197
+ // size: [width, height] is the correct API for rect nodes in G6 v5
198
+ size: function size(d) {
199
+ return [NODE_WIDTH, d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC];
200
+ },
201
+ fill: function fill(d) {
202
+ return colors[d.data.depth % colors.length];
203
+ },
204
+ stroke: isDark ? '#555' : '#e8ebf0',
205
+ lineWidth: 1,
206
+ radius: 8,
207
+ // Use official label wrapping/ellipsis for BOTH name & description.
208
+ // 1 line name + up to 2 lines description => total maxLines = 3.
209
+ labelText: function labelText(d) {
210
+ return d.data.description ? "".concat(d.data.name, "\n").concat(d.data.description) : d.data.name;
211
+ },
212
+ labelFill: '#ffffff',
213
+ labelFontSize: 12,
214
+ labelFontWeight: 600,
215
+ labelWordWrap: true,
216
+ labelWordWrapWidth: LABEL_MAX_WIDTH,
217
+ labelMaxLines: function labelMaxLines(d) {
218
+ return d.data.description ? 3 : 1;
219
+ },
220
+ labelLineHeight: 14,
221
+ labelPlacement: 'center'
222
+ }
223
+ },
224
+ edge: {
225
+ // Use a tree-friendly edge type that does not depend on node ports.
226
+ type: 'cubic-vertical',
227
+ style: {
228
+ stroke: isDark ? '#4a4a4a' : '#d0d7e0',
229
+ lineWidth: 1.5,
230
+ endArrow: false,
231
+ startArrow: false
232
+ }
233
+ },
234
+ layout: {
235
+ type: 'dagre',
236
+ rankdir: 'TB',
237
+ nodesep: 40,
238
+ ranksep: 60,
239
+ // Dynamic nodeSize lets dagre calculate accurate per-node spacing
240
+ nodeSize: function nodeSize(d) {
241
+ return [NODE_WIDTH, d.data.description ? NODE_HEIGHT_WITH_DESC : NODE_HEIGHT_NO_DESC];
242
+ }
243
+ },
244
+ behaviors: ['drag-canvas']
245
+ });
246
+ graph.render();
247
+ };
248
+ var destroy = function destroy() {
249
+ if (graph) {
250
+ graph.destroy();
251
+ graph = null;
252
+ }
253
+ };
254
+ return {
255
+ render: render,
256
+ destroy: destroy,
257
+ zoomTo: function zoomTo(zoom) {
258
+ var _graph;
259
+ return (_graph = graph) === null || _graph === void 0 ? void 0 : _graph.zoomTo(zoom);
260
+ },
261
+ getZoom: function getZoom() {
262
+ var _graph2;
263
+ return (_graph2 = graph) === null || _graph2 === void 0 ? void 0 : _graph2.getZoom();
264
+ }
265
+ };
266
+ };
267
+ function escapeHtml(input) {
268
+ return String(input).replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&#039;');
269
+ }
@@ -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,
@@ -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.
@@ -64,7 +64,7 @@ export var Scatter = function Scatter(options) {
64
64
  }
65
65
 
66
66
  // Get colors from style.palette or theme defaults
67
- var colors = style.palette || getThemeColors(theme);
67
+ var colors = normalizePalette(style.palette, theme);
68
68
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
69
69
 
70
70
  // Check if data has group field
@@ -108,6 +108,7 @@ export var Scatter = function Scatter(options) {
108
108
  // Note: Using 'any' type due to G2's complex type system with transformations
109
109
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
110
110
  var chartOptions = {
111
+ animate: false,
111
112
  type: 'point',
112
113
  data: data,
113
114
  title: title !== null && title !== void 0 ? title : '',
@@ -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) {
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
8
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
9
9
 
10
10
  /**
11
11
  * TreemapDataItem is the type for each data item in the treemap chart.
@@ -83,7 +83,7 @@ export var Treemap = function Treemap(options) {
83
83
  }
84
84
 
85
85
  // Get colors from style.palette or theme defaults
86
- var colors = style.palette || getThemeColors(theme);
86
+ var colors = normalizePalette(style.palette, theme);
87
87
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
88
88
 
89
89
  // Create chart
@@ -98,6 +98,7 @@ export var Treemap = function Treemap(options) {
98
98
  // Note: Using 'any' type due to G2's complex type system with transformations
99
99
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
100
100
  var chartOptions = {
101
+ animate: false,
101
102
  type: 'treemap',
102
103
  data: {
103
104
  type: 'inline',
@@ -3,7 +3,8 @@ import type { VisualizationOptions } from '../../types';
3
3
  * VennDataItem is the type for each data item in the venn chart.
4
4
  */
5
5
  export type VennDataItem = {
6
- sets: string[];
6
+ /** Parser / DSL often yields a comma-separated string; G2 venn transform expects string[]. */
7
+ sets: string[] | string;
7
8
  value: number;
8
9
  label?: string;
9
10
  };
@@ -1,10 +1,29 @@
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 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
+ 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
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
7
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeColors, getThemeObject } from "../../util/theme";
8
+ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
3
9
 
4
10
  /**
5
11
  * VennDataItem is the type for each data item in the venn chart.
6
12
  */
7
13
 
14
+ function normalizeVennSets(sets) {
15
+ if (Array.isArray(sets)) return sets.map(function (s) {
16
+ return String(s);
17
+ });
18
+ if (typeof sets === 'string') {
19
+ return sets.split(',').map(function (s) {
20
+ return s.trim();
21
+ }).filter(Boolean);
22
+ }
23
+ if (sets == null) return [];
24
+ return [String(sets)];
25
+ }
26
+
8
27
  /**
9
28
  * VennConfig defines the configuration for rendering the venn chart.
10
29
  */
@@ -63,8 +82,13 @@ export var Venn = function Venn(options) {
63
82
  }
64
83
 
65
84
  // Get colors from style.palette or theme defaults
66
- var colors = style.palette || getThemeColors(theme);
85
+ var colors = normalizePalette(style.palette, theme);
67
86
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
87
+ var normalizedData = data.map(function (d) {
88
+ return _objectSpread(_objectSpread({}, d), {}, {
89
+ sets: normalizeVennSets(d.sets)
90
+ });
91
+ });
68
92
 
69
93
  // Create chart
70
94
  chart = new Chart({
@@ -78,9 +102,10 @@ export var Venn = function Venn(options) {
78
102
  // Note: Using 'any' type due to G2's complex type system with transformations
79
103
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
80
104
  var chartOptions = {
105
+ animate: false,
81
106
  type: 'path',
82
107
  data: {
83
- value: data,
108
+ value: normalizedData,
84
109
  transform: [{
85
110
  type: 'venn',
86
111
  padding: 8,
@@ -102,7 +127,7 @@ export var Venn = function Venn(options) {
102
127
  style: {
103
128
  // Set opacity: intersections (sets.length > 1) are nearly transparent, single sets are more opaque
104
129
  opacity: function opacity(d) {
105
- return d.sets.length > 1 ? 0.001 : 0.65;
130
+ return normalizeVennSets(d.sets).length > 1 ? 0.001 : 0.65;
106
131
  }
107
132
  },
108
133
  labels: [{