@antv/gpt-vis 0.4.7 → 0.5.0-beta.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/dist/cjs/ssr/area.d.ts +6 -0
- package/dist/cjs/ssr/area.js +64 -0
- package/dist/cjs/ssr/bar.d.ts +6 -0
- package/dist/cjs/ssr/bar.js +79 -0
- package/dist/cjs/ssr/column.d.ts +6 -0
- package/dist/cjs/ssr/column.js +77 -0
- package/dist/cjs/ssr/dual-axes.d.ts +6 -0
- package/dist/cjs/ssr/dual-axes.js +98 -0
- package/dist/cjs/ssr/fishbone-diagram.d.ts +6 -0
- package/dist/cjs/ssr/fishbone-diagram.js +189 -0
- package/dist/cjs/ssr/flow-diagram.d.ts +6 -0
- package/dist/cjs/ssr/flow-diagram.js +82 -0
- package/dist/cjs/ssr/histogram.d.ts +6 -0
- package/dist/cjs/ssr/histogram.js +50 -0
- package/dist/cjs/ssr/index.d.ts +2 -0
- package/dist/cjs/ssr/index.js +79 -0
- package/dist/cjs/ssr/line.d.ts +6 -0
- package/dist/cjs/ssr/line.js +62 -0
- package/dist/cjs/ssr/mind-map.d.ts +6 -0
- package/dist/cjs/ssr/mind-map.js +326 -0
- package/dist/cjs/ssr/network-graph.d.ts +6 -0
- package/dist/cjs/ssr/network-graph.js +72 -0
- package/dist/cjs/ssr/pie.d.ts +6 -0
- package/dist/cjs/ssr/pie.js +64 -0
- package/dist/cjs/ssr/radar.d.ts +6 -0
- package/dist/cjs/ssr/radar.js +92 -0
- package/dist/cjs/ssr/scatter.d.ts +6 -0
- package/dist/cjs/ssr/scatter.js +56 -0
- package/dist/cjs/ssr/treemap.d.ts +6 -0
- package/dist/cjs/ssr/treemap.js +57 -0
- package/dist/cjs/ssr/type.d.ts +30 -0
- package/dist/cjs/ssr/type.js +17 -0
- package/dist/cjs/ssr/word-cloud.d.ts +6 -0
- package/dist/cjs/ssr/word-cloud.js +48 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/ssr/area.d.ts +6 -0
- package/dist/esm/ssr/area.js +67 -0
- package/dist/esm/ssr/bar.d.ts +6 -0
- package/dist/esm/ssr/bar.js +71 -0
- package/dist/esm/ssr/column.d.ts +6 -0
- package/dist/esm/ssr/column.js +65 -0
- package/dist/esm/ssr/dual-axes.d.ts +6 -0
- package/dist/esm/ssr/dual-axes.js +122 -0
- package/dist/esm/ssr/fishbone-diagram.d.ts +6 -0
- package/dist/esm/ssr/fishbone-diagram.js +195 -0
- package/dist/esm/ssr/flow-diagram.d.ts +6 -0
- package/dist/esm/ssr/flow-diagram.js +89 -0
- package/dist/esm/ssr/histogram.d.ts +6 -0
- package/dist/esm/ssr/histogram.js +56 -0
- package/dist/esm/ssr/index.d.ts +2 -0
- package/dist/esm/ssr/index.js +68 -0
- package/dist/esm/ssr/line.d.ts +6 -0
- package/dist/esm/ssr/line.js +61 -0
- package/dist/esm/ssr/mind-map.d.ts +6 -0
- package/dist/esm/ssr/mind-map.js +416 -0
- package/dist/esm/ssr/network-graph.d.ts +6 -0
- package/dist/esm/ssr/network-graph.js +79 -0
- package/dist/esm/ssr/pie.d.ts +6 -0
- package/dist/esm/ssr/pie.js +66 -0
- package/dist/esm/ssr/radar.d.ts +6 -0
- package/dist/esm/ssr/radar.js +88 -0
- package/dist/esm/ssr/scatter.d.ts +6 -0
- package/dist/esm/ssr/scatter.js +52 -0
- package/dist/esm/ssr/treemap.d.ts +6 -0
- package/dist/esm/ssr/treemap.js +51 -0
- package/dist/esm/ssr/type.d.ts +30 -0
- package/dist/esm/ssr/type.js +1 -0
- package/dist/esm/ssr/word-cloud.d.ts +6 -0
- package/dist/esm/ssr/word-cloud.js +40 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/424.async.js +1 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +58 -31
- package/dist/umd/100.async.js +0 -1
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
7
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
8
|
+
import _get from "@babel/runtime/helpers/esm/get";
|
|
9
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
10
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
11
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
12
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
13
|
+
var _excluded = ["children"];
|
|
14
|
+
import { Rect } from '@antv/g';
|
|
15
|
+
import { createGraph, G6 } from '@antv/g6-ssr';
|
|
16
|
+
import { createCanvas } from 'canvas';
|
|
17
|
+
var register = G6.register,
|
|
18
|
+
BaseNode = G6.BaseNode,
|
|
19
|
+
BaseTransform = G6.BaseTransform,
|
|
20
|
+
ExtensionCategory = G6.ExtensionCategory,
|
|
21
|
+
idOf = G6.idOf,
|
|
22
|
+
positionOf = G6.positionOf,
|
|
23
|
+
treeToGraphData = G6.treeToGraphData;
|
|
24
|
+
var canvas = null;
|
|
25
|
+
var ctx = null;
|
|
26
|
+
var measureText = function measureText(style) {
|
|
27
|
+
if (!canvas) {
|
|
28
|
+
canvas = createCanvas(0, 0);
|
|
29
|
+
ctx = canvas.getContext('2d');
|
|
30
|
+
}
|
|
31
|
+
var font = [style.fontStyle || 'normal', style.fontWeight || 'normal', "".concat(style.fontSize || 12, "px"), style.fontFamily || 'sans-serif'].join(' ');
|
|
32
|
+
ctx.font = font;
|
|
33
|
+
return ctx.measureText(style.text).width;
|
|
34
|
+
};
|
|
35
|
+
var RootNodeStyle = {
|
|
36
|
+
fill: '#EFF0F0',
|
|
37
|
+
labelFill: '#262626',
|
|
38
|
+
labelFontSize: 24,
|
|
39
|
+
labelFontWeight: 600,
|
|
40
|
+
labelOffsetY: 8,
|
|
41
|
+
labelPlacement: 'center',
|
|
42
|
+
ports: [{
|
|
43
|
+
placement: 'right'
|
|
44
|
+
}, {
|
|
45
|
+
placement: 'left'
|
|
46
|
+
}],
|
|
47
|
+
radius: 8
|
|
48
|
+
};
|
|
49
|
+
var NodeStyle = {
|
|
50
|
+
fill: 'transparent',
|
|
51
|
+
labelPlacement: 'center',
|
|
52
|
+
labelFontSize: 16,
|
|
53
|
+
ports: [{
|
|
54
|
+
placement: 'right-bottom'
|
|
55
|
+
}, {
|
|
56
|
+
placement: 'left-bottom'
|
|
57
|
+
}]
|
|
58
|
+
};
|
|
59
|
+
var getNodeWidth = function getNodeWidth(nodeId, isRoot) {
|
|
60
|
+
var padding = isRoot ? 40 : 30;
|
|
61
|
+
var nodeStyle = isRoot ? RootNodeStyle : NodeStyle;
|
|
62
|
+
return measureText({
|
|
63
|
+
text: nodeId,
|
|
64
|
+
fontSize: nodeStyle.labelFontSize,
|
|
65
|
+
fontFamily: 'Gill Sans'
|
|
66
|
+
}) + padding;
|
|
67
|
+
};
|
|
68
|
+
var getNodeSize = function getNodeSize(nodeId, isRoot) {
|
|
69
|
+
var width = getNodeWidth(nodeId, isRoot);
|
|
70
|
+
var height = isRoot ? 36 : 32;
|
|
71
|
+
return [width, height];
|
|
72
|
+
};
|
|
73
|
+
var MindmapNode = /*#__PURE__*/function (_BaseNode) {
|
|
74
|
+
_inherits(MindmapNode, _BaseNode);
|
|
75
|
+
var _super = _createSuper(MindmapNode);
|
|
76
|
+
function MindmapNode() {
|
|
77
|
+
_classCallCheck(this, MindmapNode);
|
|
78
|
+
return _super.apply(this, arguments);
|
|
79
|
+
}
|
|
80
|
+
_createClass(MindmapNode, [{
|
|
81
|
+
key: "childrenData",
|
|
82
|
+
get: function get() {
|
|
83
|
+
return this.context.model.getChildrenData(this.id);
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "rootId",
|
|
87
|
+
get: function get() {
|
|
88
|
+
return idOf(this.context.model.getRootsData()[0]);
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "isShowCollapse",
|
|
92
|
+
value: function isShowCollapse(attributes) {
|
|
93
|
+
var collapsed = attributes.collapsed,
|
|
94
|
+
showIcon = attributes.showIcon;
|
|
95
|
+
return !collapsed && showIcon && this.childrenData.length > 0;
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "getCollapseStyle",
|
|
99
|
+
value: function getCollapseStyle(attributes) {
|
|
100
|
+
var showIcon = attributes.showIcon,
|
|
101
|
+
color = attributes.color,
|
|
102
|
+
direction = attributes.direction;
|
|
103
|
+
if (!this.isShowCollapse(attributes)) return false;
|
|
104
|
+
var _this$getSize = this.getSize(attributes),
|
|
105
|
+
_this$getSize2 = _slicedToArray(_this$getSize, 2),
|
|
106
|
+
width = _this$getSize2[0],
|
|
107
|
+
height = _this$getSize2[1];
|
|
108
|
+
return {
|
|
109
|
+
backgroundFill: color,
|
|
110
|
+
backgroundHeight: 12,
|
|
111
|
+
backgroundWidth: 12,
|
|
112
|
+
cursor: 'pointer',
|
|
113
|
+
fill: '#fff',
|
|
114
|
+
fontFamily: 'iconfont',
|
|
115
|
+
fontSize: 8,
|
|
116
|
+
text: "\uE6E4",
|
|
117
|
+
textAlign: 'center',
|
|
118
|
+
transform: direction === 'left' ? [['rotate', 90]] : [['rotate', -90]],
|
|
119
|
+
visibility: showIcon ? 'visible' : 'hidden',
|
|
120
|
+
x: direction === 'left' ? -6 : width + 6,
|
|
121
|
+
y: height
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
key: "drawCollapseShape",
|
|
126
|
+
value: function drawCollapseShape() {}
|
|
127
|
+
}, {
|
|
128
|
+
key: "getCountStyle",
|
|
129
|
+
value: function getCountStyle(attributes) {
|
|
130
|
+
var collapsed = attributes.collapsed,
|
|
131
|
+
color = attributes.color,
|
|
132
|
+
direction = attributes.direction;
|
|
133
|
+
var count = this.context.model.getDescendantsData(this.id).length;
|
|
134
|
+
if (!collapsed || count === 0) return false;
|
|
135
|
+
var _this$getSize3 = this.getSize(attributes),
|
|
136
|
+
_this$getSize4 = _slicedToArray(_this$getSize3, 2),
|
|
137
|
+
width = _this$getSize4[0],
|
|
138
|
+
height = _this$getSize4[1];
|
|
139
|
+
return {
|
|
140
|
+
backgroundFill: color,
|
|
141
|
+
backgroundHeight: 12,
|
|
142
|
+
backgroundWidth: 12,
|
|
143
|
+
cursor: 'pointer',
|
|
144
|
+
fill: '#fff',
|
|
145
|
+
fontSize: 8,
|
|
146
|
+
text: count.toString(),
|
|
147
|
+
textAlign: 'center',
|
|
148
|
+
x: direction === 'left' ? -6 : width + 6,
|
|
149
|
+
y: height
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "drawCountShape",
|
|
154
|
+
value: function drawCountShape() {}
|
|
155
|
+
}, {
|
|
156
|
+
key: "getAddStyle",
|
|
157
|
+
value: function getAddStyle(attributes) {
|
|
158
|
+
var collapsed = attributes.collapsed,
|
|
159
|
+
showIcon = attributes.showIcon,
|
|
160
|
+
direction = attributes.direction;
|
|
161
|
+
if (collapsed || !showIcon) return false;
|
|
162
|
+
var _this$getSize5 = this.getSize(attributes),
|
|
163
|
+
_this$getSize6 = _slicedToArray(_this$getSize5, 2),
|
|
164
|
+
width = _this$getSize6[0],
|
|
165
|
+
height = _this$getSize6[1];
|
|
166
|
+
var color = '#ddd';
|
|
167
|
+
var offsetX = this.isShowCollapse(attributes) ? 24 : 12;
|
|
168
|
+
var isRoot = this.id === this.rootId;
|
|
169
|
+
return {
|
|
170
|
+
backgroundFill: '#fff',
|
|
171
|
+
backgroundHeight: 12,
|
|
172
|
+
backgroundLineWidth: 1,
|
|
173
|
+
backgroundStroke: color,
|
|
174
|
+
backgroundWidth: 12,
|
|
175
|
+
cursor: 'pointer',
|
|
176
|
+
fill: color,
|
|
177
|
+
fontFamily: 'iconfont',
|
|
178
|
+
fontSize: 8,
|
|
179
|
+
text: "\uE664",
|
|
180
|
+
textAlign: 'center',
|
|
181
|
+
x: isRoot ? width + 12 : direction === 'left' ? -offsetX : width + offsetX,
|
|
182
|
+
y: isRoot ? height / 2 : height
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}, {
|
|
186
|
+
key: "getAddBarStyle",
|
|
187
|
+
value: function getAddBarStyle(attributes) {
|
|
188
|
+
var collapsed = attributes.collapsed,
|
|
189
|
+
showIcon = attributes.showIcon,
|
|
190
|
+
direction = attributes.direction,
|
|
191
|
+
_attributes$color = attributes.color,
|
|
192
|
+
color = _attributes$color === void 0 ? '#1783FF' : _attributes$color;
|
|
193
|
+
if (collapsed || !showIcon) return false;
|
|
194
|
+
var _this$getSize7 = this.getSize(attributes),
|
|
195
|
+
_this$getSize8 = _slicedToArray(_this$getSize7, 2),
|
|
196
|
+
width = _this$getSize8[0],
|
|
197
|
+
height = _this$getSize8[1];
|
|
198
|
+
var offsetX = this.isShowCollapse(attributes) ? 12 : 0;
|
|
199
|
+
var isRoot = this.id === this.rootId;
|
|
200
|
+
var HEIGHT = 2;
|
|
201
|
+
var WIDTH = 6;
|
|
202
|
+
return {
|
|
203
|
+
cursor: 'pointer',
|
|
204
|
+
fill: direction === 'left' ? "linear-gradient(180deg, #fff 20%, ".concat(color, ")") : "linear-gradient(0deg, #fff 20%, ".concat(color, ")"),
|
|
205
|
+
height: HEIGHT,
|
|
206
|
+
width: WIDTH,
|
|
207
|
+
x: isRoot ? width : direction === 'left' ? -offsetX - WIDTH : width + offsetX,
|
|
208
|
+
y: isRoot ? height / 2 - HEIGHT / 2 : height - HEIGHT / 2,
|
|
209
|
+
zIndex: -1
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "drawAddShape",
|
|
214
|
+
value: function drawAddShape() {}
|
|
215
|
+
}, {
|
|
216
|
+
key: "forwardEvent",
|
|
217
|
+
value: function forwardEvent() {}
|
|
218
|
+
}, {
|
|
219
|
+
key: "getKeyStyle",
|
|
220
|
+
value: function getKeyStyle(attributes) {
|
|
221
|
+
var _this$getSize9 = this.getSize(attributes),
|
|
222
|
+
_this$getSize10 = _slicedToArray(_this$getSize9, 2),
|
|
223
|
+
width = _this$getSize10[0],
|
|
224
|
+
height = _this$getSize10[1];
|
|
225
|
+
var keyShape = _get(_getPrototypeOf(MindmapNode.prototype), "getKeyStyle", this).call(this, attributes);
|
|
226
|
+
return _objectSpread({
|
|
227
|
+
width: width,
|
|
228
|
+
height: height
|
|
229
|
+
}, keyShape);
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "drawKeyShape",
|
|
233
|
+
value: function drawKeyShape(attributes, container) {
|
|
234
|
+
var keyStyle = this.getKeyStyle(attributes);
|
|
235
|
+
// @ts-ignore
|
|
236
|
+
return this.upsert('key', Rect, keyStyle, container);
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "render",
|
|
240
|
+
value: function render() {
|
|
241
|
+
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.parsedAttributes;
|
|
242
|
+
var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
|
|
243
|
+
_get(_getPrototypeOf(MindmapNode.prototype), "render", this).call(this, attributes, container);
|
|
244
|
+
}
|
|
245
|
+
}]);
|
|
246
|
+
return MindmapNode;
|
|
247
|
+
}(BaseNode);
|
|
248
|
+
_defineProperty(MindmapNode, "defaultStyleProps", _objectSpread(_objectSpread({}, BaseNode.defaultStyleProps), {}, {
|
|
249
|
+
showIcon: false
|
|
250
|
+
}));
|
|
251
|
+
var AssignColorByBranch = /*#__PURE__*/function (_BaseTransform) {
|
|
252
|
+
_inherits(AssignColorByBranch, _BaseTransform);
|
|
253
|
+
var _super2 = _createSuper(AssignColorByBranch);
|
|
254
|
+
function AssignColorByBranch(context, options) {
|
|
255
|
+
_classCallCheck(this, AssignColorByBranch);
|
|
256
|
+
return _super2.call(this, context, Object.assign({}, AssignColorByBranch.defaultOptions, options));
|
|
257
|
+
}
|
|
258
|
+
_createClass(AssignColorByBranch, [{
|
|
259
|
+
key: "beforeDraw",
|
|
260
|
+
value: function beforeDraw(input) {
|
|
261
|
+
var _this = this;
|
|
262
|
+
var nodes = this.context.model.getNodeData();
|
|
263
|
+
if (nodes.length === 0) return input;
|
|
264
|
+
var colorIndex = 0;
|
|
265
|
+
var dfs = function dfs(nodeId, color) {
|
|
266
|
+
var _node$children;
|
|
267
|
+
var node = nodes.find(function (datum) {
|
|
268
|
+
return datum.id == nodeId;
|
|
269
|
+
});
|
|
270
|
+
if (!node) return;
|
|
271
|
+
node.style || (node.style = {});
|
|
272
|
+
node.style.color = color || _this.options.colors[colorIndex++ % _this.options.colors.length];
|
|
273
|
+
(_node$children = node.children) === null || _node$children === void 0 || _node$children.forEach(function (childId) {
|
|
274
|
+
var _node$style;
|
|
275
|
+
return dfs(childId, (_node$style = node.style) === null || _node$style === void 0 ? void 0 : _node$style.color);
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
// @ts-ignore
|
|
279
|
+
nodes.filter(function (node) {
|
|
280
|
+
return node.depth === 1;
|
|
281
|
+
}).forEach(function (rootNode) {
|
|
282
|
+
return dfs(rootNode.id);
|
|
283
|
+
});
|
|
284
|
+
return input;
|
|
285
|
+
}
|
|
286
|
+
}]);
|
|
287
|
+
return AssignColorByBranch;
|
|
288
|
+
}(BaseTransform);
|
|
289
|
+
_defineProperty(AssignColorByBranch, "defaultOptions", {
|
|
290
|
+
colors: ['#1783FF', '#F08F56', '#D580FF', '#00C9C9', '#7863FF', '#DB9D0D', '#60C42D', '#FF80CA', '#2491B3', '#17C76F']
|
|
291
|
+
});
|
|
292
|
+
register(ExtensionCategory.NODE, 'mindmap', MindmapNode);
|
|
293
|
+
register(ExtensionCategory.TRANSFORM, 'assign-color-by-branch', AssignColorByBranch);
|
|
294
|
+
var getNodeSide = function getNodeSide(nodeData, parentData) {
|
|
295
|
+
if (!parentData) return 'center';
|
|
296
|
+
var nodePositionX = positionOf(nodeData)[0];
|
|
297
|
+
var parentPositionX = positionOf(parentData)[0];
|
|
298
|
+
return parentPositionX > nodePositionX ? 'left' : 'right';
|
|
299
|
+
};
|
|
300
|
+
function visTreeData2GraphData(data) {
|
|
301
|
+
return treeToGraphData(data, {
|
|
302
|
+
getNodeData: function getNodeData(datum, depth) {
|
|
303
|
+
datum.id = datum.name;
|
|
304
|
+
datum.depth = depth;
|
|
305
|
+
if (!datum.children) return datum;
|
|
306
|
+
var children = datum.children,
|
|
307
|
+
restDatum = _objectWithoutProperties(datum, _excluded);
|
|
308
|
+
return _objectSpread(_objectSpread({}, restDatum), {}, {
|
|
309
|
+
children: children.map(function (child) {
|
|
310
|
+
return child.name;
|
|
311
|
+
})
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
getEdgeData: function getEdgeData(source, target) {
|
|
315
|
+
return {
|
|
316
|
+
source: source.name,
|
|
317
|
+
target: target.name
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
export function MindMap(_x) {
|
|
323
|
+
return _MindMap.apply(this, arguments);
|
|
324
|
+
}
|
|
325
|
+
function _MindMap() {
|
|
326
|
+
_MindMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
327
|
+
var data, width, height, dataParse, rootId;
|
|
328
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
329
|
+
while (1) switch (_context.prev = _context.next) {
|
|
330
|
+
case 0:
|
|
331
|
+
data = options.data, width = options.width, height = options.height;
|
|
332
|
+
dataParse = visTreeData2GraphData(data);
|
|
333
|
+
rootId = data.name;
|
|
334
|
+
_context.next = 5;
|
|
335
|
+
return createGraph({
|
|
336
|
+
waitForRender: 300,
|
|
337
|
+
width: width,
|
|
338
|
+
height: height,
|
|
339
|
+
data: dataParse,
|
|
340
|
+
padding: 24,
|
|
341
|
+
autoFit: {
|
|
342
|
+
type: 'view'
|
|
343
|
+
},
|
|
344
|
+
node: {
|
|
345
|
+
type: 'mindmap',
|
|
346
|
+
// @ts-ignore
|
|
347
|
+
style: function style(d) {
|
|
348
|
+
var _d$style, _d$style2, _d$style3;
|
|
349
|
+
var direction = getNodeSide(d, this.getParentData(idOf(d), 'tree'));
|
|
350
|
+
var isRoot = idOf(d) === rootId;
|
|
351
|
+
var depth = d.depth;
|
|
352
|
+
return _objectSpread(_objectSpread({
|
|
353
|
+
direction: direction,
|
|
354
|
+
labelText: idOf(d),
|
|
355
|
+
size: getNodeSize(idOf(d), isRoot),
|
|
356
|
+
labelFontFamily: 'Gill Sans',
|
|
357
|
+
lineWidth: 2,
|
|
358
|
+
radius: 8,
|
|
359
|
+
stroke: depth === 0 ? '#f1f4f5' : (_d$style = d.style) === null || _d$style === void 0 ? void 0 : _d$style.color,
|
|
360
|
+
labelBackground: true,
|
|
361
|
+
labelBackgroundFill: 'transparent',
|
|
362
|
+
labelPadding: direction === 'left' ? [2, 0, 10, 40] : [2, 40, 10, 0]
|
|
363
|
+
}, isRoot ? RootNodeStyle : NodeStyle), {}, {
|
|
364
|
+
fill: depth === 0 ? '#f1f4f5' : depth === 1 ? (_d$style2 = d.style) === null || _d$style2 === void 0 ? void 0 : _d$style2.color : 'transparent',
|
|
365
|
+
labelFill: depth === 0 ? '#262626' : depth === 1 ? '#FFF' : (_d$style3 = d.style) === null || _d$style3 === void 0 ? void 0 : _d$style3.color,
|
|
366
|
+
ports: [{
|
|
367
|
+
placement: 'left'
|
|
368
|
+
}, {
|
|
369
|
+
placement: 'right'
|
|
370
|
+
}]
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
edge: {
|
|
375
|
+
type: 'cubic-horizontal',
|
|
376
|
+
style: {
|
|
377
|
+
lineWidth: 1.5,
|
|
378
|
+
// @ts-ignore
|
|
379
|
+
stroke: function stroke(data) {
|
|
380
|
+
// @ts-ignore
|
|
381
|
+
return this.getNodeData(data.target).depth > 1 ?
|
|
382
|
+
// @ts-ignore
|
|
383
|
+
this.getNodeData(data.target).style.color : '#99ADD1';
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
layout: {
|
|
388
|
+
type: 'mindmap',
|
|
389
|
+
direction: 'H',
|
|
390
|
+
getHeight: function getHeight() {
|
|
391
|
+
return 30;
|
|
392
|
+
},
|
|
393
|
+
getWidth: function getWidth(node) {
|
|
394
|
+
return getNodeWidth(node.id, node.id === rootId);
|
|
395
|
+
},
|
|
396
|
+
getVGap: function getVGap() {
|
|
397
|
+
return 14;
|
|
398
|
+
},
|
|
399
|
+
getHGap: function getHGap() {
|
|
400
|
+
return 64;
|
|
401
|
+
},
|
|
402
|
+
animation: false
|
|
403
|
+
},
|
|
404
|
+
transforms: ['assign-color-by-branch'],
|
|
405
|
+
animation: false
|
|
406
|
+
});
|
|
407
|
+
case 5:
|
|
408
|
+
return _context.abrupt("return", _context.sent);
|
|
409
|
+
case 6:
|
|
410
|
+
case "end":
|
|
411
|
+
return _context.stop();
|
|
412
|
+
}
|
|
413
|
+
}, _callee);
|
|
414
|
+
}));
|
|
415
|
+
return _MindMap.apply(this, arguments);
|
|
416
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type NetworkGraphProps } from '../export';
|
|
2
|
+
import { type BaseChartConfig } from './type';
|
|
3
|
+
export type NetworkGraphOptions = BaseChartConfig & {
|
|
4
|
+
type: 'network-graph';
|
|
5
|
+
} & NetworkGraphProps;
|
|
6
|
+
export declare function NetworkGraph(options: NetworkGraphOptions): Promise<import("@antv/g6-ssr").Graph>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import { createGraph } from '@antv/g6-ssr';
|
|
5
|
+
export function NetworkGraph(_x) {
|
|
6
|
+
return _NetworkGraph.apply(this, arguments);
|
|
7
|
+
}
|
|
8
|
+
function _NetworkGraph() {
|
|
9
|
+
_NetworkGraph = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
10
|
+
var data, _options$width, width, _options$height, height, graphData;
|
|
11
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
data = options.data, _options$width = options.width, width = _options$width === void 0 ? 600 : _options$width, _options$height = options.height, height = _options$height === void 0 ? 400 : _options$height;
|
|
15
|
+
graphData = {
|
|
16
|
+
nodes: data.nodes.map(function (node) {
|
|
17
|
+
return _objectSpread(_objectSpread({}, node), {}, {
|
|
18
|
+
id: node.name
|
|
19
|
+
});
|
|
20
|
+
}),
|
|
21
|
+
edges: data.edges.map(function (edge) {
|
|
22
|
+
return _objectSpread(_objectSpread({}, edge), {}, {
|
|
23
|
+
id: "".concat(edge.source, "-").concat(edge.target)
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
_context.next = 4;
|
|
28
|
+
return createGraph({
|
|
29
|
+
data: graphData,
|
|
30
|
+
width: width,
|
|
31
|
+
height: height,
|
|
32
|
+
devicePixelRatio: 3,
|
|
33
|
+
autoFit: 'view',
|
|
34
|
+
padding: 20,
|
|
35
|
+
animation: false,
|
|
36
|
+
node: {
|
|
37
|
+
type: 'circle',
|
|
38
|
+
style: {
|
|
39
|
+
size: 20,
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
labelText: function labelText(d) {
|
|
42
|
+
return d.name;
|
|
43
|
+
},
|
|
44
|
+
labelSize: 10,
|
|
45
|
+
labelFontSize: 10,
|
|
46
|
+
labelBackground: true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
edge: {
|
|
50
|
+
style: {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
labelText: function labelText(d) {
|
|
53
|
+
return d.name;
|
|
54
|
+
},
|
|
55
|
+
labelFontSize: 10,
|
|
56
|
+
labelBackground: true,
|
|
57
|
+
endArrow: true
|
|
58
|
+
},
|
|
59
|
+
animation: {
|
|
60
|
+
enter: false
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
layout: {
|
|
64
|
+
type: 'force-atlas2',
|
|
65
|
+
preventOverlap: true,
|
|
66
|
+
kr: 600
|
|
67
|
+
},
|
|
68
|
+
transforms: ['process-parallel-edges']
|
|
69
|
+
});
|
|
70
|
+
case 4:
|
|
71
|
+
return _context.abrupt("return", _context.sent);
|
|
72
|
+
case 5:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context.stop();
|
|
75
|
+
}
|
|
76
|
+
}, _callee);
|
|
77
|
+
}));
|
|
78
|
+
return _NetworkGraph.apply(this, arguments);
|
|
79
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import { createChart } from '@antv/g2-ssr';
|
|
4
|
+
export function Pie(_x) {
|
|
5
|
+
return _Pie.apply(this, arguments);
|
|
6
|
+
}
|
|
7
|
+
function _Pie() {
|
|
8
|
+
_Pie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
9
|
+
var data, title, width, height, innerRadius;
|
|
10
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
11
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
data = options.data, title = options.title, width = options.width, height = options.height, innerRadius = options.innerRadius;
|
|
14
|
+
_context.next = 3;
|
|
15
|
+
return createChart({
|
|
16
|
+
type: 'interval',
|
|
17
|
+
title: title,
|
|
18
|
+
width: width,
|
|
19
|
+
height: height,
|
|
20
|
+
data: data,
|
|
21
|
+
encode: {
|
|
22
|
+
y: 'value',
|
|
23
|
+
color: 'category'
|
|
24
|
+
},
|
|
25
|
+
transform: [{
|
|
26
|
+
type: 'stackY'
|
|
27
|
+
}],
|
|
28
|
+
coordinate: {
|
|
29
|
+
type: 'theta',
|
|
30
|
+
outerRadius: 0.95,
|
|
31
|
+
innerRadius: innerRadius
|
|
32
|
+
},
|
|
33
|
+
style: {
|
|
34
|
+
radius: 4,
|
|
35
|
+
stroke: '#fff',
|
|
36
|
+
lineWidth: 1
|
|
37
|
+
},
|
|
38
|
+
labels: [{
|
|
39
|
+
text: function text(data) {
|
|
40
|
+
return "".concat(data.category, ": ").concat(data.value);
|
|
41
|
+
},
|
|
42
|
+
position: 'outside',
|
|
43
|
+
radius: 0.85,
|
|
44
|
+
fontSize: 12
|
|
45
|
+
}],
|
|
46
|
+
legend: {
|
|
47
|
+
color: {
|
|
48
|
+
position: 'bottom',
|
|
49
|
+
layout: {
|
|
50
|
+
justifyContent: 'center'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
animate: false,
|
|
55
|
+
axis: false
|
|
56
|
+
});
|
|
57
|
+
case 3:
|
|
58
|
+
return _context.abrupt("return", _context.sent);
|
|
59
|
+
case 4:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}, _callee);
|
|
64
|
+
}));
|
|
65
|
+
return _Pie.apply(this, arguments);
|
|
66
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type RadarProps } from '../export';
|
|
2
|
+
import { type BaseChartConfig } from './type';
|
|
3
|
+
export type RadarOptions = BaseChartConfig & {
|
|
4
|
+
type: 'radar';
|
|
5
|
+
} & RadarProps;
|
|
6
|
+
export declare function Radar(options: RadarOptions): Promise<import("@antv/g2-ssr").Chart>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import { createChart } from '@antv/g2-ssr';
|
|
4
|
+
export function Radar(_x) {
|
|
5
|
+
return _Radar.apply(this, arguments);
|
|
6
|
+
}
|
|
7
|
+
function _Radar() {
|
|
8
|
+
_Radar = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
9
|
+
var _;
|
|
10
|
+
var data, title, width, height, hasGroupField, encode;
|
|
11
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
data = options.data, title = options.title, width = options.width, height = options.height;
|
|
15
|
+
hasGroupField = ((_ = (data || [])[0]) === null || _ === void 0 ? void 0 : _.group) !== undefined;
|
|
16
|
+
encode = {};
|
|
17
|
+
if (hasGroupField) {
|
|
18
|
+
encode = {
|
|
19
|
+
x: 'name',
|
|
20
|
+
y: 'value',
|
|
21
|
+
color: 'group'
|
|
22
|
+
};
|
|
23
|
+
} else {
|
|
24
|
+
encode = {
|
|
25
|
+
x: 'name',
|
|
26
|
+
y: 'value'
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
_context.next = 6;
|
|
30
|
+
return createChart({
|
|
31
|
+
title: title,
|
|
32
|
+
type: 'view',
|
|
33
|
+
width: width,
|
|
34
|
+
data: data,
|
|
35
|
+
height: height,
|
|
36
|
+
children: [{
|
|
37
|
+
axis: {
|
|
38
|
+
x: {
|
|
39
|
+
grid: true,
|
|
40
|
+
line: true
|
|
41
|
+
},
|
|
42
|
+
y: {
|
|
43
|
+
zIndex: 1,
|
|
44
|
+
title: false,
|
|
45
|
+
line: true,
|
|
46
|
+
nice: true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
coordinateType: 'polar',
|
|
51
|
+
scale: {
|
|
52
|
+
x: {
|
|
53
|
+
padding: 0.5,
|
|
54
|
+
align: 0
|
|
55
|
+
},
|
|
56
|
+
y: {
|
|
57
|
+
nice: true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
coordinate: {
|
|
61
|
+
type: 'polar'
|
|
62
|
+
},
|
|
63
|
+
encode: encode,
|
|
64
|
+
type: 'line'
|
|
65
|
+
}, {
|
|
66
|
+
style: {
|
|
67
|
+
fillOpacity: 0.5
|
|
68
|
+
},
|
|
69
|
+
encode: encode,
|
|
70
|
+
scale: {
|
|
71
|
+
x: {
|
|
72
|
+
padding: 0.5,
|
|
73
|
+
align: 0
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
type: 'area'
|
|
77
|
+
}]
|
|
78
|
+
});
|
|
79
|
+
case 6:
|
|
80
|
+
return _context.abrupt("return", _context.sent);
|
|
81
|
+
case 7:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context.stop();
|
|
84
|
+
}
|
|
85
|
+
}, _callee);
|
|
86
|
+
}));
|
|
87
|
+
return _Radar.apply(this, arguments);
|
|
88
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ScatterProps } from '../export';
|
|
2
|
+
import { type BaseChartConfig } from './type';
|
|
3
|
+
export type ScatterOptions = BaseChartConfig & {
|
|
4
|
+
type: 'scatter';
|
|
5
|
+
} & ScatterProps;
|
|
6
|
+
export declare function Scatter(options: ScatterOptions): Promise<import("@antv/g2-ssr").Chart>;
|