@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,342 @@
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ 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."); }
5
+ 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); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
+ 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; }
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
11
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ 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); }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ import { ExtensionCategory, Graph, HoverActivate, idOf, register } from '@antv/g6';
22
+ import { getBackgroundColor, normalizePalette } from "../../util/theme";
23
+
24
+ /**
25
+ * FlowDiagramConfig defines the configuration for rendering the flow diagram.
26
+ */
27
+
28
+ /**
29
+ * FlowDiagramInstance represents a flow diagram instance with render and destroy methods.
30
+ */
31
+
32
+ var ACTIVE_COLOR = '#f6c523';
33
+ var DEFAULT_NODE_WIDTH = 200;
34
+ var DEFAULT_NODE_HEIGHT = 80;
35
+ var HoverElement = /*#__PURE__*/function (_HoverActivate) {
36
+ _inherits(HoverElement, _HoverActivate);
37
+ var _super = _createSuper(HoverElement);
38
+ function HoverElement() {
39
+ _classCallCheck(this, HoverElement);
40
+ return _super.apply(this, arguments);
41
+ }
42
+ _createClass(HoverElement, [{
43
+ key: "getActiveIds",
44
+ value: function getActiveIds(event) {
45
+ var _this$context = this.context,
46
+ model = _this$context.model,
47
+ graph = _this$context.graph;
48
+ var targetType = event.targetType,
49
+ target = event.target;
50
+ var targetId = target.id;
51
+ var ids = [targetId];
52
+ if (targetType === 'edge') {
53
+ var edge = model.getEdgeDatum(targetId);
54
+ ids.push(edge.source, edge.target);
55
+ } else if (targetType === 'node') {
56
+ ids.push.apply(ids, _toConsumableArray(model.getRelatedEdgesData(targetId).map(idOf)));
57
+ }
58
+ graph.frontElement(ids);
59
+ return ids;
60
+ }
61
+ }]);
62
+ return HoverElement;
63
+ }(HoverActivate);
64
+ var behaviorRegistered = false;
65
+ function ensureBehaviorRegistered() {
66
+ if (!behaviorRegistered) {
67
+ register(ExtensionCategory.BEHAVIOR, 'hover-element', HoverElement);
68
+ behaviorRegistered = true;
69
+ }
70
+ }
71
+ function escapeHtml() {
72
+ var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
73
+ return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
74
+ }
75
+ function createNodeHTML(d, color) {
76
+ var _d$data, _d$states, _d$states2;
77
+ var selectedBorderColor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '#000';
78
+ var text = escapeHtml(((_d$data = d.data) === null || _d$data === void 0 ? void 0 : _d$data.text) || '');
79
+ var isHovered = (_d$states = d.states) === null || _d$states === void 0 ? void 0 : _d$states.includes('active');
80
+ var isSelected = (_d$states2 = d.states) === null || _d$states2 === void 0 ? void 0 : _d$states2.includes('selected');
81
+ var nodeColor = isHovered ? ACTIVE_COLOR : color;
82
+ return "\n <div\n data-node-key=\"".concat(escapeHtml(String(d.id)), "\"\n style=\"\n box-sizing: border-box;\n width: ").concat(DEFAULT_NODE_WIDTH, "px;\n min-height: ").concat(DEFAULT_NODE_HEIGHT, "px;\n padding: 16px;\n background: ").concat(nodeColor, ";\n border: 3px solid ").concat(isSelected ? selectedBorderColor : nodeColor, ";\n border-radius: 16px;\n color: #fff;\n font-size: 16px;\n font-weight: 600;\n line-height: 22px;\n text-align: center;\n white-space: normal;\n word-break: break-word;\n overflow-wrap: anywhere;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n \"\n >\n <div style=\"width: 100%;\">\n ").concat(text, "\n </div>\n </div>\n ");
83
+ }
84
+ function measureAndUpdateNodeSizes(graph, container, nodeColorMap, selectedBorderColor) {
85
+ var nodes = graph.getNodeData();
86
+ var updatedNodes = nodes.map(function (node) {
87
+ var dom = container.querySelector("[data-node-key=\"".concat(CSS.escape(String(node.id)), "\"]"));
88
+ var height = DEFAULT_NODE_HEIGHT;
89
+ if (dom) {
90
+ height = Math.max(DEFAULT_NODE_HEIGHT, Math.ceil(dom.getBoundingClientRect().height));
91
+ }
92
+ return {
93
+ id: node.id,
94
+ style: {
95
+ size: [DEFAULT_NODE_WIDTH, height],
96
+ dx: -DEFAULT_NODE_WIDTH / 2,
97
+ dy: -height / 2,
98
+ innerHTML: createNodeHTML(node, nodeColorMap.get(String(node.id)) || '#1783FF', selectedBorderColor)
99
+ }
100
+ };
101
+ });
102
+ graph.updateNodeData(updatedNodes);
103
+ graph.render();
104
+ }
105
+
106
+ /**
107
+ * FlowDiagram chart component using G6 5.0 with dagre layout.
108
+ */
109
+ export var FlowDiagram = function FlowDiagram(options) {
110
+ var container = options.container,
111
+ width = options.width,
112
+ height = options.height,
113
+ _options$theme = options.theme,
114
+ chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
115
+ var graph = null;
116
+ var render = function render(config) {
117
+ var data = config.data,
118
+ title = config.title,
119
+ _config$theme = config.theme,
120
+ theme = _config$theme === void 0 ? chartTheme : _config$theme,
121
+ _config$style = config.style,
122
+ style = _config$style === void 0 ? {} : _config$style;
123
+ if (graph) {
124
+ graph.destroy();
125
+ graph = null;
126
+ }
127
+ ensureBehaviorRegistered();
128
+ var colors = normalizePalette(style.palette, theme);
129
+ var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
130
+
131
+ // Resolve container element
132
+ var containerEl;
133
+ if (typeof container === 'string') {
134
+ var el = document.getElementById(container.replace(/^#/, ''));
135
+ if (!el) throw new Error("Container element \"".concat(container, "\" not found"));
136
+ containerEl = el;
137
+ } else {
138
+ containerEl = container;
139
+ }
140
+ containerEl.style.backgroundColor = backgroundColor;
141
+
142
+ // Compute node ranks (BFS layers) for color assignment by row
143
+ var nodeRankMap = new Map();
144
+ var incomingTargets = new Set(data.edges.map(function (e) {
145
+ return e.target;
146
+ }));
147
+ var childrenMap = new Map();
148
+ var _iterator = _createForOfIteratorHelper(data.edges),
149
+ _step;
150
+ try {
151
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
152
+ var edge = _step.value;
153
+ var list = childrenMap.get(edge.source) || [];
154
+ list.push(edge.target);
155
+ childrenMap.set(edge.source, list);
156
+ }
157
+ } catch (err) {
158
+ _iterator.e(err);
159
+ } finally {
160
+ _iterator.f();
161
+ }
162
+ var roots = data.nodes.filter(function (n) {
163
+ return !incomingTargets.has(n.name);
164
+ }).map(function (n) {
165
+ return n.name;
166
+ });
167
+ var queue = roots.map(function (name) {
168
+ return {
169
+ name: name,
170
+ rank: 0
171
+ };
172
+ });
173
+ var head = 0;
174
+ while (head < queue.length) {
175
+ var _queue$head = queue[head++],
176
+ name = _queue$head.name,
177
+ rank = _queue$head.rank;
178
+ if (nodeRankMap.has(name)) continue;
179
+ nodeRankMap.set(name, rank);
180
+ var _iterator2 = _createForOfIteratorHelper(childrenMap.get(name) || []),
181
+ _step2;
182
+ try {
183
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
184
+ var child = _step2.value;
185
+ if (!nodeRankMap.has(child)) {
186
+ queue.push({
187
+ name: child,
188
+ rank: rank + 1
189
+ });
190
+ }
191
+ }
192
+ } catch (err) {
193
+ _iterator2.e(err);
194
+ } finally {
195
+ _iterator2.f();
196
+ }
197
+ }
198
+
199
+ // Convert GraphData (name-based) to G6 format (id-based), color by rank
200
+ var nodeColorMap = new Map();
201
+ var g6Nodes = data.nodes.map(function (node) {
202
+ var rank = nodeRankMap.get(node.name) || 0;
203
+ var color = colors[rank % colors.length];
204
+ nodeColorMap.set(node.name, color);
205
+ return {
206
+ id: node.name,
207
+ data: {
208
+ text: node.name
209
+ }
210
+ };
211
+ });
212
+ var nodeNames = new Set(data.nodes.map(function (n) {
213
+ return n.name;
214
+ }));
215
+ var g6Edges = data.edges.filter(function (edge) {
216
+ return nodeNames.has(edge.source) && nodeNames.has(edge.target);
217
+ }).map(function (edge, index) {
218
+ return {
219
+ id: "edge-".concat(index),
220
+ source: edge.source,
221
+ target: edge.target,
222
+ data: {
223
+ text: edge.name || ''
224
+ }
225
+ };
226
+ });
227
+ var isDark = theme === 'dark';
228
+ var edgeStroke = isDark ? '#5a6b7f' : '#8b9baf';
229
+ var labelFill = isDark ? '#aab4c0' : '#8b9baf';
230
+ var labelBgFill = isDark ? '#1a1a2e' : '#f8f8f8';
231
+ var labelBgStroke = isDark ? '#5a6b7f' : '#8b9baf';
232
+ var selectedBorder = isDark ? '#fff' : '#000';
233
+ graph = new Graph({
234
+ animation: false,
235
+ container: containerEl,
236
+ width: width,
237
+ height: height,
238
+ theme: theme,
239
+ data: {
240
+ nodes: g6Nodes,
241
+ edges: g6Edges
242
+ },
243
+ autoFit: 'view',
244
+ autoResize: true,
245
+ padding: 20,
246
+ plugins: title ? [{
247
+ key: 'title',
248
+ type: 'title',
249
+ title: title,
250
+ titleFill: isDark ? '#e0e6ed' : '#1a1a2e'
251
+ }] : [],
252
+ node: {
253
+ type: 'html',
254
+ style: function style(d) {
255
+ var color = nodeColorMap.get(String(d.id)) || colors[0];
256
+ return {
257
+ size: [DEFAULT_NODE_WIDTH, DEFAULT_NODE_HEIGHT],
258
+ dx: -DEFAULT_NODE_WIDTH / 2,
259
+ dy: -DEFAULT_NODE_HEIGHT / 2,
260
+ innerHTML: createNodeHTML(d, color, selectedBorder),
261
+ ports: [{
262
+ placement: 'top'
263
+ }, {
264
+ placement: 'bottom'
265
+ }]
266
+ };
267
+ },
268
+ state: {
269
+ active: {
270
+ halo: false
271
+ },
272
+ selected: {
273
+ halo: false
274
+ }
275
+ }
276
+ },
277
+ edge: {
278
+ type: 'polyline',
279
+ style: {
280
+ lineWidth: 3,
281
+ radius: 20,
282
+ stroke: edgeStroke,
283
+ endArrow: true,
284
+ labelText: function labelText(d) {
285
+ var _d$data2;
286
+ return ((_d$data2 = d.data) === null || _d$data2 === void 0 ? void 0 : _d$data2.text) || '';
287
+ },
288
+ labelFill: labelFill,
289
+ labelFontWeight: 600,
290
+ labelBackground: true,
291
+ labelBackgroundFill: labelBgFill,
292
+ labelBackgroundOpacity: 1,
293
+ labelBackgroundLineWidth: 3,
294
+ labelBackgroundStroke: labelBgStroke,
295
+ labelPadding: [1, 10],
296
+ labelBackgroundRadius: 4,
297
+ router: {
298
+ type: 'orth',
299
+ padding: 40
300
+ }
301
+ },
302
+ state: {
303
+ active: {
304
+ stroke: ACTIVE_COLOR,
305
+ labelBackgroundStroke: ACTIVE_COLOR,
306
+ halo: false
307
+ }
308
+ }
309
+ },
310
+ layout: {
311
+ type: 'antv-dagre'
312
+ },
313
+ behaviors: ['drag-canvas', 'hover-element', 'click-select']
314
+ });
315
+ graph.render();
316
+
317
+ // Measure real node heights after initial render
318
+ graph.once('afterrender', function () {
319
+ if (graph) {
320
+ measureAndUpdateNodeSizes(graph, containerEl, nodeColorMap, selectedBorder);
321
+ }
322
+ });
323
+ };
324
+ var destroy = function destroy() {
325
+ if (graph) {
326
+ graph.destroy();
327
+ graph = null;
328
+ }
329
+ };
330
+ return {
331
+ render: render,
332
+ destroy: destroy,
333
+ zoomTo: function zoomTo(zoom) {
334
+ var _graph;
335
+ return (_graph = graph) === null || _graph === void 0 ? void 0 : _graph.zoomTo(zoom);
336
+ },
337
+ getZoom: function getZoom() {
338
+ var _graph2;
339
+ return (_graph2 = graph) === null || _graph2 === void 0 ? void 0 : _graph2.getZoom();
340
+ }
341
+ };
342
+ };
@@ -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
  * FunnelDataItem is the type for each data item in the funnel chart.
@@ -65,7 +65,7 @@ export var Funnel = function Funnel(options) {
65
65
  }
66
66
 
67
67
  // Get colors from style.palette or theme defaults
68
- var colors = style.palette || getThemeColors(theme);
68
+ var colors = normalizePalette(style.palette, theme);
69
69
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
70
70
 
71
71
  // Helper function to calculate conversion rate
@@ -87,6 +87,7 @@ export var Funnel = function Funnel(options) {
87
87
  // Note: Using 'any' type due to G2's complex type system with transformations
88
88
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
89
89
  var chartOptions = {
90
+ animate: false,
90
91
  type: 'view',
91
92
  data: data,
92
93
  title: title !== null && title !== void 0 ? title : '',
@@ -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
  * HistogramConfig defines the configuration for rendering the histogram chart.
@@ -60,7 +60,7 @@ export var Histogram = function Histogram(options) {
60
60
  }
61
61
 
62
62
  // Get colors from style.palette or theme defaults
63
- var colors = style.palette || getThemeColors(theme);
63
+ var colors = normalizePalette(style.palette, theme);
64
64
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
65
65
 
66
66
  // Create chart
@@ -75,6 +75,7 @@ export var Histogram = function Histogram(options) {
75
75
  // Note: Using 'any' type due to G2's complex type system with transformations
76
76
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
77
77
  var chartOptions = {
78
+ animate: false,
78
79
  type: 'interval',
79
80
  data: data,
80
81
  title: title !== null && title !== void 0 ? title : '',
@@ -116,11 +117,9 @@ export var Histogram = function Histogram(options) {
116
117
  },
117
118
  legend: false,
118
119
  tooltip: {
119
- items: [function (d) {
120
- return {
121
- name: '频数',
122
- value: d.count
123
- };
120
+ items: [{
121
+ channel: 'y',
122
+ name: '频数'
124
123
  }]
125
124
  },
126
125
  viewStyle: {
@@ -0,0 +1,40 @@
1
+ import type { VisualizationOptions } from '../../types';
2
+ /**
3
+ * Indented tree node data — only name + optional children, no description.
4
+ * Aligns with the official G6 indented tree example data structure.
5
+ */
6
+ export interface IndentedTreeData {
7
+ name: string;
8
+ children?: IndentedTreeData[];
9
+ }
10
+ /**
11
+ * IndentedTreeConfig defines the configuration for rendering the indented tree.
12
+ */
13
+ export interface IndentedTreeConfig {
14
+ type?: 'indented-tree';
15
+ data: IndentedTreeData;
16
+ theme?: 'default' | 'academy' | 'dark';
17
+ title?: string;
18
+ /** Layout direction: 'LR' = root left (default), 'RL' = root right, 'H' = root center */
19
+ direction?: 'LR' | 'RL' | 'H';
20
+ style?: {
21
+ backgroundColor?: string;
22
+ palette?: string[];
23
+ };
24
+ }
25
+ /**
26
+ * IndentedTreeInstance represents a chart instance with render and destroy methods.
27
+ */
28
+ export interface IndentedTreeInstance {
29
+ render: (config: IndentedTreeConfig) => void;
30
+ destroy: () => void;
31
+ zoomTo: (zoom: number) => void;
32
+ getZoom: () => number | undefined;
33
+ }
34
+ /**
35
+ * IndentedTree — G6 5 indented layout for static DSL trees (no collapse/add UI).
36
+ * Uses built-in `rect` nodes and `line` edges. Tree edges must have explicit ids (see render) to avoid
37
+ * colliding with path-based node ids under G6's default `${source}-${target}` edge id rule.
38
+ * Based on: https://g6.antv.antgroup.com/examples/scene-case/tree-graph#indented-tree
39
+ */
40
+ export declare const IndentedTree: (options: VisualizationOptions) => IndentedTreeInstance;