@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.
- package/README.md +223 -47
- package/README.zh-CN.md +227 -51
- package/dist/cjs/gpt-vis/index.d.ts +8 -1
- package/dist/cjs/gpt-vis/index.js +43 -20
- package/dist/cjs/index.d.ts +15 -2
- package/dist/cjs/index.js +22 -2
- package/dist/cjs/syntax/parser.d.ts +17 -2
- package/dist/cjs/syntax/parser.js +151 -38
- package/dist/cjs/util/container.d.ts +5 -0
- package/dist/cjs/util/container.js +43 -0
- package/dist/cjs/util/theme.d.ts +5 -0
- package/dist/cjs/util/theme.js +9 -2
- package/dist/cjs/vis/area/index.js +2 -1
- package/dist/cjs/vis/bar/index.js +5 -4
- package/dist/cjs/vis/boxplot/index.js +7 -2
- package/dist/cjs/vis/column/index.js +5 -4
- package/dist/cjs/vis/dual-axes/index.js +3 -3
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +35 -0
- package/dist/cjs/vis/fishbone-diagram/index.js +191 -0
- package/dist/cjs/vis/flow-diagram/index.d.ts +27 -0
- package/dist/cjs/vis/flow-diagram/index.js +287 -0
- package/dist/cjs/vis/funnel/index.js +2 -1
- package/dist/cjs/vis/histogram/index.js +3 -7
- package/dist/cjs/vis/indented-tree/index.d.ts +40 -0
- package/dist/cjs/vis/indented-tree/index.js +385 -0
- package/dist/cjs/vis/line/index.js +2 -1
- package/dist/cjs/vis/liquid/index.js +2 -1
- package/dist/cjs/vis/mindmap/index.d.ts +32 -0
- package/dist/cjs/vis/mindmap/index.js +222 -0
- package/dist/cjs/vis/network-graph/index.d.ts +59 -0
- package/dist/cjs/vis/network-graph/index.js +175 -0
- package/dist/cjs/vis/organization-chart/index.d.ts +64 -0
- package/dist/cjs/vis/organization-chart/index.js +200 -0
- package/dist/cjs/vis/pie/index.js +3 -3
- package/dist/cjs/vis/radar/index.d.ts +1 -0
- package/dist/cjs/vis/radar/index.js +10 -9
- package/dist/cjs/vis/sankey/index.js +2 -1
- package/dist/cjs/vis/scatter/index.d.ts +2 -0
- package/dist/cjs/vis/scatter/index.js +9 -4
- package/dist/cjs/vis/summary/index.js +17 -3
- package/dist/cjs/vis/table/index.d.ts +1 -0
- package/dist/cjs/vis/table/index.js +37 -1
- package/dist/cjs/vis/treemap/index.js +2 -1
- package/dist/cjs/vis/venn/index.d.ts +2 -1
- package/dist/cjs/vis/venn/index.js +18 -3
- package/dist/cjs/vis/violin/index.js +2 -1
- package/dist/cjs/vis/waterfall/index.d.ts +6 -9
- package/dist/cjs/vis/waterfall/index.js +29 -6
- package/dist/cjs/vis/word-cloud/index.js +2 -1
- package/dist/cjs/vis-wrapper/icons.js +2 -2
- package/dist/cjs/vis-wrapper/index.d.ts +1 -0
- package/dist/cjs/vis-wrapper/index.js +27 -16
- package/dist/cjs/vis-wrapper/styles.d.ts +1 -1
- package/dist/cjs/vis-wrapper/styles.js +8 -1
- package/dist/esm/gpt-vis/index.d.ts +8 -1
- package/dist/esm/gpt-vis/index.js +47 -26
- package/dist/esm/index.d.ts +15 -2
- package/dist/esm/index.js +7 -1
- package/dist/esm/syntax/parser.d.ts +17 -2
- package/dist/esm/syntax/parser.js +248 -90
- package/dist/esm/util/container.d.ts +5 -0
- package/dist/esm/util/container.js +20 -0
- package/dist/esm/util/theme.d.ts +5 -0
- package/dist/esm/util/theme.js +9 -0
- package/dist/esm/vis/area/index.js +3 -2
- package/dist/esm/vis/bar/index.js +7 -6
- package/dist/esm/vis/boxplot/index.js +17 -4
- package/dist/esm/vis/column/index.js +7 -6
- package/dist/esm/vis/dual-axes/index.js +13 -5
- package/dist/esm/vis/fishbone-diagram/index.d.ts +35 -0
- package/dist/esm/vis/fishbone-diagram/index.js +219 -0
- package/dist/esm/vis/flow-diagram/index.d.ts +27 -0
- package/dist/esm/vis/flow-diagram/index.js +349 -0
- package/dist/esm/vis/funnel/index.js +3 -2
- package/dist/esm/vis/histogram/index.js +6 -7
- package/dist/esm/vis/indented-tree/index.d.ts +40 -0
- package/dist/esm/vis/indented-tree/index.js +569 -0
- package/dist/esm/vis/line/index.js +3 -2
- package/dist/esm/vis/liquid/index.js +3 -2
- package/dist/esm/vis/mindmap/index.d.ts +32 -0
- package/dist/esm/vis/mindmap/index.js +316 -0
- package/dist/esm/vis/network-graph/index.d.ts +59 -0
- package/dist/esm/vis/network-graph/index.js +242 -0
- package/dist/esm/vis/organization-chart/index.d.ts +64 -0
- package/dist/esm/vis/organization-chart/index.js +271 -0
- package/dist/esm/vis/pie/index.js +4 -8
- package/dist/esm/vis/radar/index.d.ts +1 -0
- package/dist/esm/vis/radar/index.js +20 -4
- package/dist/esm/vis/sankey/index.js +3 -2
- package/dist/esm/vis/scatter/index.d.ts +2 -0
- package/dist/esm/vis/scatter/index.js +15 -4
- package/dist/esm/vis/summary/index.js +25 -4
- package/dist/esm/vis/table/index.d.ts +1 -0
- package/dist/esm/vis/table/index.js +9 -2
- package/dist/esm/vis/treemap/index.js +3 -2
- package/dist/esm/vis/venn/index.d.ts +2 -1
- package/dist/esm/vis/venn/index.js +29 -4
- package/dist/esm/vis/violin/index.js +3 -2
- package/dist/esm/vis/waterfall/index.d.ts +6 -9
- package/dist/esm/vis/waterfall/index.js +33 -13
- package/dist/esm/vis/word-cloud/index.js +3 -2
- package/dist/esm/vis-wrapper/icons.js +2 -2
- package/dist/esm/vis-wrapper/index.d.ts +1 -0
- package/dist/esm/vis-wrapper/index.js +15 -10
- package/dist/esm/vis-wrapper/styles.d.ts +1 -1
- package/dist/esm/vis-wrapper/styles.js +1 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +17 -21
- package/src/gpt-vis/index.ts +0 -283
- package/src/index.ts +0 -44
- package/src/readme.md +0 -37
- package/src/syntax/index.ts +0 -2
- package/src/syntax/parser.ts +0 -411
- package/src/types/index.ts +0 -29
- package/src/util/theme.ts +0 -167
- package/src/vis/area/README.md +0 -143
- package/src/vis/area/index.ts +0 -212
- package/src/vis/bar/README.md +0 -158
- package/src/vis/bar/index.ts +0 -186
- package/src/vis/boxplot/README.md +0 -168
- package/src/vis/boxplot/index.ts +0 -162
- package/src/vis/column/README.md +0 -158
- package/src/vis/column/index.ts +0 -185
- package/src/vis/dual-axes/README.md +0 -191
- package/src/vis/dual-axes/index.ts +0 -218
- package/src/vis/funnel/README.md +0 -143
- package/src/vis/funnel/index.ts +0 -238
- package/src/vis/histogram/README.md +0 -130
- package/src/vis/histogram/index.ts +0 -153
- package/src/vis/line/README.md +0 -138
- package/src/vis/line/index.ts +0 -159
- package/src/vis/liquid/README.md +0 -150
- package/src/vis/liquid/index.ts +0 -130
- package/src/vis/pie/README.md +0 -127
- package/src/vis/pie/index.ts +0 -163
- package/src/vis/radar/README.md +0 -184
- package/src/vis/radar/index.ts +0 -214
- package/src/vis/sankey/README.md +0 -144
- package/src/vis/sankey/index.ts +0 -144
- package/src/vis/scatter/README.md +0 -145
- package/src/vis/scatter/index.ts +0 -147
- package/src/vis/summary/README.md +0 -272
- package/src/vis/summary/index.ts +0 -91
- package/src/vis/table/README.md +0 -174
- package/src/vis/table/index.ts +0 -241
- package/src/vis/treemap/README.md +0 -199
- package/src/vis/treemap/index.ts +0 -167
- package/src/vis/venn/README.md +0 -153
- package/src/vis/venn/index.ts +0 -149
- package/src/vis/violin/README.md +0 -168
- package/src/vis/violin/index.ts +0 -216
- package/src/vis/waterfall/README.md +0 -178
- package/src/vis/waterfall/index.ts +0 -258
- package/src/vis/word-cloud/README.md +0 -137
- package/src/vis/word-cloud/index.ts +0 -137
- package/src/vis-wrapper/README.md +0 -159
- package/src/vis-wrapper/icons.ts +0 -35
- package/src/vis-wrapper/index.ts +0 -276
- package/src/vis-wrapper/styles.ts +0 -195
|
@@ -0,0 +1,349 @@
|
|
|
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, getTheme, 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, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
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 theme = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'default';
|
|
79
|
+
var text = escapeHtml(((_d$data = d.data) === null || _d$data === void 0 ? void 0 : _d$data.text) || '');
|
|
80
|
+
var isHovered = (_d$states = d.states) === null || _d$states === void 0 ? void 0 : _d$states.includes('active');
|
|
81
|
+
var isSelected = (_d$states2 = d.states) === null || _d$states2 === void 0 ? void 0 : _d$states2.includes('selected');
|
|
82
|
+
var nodeColor = isHovered ? ACTIVE_COLOR : color;
|
|
83
|
+
var borderRadius = theme === 'academy' ? '0px' : '8px';
|
|
84
|
+
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: ").concat(borderRadius, ";\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 ");
|
|
85
|
+
}
|
|
86
|
+
function measureAndUpdateNodeSizes(graph, container, nodeColorMap, selectedBorderColor) {
|
|
87
|
+
var theme = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'default';
|
|
88
|
+
var nodes = graph.getNodeData();
|
|
89
|
+
var updatedNodes = nodes.map(function (node) {
|
|
90
|
+
var dom = container.querySelector("[data-node-key=\"".concat(CSS.escape(String(node.id)), "\"]"));
|
|
91
|
+
var height = DEFAULT_NODE_HEIGHT;
|
|
92
|
+
if (dom) {
|
|
93
|
+
height = Math.max(DEFAULT_NODE_HEIGHT, Math.ceil(dom.getBoundingClientRect().height));
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
id: node.id,
|
|
97
|
+
style: {
|
|
98
|
+
size: [DEFAULT_NODE_WIDTH, height],
|
|
99
|
+
dx: -DEFAULT_NODE_WIDTH / 2,
|
|
100
|
+
dy: -height / 2,
|
|
101
|
+
innerHTML: createNodeHTML(node, nodeColorMap.get(String(node.id)) || '#1783FF', selectedBorderColor, theme)
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
graph.updateNodeData(updatedNodes);
|
|
106
|
+
graph.render();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* FlowDiagram chart component using G6 5.0 with dagre layout.
|
|
111
|
+
*/
|
|
112
|
+
export var FlowDiagram = function FlowDiagram(options) {
|
|
113
|
+
var container = options.container,
|
|
114
|
+
width = options.width,
|
|
115
|
+
height = options.height,
|
|
116
|
+
_options$theme = options.theme,
|
|
117
|
+
chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
|
|
118
|
+
var graph = null;
|
|
119
|
+
var render = function render(config) {
|
|
120
|
+
var data = config.data,
|
|
121
|
+
title = config.title,
|
|
122
|
+
_config$theme = config.theme,
|
|
123
|
+
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
124
|
+
_config$style = config.style,
|
|
125
|
+
style = _config$style === void 0 ? {} : _config$style;
|
|
126
|
+
if (graph) {
|
|
127
|
+
graph.destroy();
|
|
128
|
+
graph = null;
|
|
129
|
+
}
|
|
130
|
+
ensureBehaviorRegistered();
|
|
131
|
+
var colors = normalizePalette(style.palette, theme);
|
|
132
|
+
var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
|
|
133
|
+
|
|
134
|
+
// Resolve container element
|
|
135
|
+
var containerEl;
|
|
136
|
+
if (typeof container === 'string') {
|
|
137
|
+
var el = document.getElementById(container.replace(/^#/, ''));
|
|
138
|
+
if (!el) throw new Error("Container element \"".concat(container, "\" not found"));
|
|
139
|
+
containerEl = el;
|
|
140
|
+
} else {
|
|
141
|
+
containerEl = container;
|
|
142
|
+
}
|
|
143
|
+
containerEl.style.backgroundColor = backgroundColor;
|
|
144
|
+
|
|
145
|
+
// Compute node ranks (BFS layers) for color assignment by row
|
|
146
|
+
var nodeRankMap = new Map();
|
|
147
|
+
var incomingTargets = new Set(data.edges.map(function (e) {
|
|
148
|
+
return e.target;
|
|
149
|
+
}));
|
|
150
|
+
var childrenMap = new Map();
|
|
151
|
+
var _iterator = _createForOfIteratorHelper(data.edges),
|
|
152
|
+
_step;
|
|
153
|
+
try {
|
|
154
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
155
|
+
var edge = _step.value;
|
|
156
|
+
var list = childrenMap.get(edge.source) || [];
|
|
157
|
+
list.push(edge.target);
|
|
158
|
+
childrenMap.set(edge.source, list);
|
|
159
|
+
}
|
|
160
|
+
} catch (err) {
|
|
161
|
+
_iterator.e(err);
|
|
162
|
+
} finally {
|
|
163
|
+
_iterator.f();
|
|
164
|
+
}
|
|
165
|
+
var roots = data.nodes.filter(function (n) {
|
|
166
|
+
return !incomingTargets.has(n.name);
|
|
167
|
+
}).map(function (n) {
|
|
168
|
+
return n.name;
|
|
169
|
+
});
|
|
170
|
+
var queue = roots.map(function (name) {
|
|
171
|
+
return {
|
|
172
|
+
name: name,
|
|
173
|
+
rank: 0
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
var head = 0;
|
|
177
|
+
while (head < queue.length) {
|
|
178
|
+
var _queue$head = queue[head++],
|
|
179
|
+
name = _queue$head.name,
|
|
180
|
+
rank = _queue$head.rank;
|
|
181
|
+
if (nodeRankMap.has(name)) continue;
|
|
182
|
+
nodeRankMap.set(name, rank);
|
|
183
|
+
var _iterator2 = _createForOfIteratorHelper(childrenMap.get(name) || []),
|
|
184
|
+
_step2;
|
|
185
|
+
try {
|
|
186
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
187
|
+
var child = _step2.value;
|
|
188
|
+
if (!nodeRankMap.has(child)) {
|
|
189
|
+
queue.push({
|
|
190
|
+
name: child,
|
|
191
|
+
rank: rank + 1
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
_iterator2.e(err);
|
|
197
|
+
} finally {
|
|
198
|
+
_iterator2.f();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Convert GraphData (name-based) to G6 format (id-based), color by rank
|
|
203
|
+
var nodeColorMap = new Map();
|
|
204
|
+
var g6Nodes = data.nodes.map(function (node) {
|
|
205
|
+
var rank = nodeRankMap.get(node.name) || 0;
|
|
206
|
+
var color = colors[rank % colors.length];
|
|
207
|
+
nodeColorMap.set(node.name, color);
|
|
208
|
+
return {
|
|
209
|
+
id: node.name,
|
|
210
|
+
data: {
|
|
211
|
+
text: node.name
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
var nodeNames = new Set(data.nodes.map(function (n) {
|
|
216
|
+
return n.name;
|
|
217
|
+
}));
|
|
218
|
+
var g6Edges = data.edges.filter(function (edge) {
|
|
219
|
+
return nodeNames.has(edge.source) && nodeNames.has(edge.target);
|
|
220
|
+
}).map(function (edge, index) {
|
|
221
|
+
return {
|
|
222
|
+
id: "edge-".concat(index),
|
|
223
|
+
source: edge.source,
|
|
224
|
+
target: edge.target,
|
|
225
|
+
data: {
|
|
226
|
+
text: edge.name || ''
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
var isDark = theme === 'dark';
|
|
231
|
+
var edgeStroke = isDark ? '#5a6b7f' : '#8b9baf';
|
|
232
|
+
var labelFill = isDark ? '#aab4c0' : '#8b9baf';
|
|
233
|
+
var labelBgFill = isDark ? '#1a1a2e' : '#f8f8f8';
|
|
234
|
+
var labelBgStroke = isDark ? '#5a6b7f' : '#8b9baf';
|
|
235
|
+
var selectedBorder = isDark ? '#fff' : '#000';
|
|
236
|
+
graph = new Graph({
|
|
237
|
+
animation: false,
|
|
238
|
+
container: containerEl,
|
|
239
|
+
width: width,
|
|
240
|
+
height: height,
|
|
241
|
+
theme: getTheme(theme),
|
|
242
|
+
data: {
|
|
243
|
+
nodes: g6Nodes,
|
|
244
|
+
edges: g6Edges
|
|
245
|
+
},
|
|
246
|
+
autoFit: 'view',
|
|
247
|
+
autoResize: true,
|
|
248
|
+
padding: title ? [46, 20, 20, 20] : 20,
|
|
249
|
+
plugins: title ? [{
|
|
250
|
+
key: 'title',
|
|
251
|
+
type: 'title',
|
|
252
|
+
title: title,
|
|
253
|
+
titleFill: isDark ? '#e0e6ed' : '#000',
|
|
254
|
+
titleFontFamily: 'sans-serif'
|
|
255
|
+
}] : [],
|
|
256
|
+
node: {
|
|
257
|
+
type: 'html',
|
|
258
|
+
style: function style(d) {
|
|
259
|
+
var _d$style;
|
|
260
|
+
var color = nodeColorMap.get(String(d.id)) || colors[0];
|
|
261
|
+
var size = ((_d$style = d.style) === null || _d$style === void 0 ? void 0 : _d$style.size) || [DEFAULT_NODE_WIDTH, DEFAULT_NODE_HEIGHT];
|
|
262
|
+
var height = size[1];
|
|
263
|
+
return {
|
|
264
|
+
size: size,
|
|
265
|
+
dx: -DEFAULT_NODE_WIDTH / 2,
|
|
266
|
+
dy: -height / 2,
|
|
267
|
+
innerHTML: createNodeHTML(d, color, selectedBorder, theme),
|
|
268
|
+
ports: [{
|
|
269
|
+
placement: 'top'
|
|
270
|
+
}, {
|
|
271
|
+
placement: 'bottom'
|
|
272
|
+
}]
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
state: {
|
|
276
|
+
active: {
|
|
277
|
+
halo: false
|
|
278
|
+
},
|
|
279
|
+
selected: {
|
|
280
|
+
halo: false
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
edge: {
|
|
285
|
+
type: 'polyline',
|
|
286
|
+
style: {
|
|
287
|
+
lineWidth: 3,
|
|
288
|
+
radius: 20,
|
|
289
|
+
stroke: edgeStroke,
|
|
290
|
+
endArrow: true,
|
|
291
|
+
labelText: function labelText(d) {
|
|
292
|
+
var _d$data2;
|
|
293
|
+
return ((_d$data2 = d.data) === null || _d$data2 === void 0 ? void 0 : _d$data2.text) || '';
|
|
294
|
+
},
|
|
295
|
+
labelFill: labelFill,
|
|
296
|
+
labelFontWeight: 600,
|
|
297
|
+
labelBackground: true,
|
|
298
|
+
labelBackgroundFill: labelBgFill,
|
|
299
|
+
labelBackgroundOpacity: 1,
|
|
300
|
+
labelBackgroundLineWidth: 3,
|
|
301
|
+
labelBackgroundStroke: labelBgStroke,
|
|
302
|
+
labelPadding: [1, 10],
|
|
303
|
+
labelBackgroundRadius: 4,
|
|
304
|
+
router: {
|
|
305
|
+
type: 'orth',
|
|
306
|
+
padding: 40
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
state: {
|
|
310
|
+
active: {
|
|
311
|
+
stroke: ACTIVE_COLOR,
|
|
312
|
+
labelBackgroundStroke: ACTIVE_COLOR,
|
|
313
|
+
halo: false
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
layout: {
|
|
318
|
+
type: 'antv-dagre'
|
|
319
|
+
},
|
|
320
|
+
behaviors: ['drag-canvas', 'hover-element', 'click-select']
|
|
321
|
+
});
|
|
322
|
+
graph.render();
|
|
323
|
+
|
|
324
|
+
// Measure real node heights after initial render
|
|
325
|
+
graph.once('afterrender', function () {
|
|
326
|
+
if (graph) {
|
|
327
|
+
measureAndUpdateNodeSizes(graph, containerEl, nodeColorMap, selectedBorder, theme);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
var destroy = function destroy() {
|
|
332
|
+
if (graph) {
|
|
333
|
+
graph.destroy();
|
|
334
|
+
graph = null;
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
return {
|
|
338
|
+
render: render,
|
|
339
|
+
destroy: destroy,
|
|
340
|
+
zoomTo: function zoomTo(zoom) {
|
|
341
|
+
var _graph;
|
|
342
|
+
return (_graph = graph) === null || _graph === void 0 ? void 0 : _graph.zoomTo(zoom);
|
|
343
|
+
},
|
|
344
|
+
getZoom: function getZoom() {
|
|
345
|
+
var _graph2;
|
|
346
|
+
return (_graph2 = graph) === null || _graph2 === void 0 ? void 0 : _graph2.getZoom();
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Chart } from '@antv/g2';
|
|
2
|
-
import { getBackgroundColor,
|
|
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
|
|
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,
|
|
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
|
|
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: [
|
|
120
|
-
|
|
121
|
-
|
|
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;
|