@antv/g6 5.0.1-beta.2 → 5.0.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.
- package/dist/g6.min.js +2 -2
- package/dist/lib/behaviors/click-select.d.ts +4 -5
- package/dist/lib/elements/base-element.d.ts +1 -22
- package/dist/lib/elements/combos/base-combo.d.ts +4 -4
- package/dist/lib/elements/edges/base-edge.d.ts +4 -2
- package/dist/lib/elements/effect.d.ts +17 -0
- package/dist/lib/elements/nodes/base-node.d.ts +5 -4
- package/dist/lib/elements/nodes/diamond.d.ts +0 -1
- package/dist/lib/elements/shapes/badge.d.ts +17 -6
- package/dist/lib/elements/shapes/base-shape.d.ts +9 -3
- package/dist/lib/elements/shapes/icon.d.ts +15 -3
- package/dist/lib/elements/shapes/label.d.ts +18 -7
- package/dist/lib/exports.d.ts +3 -2
- package/dist/lib/index.d.ts +5 -1
- package/dist/lib/layouts/base-layout.d.ts +3 -1
- package/dist/lib/plugins/bubble-sets.d.ts +2 -2
- package/dist/lib/plugins/hull/index.d.ts +2 -2
- package/dist/lib/runtime/canvas.d.ts +15 -2
- package/dist/lib/runtime/data.d.ts +7 -16
- package/dist/lib/runtime/element.d.ts +18 -2
- package/dist/lib/runtime/graph.d.ts +372 -108
- package/dist/lib/spec/element/edge.d.ts +1 -1
- package/dist/lib/spec/element/node.d.ts +1 -1
- package/dist/lib/transforms/process-parallel-edges.d.ts +2 -2
- package/dist/lib/types/callable.d.ts +0 -11
- package/dist/lib/types/data.d.ts +12 -0
- package/dist/lib/types/edge.d.ts +11 -0
- package/dist/lib/types/element.d.ts +100 -9
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/types/point.d.ts +0 -1
- package/dist/lib/utils/element.d.ts +2 -2
- package/dist/lib/utils/layout.d.ts +2 -2
- package/dist/lib/utils/path.d.ts +3 -3
- package/dist/lib/utils/position.d.ts +8 -8
- package/dist/lib/utils/style.d.ts +13 -8
- package/esm/behaviors/click-select.d.ts +4 -5
- package/esm/behaviors/click-select.js +59 -50
- package/esm/behaviors/click-select.js.map +1 -1
- package/esm/behaviors/lasso-select.js.map +1 -1
- package/esm/elements/base-element.d.ts +1 -22
- package/esm/elements/base-element.js +0 -21
- package/esm/elements/base-element.js.map +1 -1
- package/esm/elements/combos/base-combo.d.ts +4 -4
- package/esm/elements/combos/base-combo.js +27 -4
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/edges/base-edge.d.ts +4 -2
- package/esm/elements/edges/base-edge.js +41 -7
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/effect.d.ts +17 -0
- package/esm/elements/effect.js +70 -0
- package/esm/elements/effect.js.map +1 -0
- package/esm/elements/nodes/base-node.d.ts +5 -4
- package/esm/elements/nodes/base-node.js +33 -14
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/circle.js +1 -1
- package/esm/elements/nodes/circle.js.map +1 -1
- package/esm/elements/nodes/diamond.d.ts +0 -1
- package/esm/elements/nodes/diamond.js +0 -6
- package/esm/elements/nodes/diamond.js.map +1 -1
- package/esm/elements/nodes/ellipse.js +1 -1
- package/esm/elements/nodes/ellipse.js.map +1 -1
- package/esm/elements/nodes/image.js +2 -2
- package/esm/elements/nodes/image.js.map +1 -1
- package/esm/elements/nodes/rect.js +1 -1
- package/esm/elements/nodes/rect.js.map +1 -1
- package/esm/elements/shapes/badge.d.ts +17 -6
- package/esm/elements/shapes/badge.js +9 -0
- package/esm/elements/shapes/badge.js.map +1 -1
- package/esm/elements/shapes/base-shape.d.ts +9 -3
- package/esm/elements/shapes/base-shape.js +33 -15
- package/esm/elements/shapes/base-shape.js.map +1 -1
- package/esm/elements/shapes/icon.d.ts +15 -3
- package/esm/elements/shapes/icon.js +12 -4
- package/esm/elements/shapes/icon.js.map +1 -1
- package/esm/elements/shapes/label.d.ts +18 -7
- package/esm/elements/shapes/label.js +10 -0
- package/esm/elements/shapes/label.js.map +1 -1
- package/esm/elements/shapes/polygon.js +1 -1
- package/esm/elements/shapes/polygon.js.map +1 -1
- package/esm/exports.d.ts +3 -2
- package/esm/exports.js +1 -1
- package/esm/exports.js.map +1 -1
- package/esm/index.d.ts +5 -1
- package/esm/index.js +5 -1
- package/esm/index.js.map +1 -1
- package/esm/layouts/base-layout.d.ts +3 -1
- package/esm/layouts/base-layout.js +3 -1
- package/esm/layouts/base-layout.js.map +1 -1
- package/esm/plugins/bubble-sets.d.ts +2 -2
- package/esm/plugins/bubble-sets.js.map +1 -1
- package/esm/plugins/hull/index.d.ts +2 -2
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/runtime/canvas.d.ts +15 -2
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +7 -16
- package/esm/runtime/data.js +14 -34
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +18 -2
- package/esm/runtime/element.js +68 -20
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +372 -108
- package/esm/runtime/graph.js +271 -76
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +1 -1
- package/esm/runtime/layout.js.map +1 -1
- package/esm/spec/element/edge.d.ts +1 -1
- package/esm/spec/element/node.d.ts +1 -1
- package/esm/themes/base.js +2 -0
- package/esm/themes/base.js.map +1 -1
- package/esm/transforms/collapse-expand-node.js +14 -4
- package/esm/transforms/collapse-expand-node.js.map +1 -1
- package/esm/transforms/process-parallel-edges.d.ts +2 -2
- package/esm/types/callable.d.ts +0 -11
- package/esm/types/data.d.ts +12 -0
- package/esm/types/edge.d.ts +11 -0
- package/esm/types/element.d.ts +100 -9
- package/esm/types/index.d.ts +0 -1
- package/esm/types/point.d.ts +0 -1
- package/esm/utils/element.d.ts +2 -2
- package/esm/utils/element.js.map +1 -1
- package/esm/utils/layout.d.ts +2 -2
- package/esm/utils/layout.js +4 -4
- package/esm/utils/layout.js.map +1 -1
- package/esm/utils/path.d.ts +3 -3
- package/esm/utils/path.js +1 -1
- package/esm/utils/path.js.map +1 -1
- package/esm/utils/position.d.ts +8 -8
- package/esm/utils/position.js +2 -2
- package/esm/utils/position.js.map +1 -1
- package/esm/utils/style.d.ts +13 -8
- package/esm/utils/style.js +16 -11
- package/esm/utils/style.js.map +1 -1
- package/lib/behaviors/click-select.d.ts +4 -5
- package/lib/behaviors/click-select.js +59 -50
- package/lib/behaviors/click-select.js.map +1 -1
- package/lib/behaviors/lasso-select.js.map +1 -1
- package/lib/elements/base-element.d.ts +1 -22
- package/lib/elements/base-element.js +0 -21
- package/lib/elements/base-element.js.map +1 -1
- package/lib/elements/combos/base-combo.d.ts +4 -4
- package/lib/elements/combos/base-combo.js +27 -4
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/edges/base-edge.d.ts +4 -2
- package/lib/elements/edges/base-edge.js +41 -7
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/effect.d.ts +17 -0
- package/lib/elements/effect.js +74 -0
- package/lib/elements/effect.js.map +1 -0
- package/lib/elements/nodes/base-node.d.ts +5 -4
- package/lib/elements/nodes/base-node.js +33 -14
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/circle.js +1 -1
- package/lib/elements/nodes/circle.js.map +1 -1
- package/lib/elements/nodes/diamond.d.ts +0 -1
- package/lib/elements/nodes/diamond.js +0 -6
- package/lib/elements/nodes/diamond.js.map +1 -1
- package/lib/elements/nodes/ellipse.js +1 -1
- package/lib/elements/nodes/ellipse.js.map +1 -1
- package/lib/elements/nodes/image.js +2 -2
- package/lib/elements/nodes/image.js.map +1 -1
- package/lib/elements/nodes/rect.js +1 -1
- package/lib/elements/nodes/rect.js.map +1 -1
- package/lib/elements/shapes/badge.d.ts +17 -6
- package/lib/elements/shapes/badge.js +9 -0
- package/lib/elements/shapes/badge.js.map +1 -1
- package/lib/elements/shapes/base-shape.d.ts +9 -3
- package/lib/elements/shapes/base-shape.js +33 -15
- package/lib/elements/shapes/base-shape.js.map +1 -1
- package/lib/elements/shapes/icon.d.ts +15 -3
- package/lib/elements/shapes/icon.js +12 -4
- package/lib/elements/shapes/icon.js.map +1 -1
- package/lib/elements/shapes/label.d.ts +18 -7
- package/lib/elements/shapes/label.js +10 -0
- package/lib/elements/shapes/label.js.map +1 -1
- package/lib/elements/shapes/polygon.js +1 -1
- package/lib/elements/shapes/polygon.js.map +1 -1
- package/lib/exports.d.ts +3 -2
- package/lib/exports.js +5 -2
- package/lib/exports.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/lib/layouts/base-layout.d.ts +3 -1
- package/lib/layouts/base-layout.js +3 -1
- package/lib/layouts/base-layout.js.map +1 -1
- package/lib/plugins/bubble-sets.d.ts +2 -2
- package/lib/plugins/bubble-sets.js.map +1 -1
- package/lib/plugins/hull/index.d.ts +2 -2
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/runtime/canvas.d.ts +15 -2
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +7 -16
- package/lib/runtime/data.js +14 -34
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +18 -2
- package/lib/runtime/element.js +68 -20
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +372 -108
- package/lib/runtime/graph.js +271 -76
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +1 -1
- package/lib/runtime/layout.js.map +1 -1
- package/lib/spec/element/edge.d.ts +1 -1
- package/lib/spec/element/node.d.ts +1 -1
- package/lib/themes/base.js +2 -0
- package/lib/themes/base.js.map +1 -1
- package/lib/transforms/collapse-expand-node.js +14 -4
- package/lib/transforms/collapse-expand-node.js.map +1 -1
- package/lib/transforms/process-parallel-edges.d.ts +2 -2
- package/lib/types/callable.d.ts +0 -11
- package/lib/types/data.d.ts +12 -0
- package/lib/types/edge.d.ts +11 -0
- package/lib/types/element.d.ts +100 -9
- package/lib/types/index.d.ts +0 -1
- package/lib/types/point.d.ts +0 -1
- package/lib/utils/element.d.ts +2 -2
- package/lib/utils/element.js.map +1 -1
- package/lib/utils/layout.d.ts +2 -2
- package/lib/utils/layout.js +4 -4
- package/lib/utils/layout.js.map +1 -1
- package/lib/utils/path.d.ts +3 -3
- package/lib/utils/path.js +1 -1
- package/lib/utils/path.js.map +1 -1
- package/lib/utils/position.d.ts +8 -8
- package/lib/utils/position.js +2 -2
- package/lib/utils/position.js.map +1 -1
- package/lib/utils/style.d.ts +13 -8
- package/lib/utils/style.js +18 -13
- package/lib/utils/style.js.map +1 -1
- package/package.json +10 -12
- package/src/behaviors/click-select.ts +59 -60
- package/src/behaviors/lasso-select.ts +2 -2
- package/src/elements/base-element.ts +1 -25
- package/src/elements/combos/base-combo.ts +27 -11
- package/src/elements/edges/base-edge.ts +28 -8
- package/src/elements/effect.ts +74 -0
- package/src/elements/nodes/base-node.ts +23 -18
- package/src/elements/nodes/circle.ts +1 -1
- package/src/elements/nodes/diamond.ts +0 -7
- package/src/elements/nodes/ellipse.ts +1 -1
- package/src/elements/nodes/image.ts +2 -2
- package/src/elements/nodes/rect.ts +1 -1
- package/src/elements/shapes/badge.ts +17 -5
- package/src/elements/shapes/base-shape.ts +35 -15
- package/src/elements/shapes/icon.ts +18 -7
- package/src/elements/shapes/label.ts +19 -6
- package/src/elements/shapes/polygon.ts +1 -1
- package/src/exports.ts +6 -2
- package/src/index.ts +6 -2
- package/src/layouts/base-layout.ts +5 -1
- package/src/plugins/bubble-sets.ts +2 -2
- package/src/plugins/hull/index.ts +2 -2
- package/src/runtime/canvas.ts +15 -10
- package/src/runtime/data.ts +22 -44
- package/src/runtime/element.ts +80 -26
- package/src/runtime/graph.ts +398 -126
- package/src/runtime/layout.ts +2 -2
- package/src/spec/element/edge.ts +1 -1
- package/src/spec/element/node.ts +1 -1
- package/src/themes/base.ts +2 -0
- package/src/transforms/collapse-expand-node.ts +13 -4
- package/src/transforms/process-parallel-edges.ts +2 -2
- package/src/types/callable.ts +0 -12
- package/src/types/data.ts +13 -0
- package/src/types/edge.ts +11 -0
- package/src/types/element.ts +106 -10
- package/src/types/index.ts +0 -1
- package/src/types/point.ts +0 -1
- package/src/utils/element.ts +3 -13
- package/src/utils/layout.ts +6 -6
- package/src/utils/path.ts +3 -3
- package/src/utils/position.ts +8 -8
- package/src/utils/style.ts +19 -12
- package/dist/lib/types/position.d.ts +0 -2
- package/esm/types/position.d.ts +0 -2
- package/esm/types/position.js +0 -2
- package/esm/types/position.js.map +0 -1
- package/lib/types/position.d.ts +0 -2
- package/lib/types/position.js +0 -3
- package/lib/types/position.js.map +0 -1
- package/scripts/tips.js +0 -6
- package/src/types/position.ts +0 -3
package/src/runtime/graph.ts
CHANGED
|
@@ -23,12 +23,12 @@ import type { UpdateBehaviorOption } from '../spec/behavior';
|
|
|
23
23
|
import type { UpdatePluginOption } from '../spec/plugin';
|
|
24
24
|
import type { UpdateTransformOption } from '../spec/transform';
|
|
25
25
|
import type {
|
|
26
|
-
CallableValue,
|
|
27
26
|
DataID,
|
|
28
27
|
EdgeDirection,
|
|
29
28
|
ElementDatum,
|
|
30
29
|
ElementType,
|
|
31
30
|
FitViewOptions,
|
|
31
|
+
HierarchyKey,
|
|
32
32
|
ID,
|
|
33
33
|
IEvent,
|
|
34
34
|
NodeLikeData,
|
|
@@ -36,7 +36,6 @@ import type {
|
|
|
36
36
|
PartialGraphData,
|
|
37
37
|
PartialNodeLikeData,
|
|
38
38
|
Point,
|
|
39
|
-
Position,
|
|
40
39
|
State,
|
|
41
40
|
Vector2,
|
|
42
41
|
ViewportAnimationEffectTiming,
|
|
@@ -46,14 +45,12 @@ import { sizeOf } from '../utils/dom';
|
|
|
46
45
|
import { GraphLifeCycleEvent, emit } from '../utils/event';
|
|
47
46
|
import { idOf } from '../utils/id';
|
|
48
47
|
import { parsePoint, toPointObject } from '../utils/point';
|
|
49
|
-
import { zIndexOf } from '../utils/style';
|
|
50
48
|
import { subtract } from '../utils/vector';
|
|
51
49
|
import { Animation } from './animation';
|
|
52
50
|
import { BatchController } from './batch';
|
|
53
51
|
import { BehaviorController } from './behavior';
|
|
54
52
|
import type { DataURLOptions } from './canvas';
|
|
55
53
|
import { Canvas } from './canvas';
|
|
56
|
-
import type { HierarchyKey } from './data';
|
|
57
54
|
import { DataController } from './data';
|
|
58
55
|
import { ElementController } from './element';
|
|
59
56
|
import { LayoutController } from './layout';
|
|
@@ -164,7 +161,7 @@ export class Graph extends EventEmitter {
|
|
|
164
161
|
}
|
|
165
162
|
|
|
166
163
|
/**
|
|
167
|
-
* <zh/>
|
|
164
|
+
* <zh/> 获取当前画布容器的尺寸
|
|
168
165
|
*
|
|
169
166
|
* <en/> Get the size of the current canvas container
|
|
170
167
|
* @returns <zh/> 画布尺寸 | <en/> canvas size
|
|
@@ -176,7 +173,7 @@ export class Graph extends EventEmitter {
|
|
|
176
173
|
}
|
|
177
174
|
|
|
178
175
|
/**
|
|
179
|
-
* <zh/>
|
|
176
|
+
* <zh/> 获取当前画布容器的尺寸
|
|
180
177
|
*
|
|
181
178
|
* <en/> Get the size of the current canvas container
|
|
182
179
|
* @param width - <zh/> 画布宽度 | <en/> canvas width
|
|
@@ -214,7 +211,11 @@ export class Graph extends EventEmitter {
|
|
|
214
211
|
* <zh/> 设置节点样式映射
|
|
215
212
|
*
|
|
216
213
|
* <en/> Set node mapper
|
|
217
|
-
* @param node - <zh/> 节点配置 | <en/> node
|
|
214
|
+
* @param node - <zh/> 节点配置 | <en/> node options
|
|
215
|
+
* @remarks
|
|
216
|
+
* <zh/> 即 `options.node` 的值
|
|
217
|
+
*
|
|
218
|
+
* <en/> The value of `options.node`
|
|
218
219
|
* @apiCategory element
|
|
219
220
|
*/
|
|
220
221
|
public setNode(node: NodeOptions): void {
|
|
@@ -226,7 +227,11 @@ export class Graph extends EventEmitter {
|
|
|
226
227
|
* <zh/> 设置边样式映射
|
|
227
228
|
*
|
|
228
229
|
* <en/> Set edge mapper
|
|
229
|
-
* @param edge - <zh/> 边配置 | <en/> edge
|
|
230
|
+
* @param edge - <zh/> 边配置 | <en/> edge options
|
|
231
|
+
* @remarks
|
|
232
|
+
* <zh/> 即 `options.edge` 的值
|
|
233
|
+
*
|
|
234
|
+
* <en/> The value of `options.edge`
|
|
230
235
|
* @apiCategory element
|
|
231
236
|
*/
|
|
232
237
|
public setEdge(edge: EdgeOptions): void {
|
|
@@ -238,7 +243,11 @@ export class Graph extends EventEmitter {
|
|
|
238
243
|
* <zh/> 设置组合样式映射
|
|
239
244
|
*
|
|
240
245
|
* <en/> Set combo mapper
|
|
241
|
-
* @param combo - <zh/> 组合配置 | <en/> combo
|
|
246
|
+
* @param combo - <zh/> 组合配置 | <en/> combo options
|
|
247
|
+
* @remarks
|
|
248
|
+
* <zh/> 即 `options.combo` 的值
|
|
249
|
+
*
|
|
250
|
+
* <en/> The value of `options.combo`
|
|
242
251
|
* @apiCategory element
|
|
243
252
|
*/
|
|
244
253
|
public setCombo(combo: ComboOptions): void {
|
|
@@ -250,7 +259,7 @@ export class Graph extends EventEmitter {
|
|
|
250
259
|
* <zh/> 获取主题
|
|
251
260
|
*
|
|
252
261
|
* <en/> Get theme
|
|
253
|
-
* @returns <zh/>
|
|
262
|
+
* @returns <zh/> 当前主题 | <en/> current theme
|
|
254
263
|
* @apiCategory theme
|
|
255
264
|
*/
|
|
256
265
|
public getTheme(): ThemeOptions {
|
|
@@ -261,10 +270,14 @@ export class Graph extends EventEmitter {
|
|
|
261
270
|
* <zh/> 设置主题
|
|
262
271
|
*
|
|
263
272
|
* <en/> Set theme
|
|
264
|
-
* @param theme - <zh/>
|
|
273
|
+
* @param theme - <zh/> 主题名 | <en/> theme name
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* graph.setTheme('dark');
|
|
277
|
+
* ```
|
|
265
278
|
* @apiCategory theme
|
|
266
279
|
*/
|
|
267
|
-
public setTheme(theme:
|
|
280
|
+
public setTheme(theme: ThemeOptions | ((prev: ThemeOptions) => ThemeOptions)): void {
|
|
268
281
|
this.options.theme = isFunction(theme) ? theme(this.getTheme()) : theme;
|
|
269
282
|
|
|
270
283
|
const { background } = getExtension('theme', this.options.theme) || {};
|
|
@@ -277,18 +290,24 @@ export class Graph extends EventEmitter {
|
|
|
277
290
|
* <zh/> 设置布局
|
|
278
291
|
*
|
|
279
292
|
* <en/> Set layout
|
|
280
|
-
* @param layout - <zh/> 布局配置 | <en/> layout
|
|
293
|
+
* @param layout - <zh/> 布局配置 | <en/> layout options
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* graph.setLayout({
|
|
297
|
+
* type: 'dagre',
|
|
298
|
+
* })
|
|
299
|
+
* ```
|
|
281
300
|
* @apiCategory layout
|
|
282
301
|
*/
|
|
283
|
-
public setLayout(layout:
|
|
302
|
+
public setLayout(layout: LayoutOptions | ((prev: LayoutOptions) => LayoutOptions)): void {
|
|
284
303
|
this.options.layout = isFunction(layout) ? layout(this.getLayout()) : layout;
|
|
285
304
|
}
|
|
286
305
|
|
|
287
306
|
/**
|
|
288
|
-
* <zh/>
|
|
307
|
+
* <zh/> 获取布局配置
|
|
289
308
|
*
|
|
290
|
-
* <en/> Get layout
|
|
291
|
-
* @returns <zh/> 布局配置 | <en/> layout
|
|
309
|
+
* <en/> Get layout options
|
|
310
|
+
* @returns <zh/> 布局配置 | <en/> layout options
|
|
292
311
|
* @apiCategory layout
|
|
293
312
|
*/
|
|
294
313
|
public getLayout(): LayoutOptions {
|
|
@@ -299,19 +318,38 @@ export class Graph extends EventEmitter {
|
|
|
299
318
|
* <zh/> 设置交互
|
|
300
319
|
*
|
|
301
320
|
* <en/> Set behaviors
|
|
302
|
-
* @param behaviors - <zh/> 交互配置 | <en/> behavior
|
|
321
|
+
* @param behaviors - <zh/> 交互配置 | <en/> behavior options
|
|
322
|
+
* @remarks
|
|
323
|
+
* <zh/> 设置的交互会全量替换原有的交互,如果需要新增交互可以使用如下方式:
|
|
324
|
+
*
|
|
325
|
+
* <en/> The set behavior will completely replace the original behavior. If you need to add behavior, you can use the following method:
|
|
326
|
+
*
|
|
327
|
+
* ```ts
|
|
328
|
+
* graph.setBehaviors((behaviors) => [...behaviors, { type: 'zoom-canvas' }])
|
|
329
|
+
* ```
|
|
303
330
|
* @apiCategory behavior
|
|
304
331
|
*/
|
|
305
|
-
public setBehaviors(behaviors:
|
|
332
|
+
public setBehaviors(behaviors: BehaviorOptions | ((prev: BehaviorOptions) => BehaviorOptions)): void {
|
|
306
333
|
this.options.behaviors = isFunction(behaviors) ? behaviors(this.getBehaviors()) : behaviors;
|
|
307
334
|
this.context.behavior?.setBehaviors(this.options.behaviors);
|
|
308
335
|
}
|
|
309
336
|
|
|
310
337
|
/**
|
|
311
|
-
* <zh/>
|
|
338
|
+
* <zh/> 更新指定的交互配置
|
|
339
|
+
*
|
|
340
|
+
* <en/> Update specified behavior options
|
|
341
|
+
* @param behavior - <zh/> 交互配置 | <en/> behavior options
|
|
342
|
+
* @remarks
|
|
343
|
+
* <zh/> 如果要更新一个交互,那么必须在交互配置中指定 key 字段,例如:
|
|
312
344
|
*
|
|
313
|
-
* <en/>
|
|
314
|
-
*
|
|
345
|
+
* <en/> If you want to update a behavior, you must specify the key field in the behavior options, for example:
|
|
346
|
+
* ```ts
|
|
347
|
+
* {
|
|
348
|
+
* behaviors: [{ type: 'zoom-canvas', key: 'zoom-canvas' }]
|
|
349
|
+
* }
|
|
350
|
+
*
|
|
351
|
+
* graph.updateBehavior({ key: 'zoom-canvas', enable: false })
|
|
352
|
+
* ```
|
|
315
353
|
* @apiCategory behavior
|
|
316
354
|
*/
|
|
317
355
|
public updateBehavior(behavior: UpdateBehaviorOption): void {
|
|
@@ -326,10 +364,10 @@ export class Graph extends EventEmitter {
|
|
|
326
364
|
}
|
|
327
365
|
|
|
328
366
|
/**
|
|
329
|
-
* <zh/>
|
|
367
|
+
* <zh/> 获取交互配置
|
|
330
368
|
*
|
|
331
|
-
* <en/> Get behaviors
|
|
332
|
-
* @returns <zh/> 交互配置 | <en/> behavior
|
|
369
|
+
* <en/> Get behaviors options
|
|
370
|
+
* @returns <zh/> 交互配置 | <en/> behavior options
|
|
333
371
|
* @apiCategory behavior
|
|
334
372
|
*/
|
|
335
373
|
public getBehaviors(): BehaviorOptions {
|
|
@@ -337,22 +375,40 @@ export class Graph extends EventEmitter {
|
|
|
337
375
|
}
|
|
338
376
|
|
|
339
377
|
/**
|
|
340
|
-
* <zh/>
|
|
378
|
+
* <zh/> 设置插件配置
|
|
379
|
+
*
|
|
380
|
+
* <en/> Set plugins options
|
|
381
|
+
* @param plugins - <zh/> 插件配置 | <en/> plugin options
|
|
382
|
+
* @remarks
|
|
383
|
+
* <zh/> 设置的插件会全量替换原有的插件配置,如果需要新增插件可以使用如下方式:
|
|
341
384
|
*
|
|
342
|
-
* <en/>
|
|
343
|
-
*
|
|
385
|
+
* <en/> The set plugin will completely replace the original plugin configuration. If you need to add a plugin, you can use the following method:
|
|
386
|
+
* ```ts
|
|
387
|
+
* graph.setPlugins((plugins) => [...plugins, { key: 'grid-line' }])
|
|
388
|
+
* ```
|
|
344
389
|
* @apiCategory plugin
|
|
345
390
|
*/
|
|
346
|
-
public setPlugins(plugins:
|
|
391
|
+
public setPlugins(plugins: PluginOptions | ((prev: PluginOptions) => PluginOptions)): void {
|
|
347
392
|
this.options.plugins = isFunction(plugins) ? plugins(this.getPlugins()) : plugins;
|
|
348
393
|
this.context.plugin?.setPlugins(this.options.plugins);
|
|
349
394
|
}
|
|
350
395
|
|
|
351
396
|
/**
|
|
352
|
-
* <zh/>
|
|
397
|
+
* <zh/> 更新插件配置
|
|
398
|
+
*
|
|
399
|
+
* <en/> Update plugin options
|
|
400
|
+
* @param plugin - <zh/> 插件配置 | <en/> plugin options
|
|
401
|
+
* @remarks
|
|
402
|
+
* <zh/> 如果要更新一个插件,那么必须在插件配置中指定 key 字段,例如:
|
|
353
403
|
*
|
|
354
|
-
* <en/>
|
|
355
|
-
*
|
|
404
|
+
* <en/> If you want to update a plugin, you must specify the key field in the plugin options, for example:
|
|
405
|
+
* ```ts
|
|
406
|
+
* {
|
|
407
|
+
* plugins: [{ key: 'grid-line' }]
|
|
408
|
+
* }
|
|
409
|
+
*
|
|
410
|
+
* graph.updatePlugin({ key: 'grid-line', follow: true })
|
|
411
|
+
* ```
|
|
356
412
|
* @apiCategory plugin
|
|
357
413
|
*/
|
|
358
414
|
public updatePlugin(plugin: UpdatePluginOption): void {
|
|
@@ -367,10 +423,10 @@ export class Graph extends EventEmitter {
|
|
|
367
423
|
}
|
|
368
424
|
|
|
369
425
|
/**
|
|
370
|
-
* <zh/>
|
|
426
|
+
* <zh/> 获取插件配置
|
|
371
427
|
*
|
|
372
|
-
* <en/> Get plugins
|
|
373
|
-
* @returns <zh/> 插件配置 | <en/> plugin
|
|
428
|
+
* <en/> Get plugins options
|
|
429
|
+
* @returns <zh/> 插件配置 | <en/> plugin options
|
|
374
430
|
* @apiCategory plugin
|
|
375
431
|
*/
|
|
376
432
|
public getPlugins(): PluginOptions {
|
|
@@ -383,6 +439,17 @@ export class Graph extends EventEmitter {
|
|
|
383
439
|
* <en/> Get plugin instance
|
|
384
440
|
* @param key - <zh/> 插件 key | <en/> plugin key
|
|
385
441
|
* @returns <zh/> 插件实例 | <en/> plugin instance
|
|
442
|
+
* @remarks
|
|
443
|
+
* <zh/> 一些插件提供了 API 方法可供调用,例如全屏插件可以调用 `request` 和 `exit` 方法来请求和退出全屏
|
|
444
|
+
*
|
|
445
|
+
* <en/> Some plugins provide API methods for calling, such as the full-screen plugin can call the `request` and `exit` methods to request and exit full-screen
|
|
446
|
+
* ```ts
|
|
447
|
+
* const fullscreen = graph.getPluginInstance('fullscreen');
|
|
448
|
+
*
|
|
449
|
+
* fullscreen.request();
|
|
450
|
+
*
|
|
451
|
+
* fullscreen.exit();
|
|
452
|
+
* ```
|
|
386
453
|
* @apiCategory plugin
|
|
387
454
|
*/
|
|
388
455
|
public getPluginInstance<T extends Plugin>(key: string) {
|
|
@@ -393,10 +460,14 @@ export class Graph extends EventEmitter {
|
|
|
393
460
|
* <zh/> 设置数据转换器
|
|
394
461
|
*
|
|
395
462
|
* <en/> Set data transforms
|
|
396
|
-
* @param transforms - <zh/> 数据转换配置 | <en/> data transform
|
|
463
|
+
* @param transforms - <zh/> 数据转换配置 | <en/> data transform options
|
|
464
|
+
* @remarks
|
|
465
|
+
* <zh/> 数据转换器能够在图渲染过程中执行数据转换,目前支持在渲染前对绘制数据进行转化。
|
|
466
|
+
*
|
|
467
|
+
* <en/> Data transforms can perform data transformation during the rendering process of the graph. Currently, it supports transforming the drawing data before rendering.
|
|
397
468
|
* @apiCategory transform
|
|
398
469
|
*/
|
|
399
|
-
public setTransforms(transforms:
|
|
470
|
+
public setTransforms(transforms: TransformOptions | ((prev: TransformOptions) => TransformOptions)): void {
|
|
400
471
|
this.options.transforms = isFunction(transforms) ? transforms(this.getTransforms()) : transforms;
|
|
401
472
|
this.context.transform?.setTransforms(this.options.transforms);
|
|
402
473
|
}
|
|
@@ -405,7 +476,7 @@ export class Graph extends EventEmitter {
|
|
|
405
476
|
* <zh/> 更新数据转换器
|
|
406
477
|
*
|
|
407
478
|
* <en/> Update data transform
|
|
408
|
-
* @param transform - <zh/>
|
|
479
|
+
* @param transform - <zh/> 数据转换器配置 | <en/> data transform options
|
|
409
480
|
* @apiCategory transform
|
|
410
481
|
*/
|
|
411
482
|
public updateTransform(transform: UpdateTransformOption): void {
|
|
@@ -421,10 +492,10 @@ export class Graph extends EventEmitter {
|
|
|
421
492
|
}
|
|
422
493
|
|
|
423
494
|
/**
|
|
424
|
-
* <zh/>
|
|
495
|
+
* <zh/> 获取数据转换器配置
|
|
425
496
|
*
|
|
426
|
-
* <en/> Get data transforms
|
|
427
|
-
* @returns <zh/>
|
|
497
|
+
* <en/> Get data transforms options
|
|
498
|
+
* @returns <zh/> 数据转换配置 | <en/> data transform options
|
|
428
499
|
* @apiCategory transform
|
|
429
500
|
*/
|
|
430
501
|
public getTransforms(): TransformOptions {
|
|
@@ -432,10 +503,13 @@ export class Graph extends EventEmitter {
|
|
|
432
503
|
}
|
|
433
504
|
|
|
434
505
|
/**
|
|
435
|
-
* <zh/>
|
|
506
|
+
* <zh/> 获取图数据
|
|
507
|
+
*
|
|
508
|
+
* <en/> Get graph data
|
|
509
|
+
* @returns <zh/> 图数据 | <en/> Graph data
|
|
510
|
+
* <zh/> 获取当前图的数据,包括节点、边、组合数据
|
|
436
511
|
*
|
|
437
|
-
* <en/> Get data
|
|
438
|
-
* @returns <zh/> 数据 | <en/> data
|
|
512
|
+
* <en/> Get the data of the current graph, including node, edge, and combo data
|
|
439
513
|
* @apiCategory data
|
|
440
514
|
*/
|
|
441
515
|
public getData(): GraphData {
|
|
@@ -448,6 +522,10 @@ export class Graph extends EventEmitter {
|
|
|
448
522
|
* <en/> Get element data by ID
|
|
449
523
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
450
524
|
* @returns <zh/> 元素数据 | <en/> element data
|
|
525
|
+
* @remarks
|
|
526
|
+
* <zh/> 直接获取元素的数据而不必考虑元素类型
|
|
527
|
+
*
|
|
528
|
+
* <en/> Get element data directly without considering the element type
|
|
451
529
|
* @apiCategory data
|
|
452
530
|
*/
|
|
453
531
|
public getElementData(id: ID): ElementDatum;
|
|
@@ -456,6 +534,10 @@ export class Graph extends EventEmitter {
|
|
|
456
534
|
*
|
|
457
535
|
* <en/> Get multiple element data in batch
|
|
458
536
|
* @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
|
|
537
|
+
* @remarks
|
|
538
|
+
* <zh/> 直接获取元素的数据而不必考虑元素类型
|
|
539
|
+
*
|
|
540
|
+
* <en/> Get element data directly without considering the element type
|
|
459
541
|
* @apiCategory data
|
|
460
542
|
*/
|
|
461
543
|
public getElementData(ids: ID[]): ElementDatum[];
|
|
@@ -478,6 +560,10 @@ export class Graph extends EventEmitter {
|
|
|
478
560
|
* <en/> Get single node data
|
|
479
561
|
* @param id - <zh/> 节点 ID | <en/> node ID
|
|
480
562
|
* @returns <zh/> 节点数据 | <en/> node data
|
|
563
|
+
* @example
|
|
564
|
+
* ```ts
|
|
565
|
+
* const node1 = graph.getNodeData('node-1');
|
|
566
|
+
* ```
|
|
481
567
|
* @apiCategory data
|
|
482
568
|
*/
|
|
483
569
|
public getNodeData(id: ID): NodeData;
|
|
@@ -487,6 +573,10 @@ export class Graph extends EventEmitter {
|
|
|
487
573
|
* <en/> Get multiple node data in batch
|
|
488
574
|
* @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
|
|
489
575
|
* @returns <zh/> 节点数据 | <en/> node data
|
|
576
|
+
* @example
|
|
577
|
+
* ```ts
|
|
578
|
+
* const [node1, node2] = graph.getNodeData(['node-1', 'node-2']);
|
|
579
|
+
* ```
|
|
490
580
|
* @apiCategory data
|
|
491
581
|
*/
|
|
492
582
|
public getNodeData(ids: ID[]): NodeData[];
|
|
@@ -510,6 +600,10 @@ export class Graph extends EventEmitter {
|
|
|
510
600
|
* <en/> Get single edge data
|
|
511
601
|
* @param id - <zh/> 边 ID | <en/> edge ID
|
|
512
602
|
* @returns <zh/> 边数据 | <en/> edge data
|
|
603
|
+
* @example
|
|
604
|
+
* ```ts
|
|
605
|
+
* const edge1 = graph.getEdgeData('edge-1');
|
|
606
|
+
* ```
|
|
513
607
|
* @apiCategory data
|
|
514
608
|
*/
|
|
515
609
|
public getEdgeData(id: ID): EdgeData;
|
|
@@ -519,6 +613,10 @@ export class Graph extends EventEmitter {
|
|
|
519
613
|
* <en/> Get multiple edge data in batch
|
|
520
614
|
* @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
|
|
521
615
|
* @returns <zh/> 边数据 | <en/> edge data
|
|
616
|
+
* @example
|
|
617
|
+
* ```ts
|
|
618
|
+
* const [edge1, edge2] = graph.getEdgeData(['edge-1', 'edge-2']);
|
|
619
|
+
* ```
|
|
522
620
|
* @apiCategory data
|
|
523
621
|
*/
|
|
524
622
|
public getEdgeData(ids: ID[]): EdgeData[];
|
|
@@ -542,6 +640,10 @@ export class Graph extends EventEmitter {
|
|
|
542
640
|
* <en/> Get single combo data
|
|
543
641
|
* @param id - <zh/> 组合ID | <en/> combo ID
|
|
544
642
|
* @returns <zh/> 组合数据 | <en/> combo data
|
|
643
|
+
* @example
|
|
644
|
+
* ```ts
|
|
645
|
+
* const combo1 = graph.getComboData('combo-1');
|
|
646
|
+
* ```
|
|
545
647
|
* @apiCategory data
|
|
546
648
|
*/
|
|
547
649
|
public getComboData(id: ID): ComboData;
|
|
@@ -551,6 +653,10 @@ export class Graph extends EventEmitter {
|
|
|
551
653
|
* <en/> Get multiple combo data in batch
|
|
552
654
|
* @param ids - <zh/> 组合ID 数组 | <en/> combo ID array
|
|
553
655
|
* @returns <zh/> 组合数据 | <en/> combo data
|
|
656
|
+
* @example
|
|
657
|
+
* ```ts
|
|
658
|
+
* const [combo1, combo2] = graph.getComboData(['combo-1', 'combo-2']);
|
|
659
|
+
* ```
|
|
554
660
|
* @apiCategory data
|
|
555
661
|
*/
|
|
556
662
|
public getComboData(ids: ID[]): ComboData[];
|
|
@@ -565,9 +671,13 @@ export class Graph extends EventEmitter {
|
|
|
565
671
|
*
|
|
566
672
|
* <en/> Set full data
|
|
567
673
|
* @param data - <zh/> 数据 | <en/> data
|
|
674
|
+
* @remarks
|
|
675
|
+
* <zh/> 设置全量数据会替换当前图中的所有数据,G6 会自动进行数据差异计算
|
|
676
|
+
*
|
|
677
|
+
* <en/> Setting full data will replace all data in the current graph, and G6 will automatically calculate the data difference
|
|
568
678
|
* @apiCategory data
|
|
569
679
|
*/
|
|
570
|
-
public setData(data:
|
|
680
|
+
public setData(data: GraphData | ((prev: GraphData) => GraphData)): void {
|
|
571
681
|
this.context.model.setData(isFunction(data) ? data(this.getData()) : data);
|
|
572
682
|
}
|
|
573
683
|
|
|
@@ -576,9 +686,16 @@ export class Graph extends EventEmitter {
|
|
|
576
686
|
*
|
|
577
687
|
* <en/> Add element data
|
|
578
688
|
* @param data - <zh/> 元素数据 | <en/> element data
|
|
689
|
+
* @example
|
|
690
|
+
* ```ts
|
|
691
|
+
* graph.addData({
|
|
692
|
+
* nodes: [{ id: 'node-1' }, { id: 'node-2' }],
|
|
693
|
+
* edges: [{ source: 'node-1', target: 'node-2' }],
|
|
694
|
+
* });
|
|
695
|
+
* ```
|
|
579
696
|
* @apiCategory data
|
|
580
697
|
*/
|
|
581
|
-
public addData(data:
|
|
698
|
+
public addData(data: GraphData | ((prev: GraphData) => GraphData)): void {
|
|
582
699
|
this.context.model.addData(isFunction(data) ? data(this.getData()) : data);
|
|
583
700
|
}
|
|
584
701
|
|
|
@@ -587,9 +704,13 @@ export class Graph extends EventEmitter {
|
|
|
587
704
|
*
|
|
588
705
|
* <en/> Add node data
|
|
589
706
|
* @param data - <zh/> 节点数据 | <en/> node data
|
|
707
|
+
* @example
|
|
708
|
+
* ```ts
|
|
709
|
+
* graph.addNodeData([{ id: 'node-1' }, { id: 'node-2' }]);
|
|
710
|
+
* ```
|
|
590
711
|
* @apiCategory data
|
|
591
712
|
*/
|
|
592
|
-
public addNodeData(data:
|
|
713
|
+
public addNodeData(data: NodeData[] | ((prev: NodeData[]) => NodeData[])): void {
|
|
593
714
|
this.context.model.addNodeData(isFunction(data) ? data(this.getNodeData()) : data);
|
|
594
715
|
}
|
|
595
716
|
|
|
@@ -598,9 +719,13 @@ export class Graph extends EventEmitter {
|
|
|
598
719
|
*
|
|
599
720
|
* <en/> Add edge data
|
|
600
721
|
* @param data - <zh/> 边数据 | <en/> edge data
|
|
722
|
+
* @example
|
|
723
|
+
* ```ts
|
|
724
|
+
* graph.addEdgeData([{ source: 'node-1', target: 'node-2' }]);
|
|
725
|
+
* ```
|
|
601
726
|
* @apiCategory data
|
|
602
727
|
*/
|
|
603
|
-
public addEdgeData(data:
|
|
728
|
+
public addEdgeData(data: EdgeData[] | ((prev: EdgeData[]) => EdgeData[])): void {
|
|
604
729
|
this.context.model.addEdgeData(isFunction(data) ? data(this.getEdgeData()) : data);
|
|
605
730
|
}
|
|
606
731
|
|
|
@@ -609,20 +734,50 @@ export class Graph extends EventEmitter {
|
|
|
609
734
|
*
|
|
610
735
|
* <en/> Add combo data
|
|
611
736
|
* @param data - <zh/> 组合数据 | <en/> combo data
|
|
737
|
+
* @example
|
|
738
|
+
* ```ts
|
|
739
|
+
* graph.addComboData([{ id: 'combo-1' }]);
|
|
740
|
+
* ```
|
|
612
741
|
* @apiCategory data
|
|
613
742
|
*/
|
|
614
|
-
public addComboData(data:
|
|
743
|
+
public addComboData(data: ComboData[] | ((prev: ComboData[]) => ComboData[])): void {
|
|
615
744
|
this.context.model.addComboData(isFunction(data) ? data(this.getComboData()) : data);
|
|
616
745
|
}
|
|
617
746
|
|
|
747
|
+
/**
|
|
748
|
+
* <zh/> 为树图节点添加子节点数据
|
|
749
|
+
*
|
|
750
|
+
* <en/> Add child node data to the tree node
|
|
751
|
+
* @param parentId - <zh/> 父节点 ID | <en/> parent node ID
|
|
752
|
+
* @param childrenData - <zh/> 子节点数据 | <en/> child node data
|
|
753
|
+
* @remarks
|
|
754
|
+
* <zh/> 为组合添加子节点使用 addNodeData / addComboData 方法
|
|
755
|
+
*
|
|
756
|
+
* <en/> Use addNodeData / addComboData method to add child nodes to the combo
|
|
757
|
+
*/
|
|
758
|
+
public addChildrenData(parentId: ID, childrenData: NodeData[]) {
|
|
759
|
+
this.context.model.addChildrenData(parentId, childrenData);
|
|
760
|
+
}
|
|
761
|
+
|
|
618
762
|
/**
|
|
619
763
|
* <zh/> 更新元素数据
|
|
620
764
|
*
|
|
621
765
|
* <en/> Update element data
|
|
622
766
|
* @param data - <zh/> 元素数据 | <en/> element data
|
|
767
|
+
* @remarks
|
|
768
|
+
* <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
|
|
769
|
+
*
|
|
770
|
+
* <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
|
|
771
|
+
* @example
|
|
772
|
+
* ```ts
|
|
773
|
+
* graph.updateData({
|
|
774
|
+
* nodes: [{ id: 'node-1', style: { x: 100, y: 100 } }],
|
|
775
|
+
* edges: [{ id: 'edge-1', style: { lineWidth: 2 } }]
|
|
776
|
+
* });
|
|
777
|
+
* ```
|
|
623
778
|
* @apiCategory data
|
|
624
779
|
*/
|
|
625
|
-
public updateData(data:
|
|
780
|
+
public updateData(data: PartialGraphData | ((prev: GraphData) => PartialGraphData)): void {
|
|
626
781
|
this.context.model.updateData(isFunction(data) ? data(this.getData()) : data);
|
|
627
782
|
}
|
|
628
783
|
|
|
@@ -631,9 +786,19 @@ export class Graph extends EventEmitter {
|
|
|
631
786
|
*
|
|
632
787
|
* <en/> Update node data
|
|
633
788
|
* @param data - <zh/> 节点数据 | <en/> node data
|
|
789
|
+
* @remarks
|
|
790
|
+
* <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
|
|
791
|
+
*
|
|
792
|
+
* <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
|
|
793
|
+
* @example
|
|
794
|
+
* ```ts
|
|
795
|
+
* graph.updateNodeData([{ id: 'node-1', style: { x: 100, y: 100 } }]);
|
|
796
|
+
* ```
|
|
634
797
|
* @apiCategory data
|
|
635
798
|
*/
|
|
636
|
-
public updateNodeData(
|
|
799
|
+
public updateNodeData(
|
|
800
|
+
data: PartialNodeLikeData<NodeData>[] | ((prev: NodeData[]) => PartialNodeLikeData<NodeData>[]),
|
|
801
|
+
): void {
|
|
637
802
|
this.context.model.updateNodeData(isFunction(data) ? data(this.getNodeData()) : data);
|
|
638
803
|
}
|
|
639
804
|
|
|
@@ -642,9 +807,17 @@ export class Graph extends EventEmitter {
|
|
|
642
807
|
*
|
|
643
808
|
* <en/> Update edge data
|
|
644
809
|
* @param data - <zh/> 边数据 | <en/> edge data
|
|
810
|
+
* @remarks
|
|
811
|
+
* <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
|
|
812
|
+
*
|
|
813
|
+
* <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
|
|
814
|
+
* @example
|
|
815
|
+
* ```ts
|
|
816
|
+
* graph.updateEdgeData([{ id: 'edge-1', style: { lineWidth: 2 } }]);
|
|
817
|
+
* ```
|
|
645
818
|
* @apiCategory data
|
|
646
819
|
*/
|
|
647
|
-
public updateEdgeData(data:
|
|
820
|
+
public updateEdgeData(data: PartialEdgeData<EdgeData>[] | ((prev: EdgeData[]) => PartialEdgeData<EdgeData>[])): void {
|
|
648
821
|
this.context.model.updateEdgeData(isFunction(data) ? data(this.getEdgeData()) : data);
|
|
649
822
|
}
|
|
650
823
|
|
|
@@ -653,17 +826,34 @@ export class Graph extends EventEmitter {
|
|
|
653
826
|
*
|
|
654
827
|
* <en/> Update combo data
|
|
655
828
|
* @param data - <zh/> 组合数据 | <en/> combo data
|
|
829
|
+
* @remarks
|
|
830
|
+
* <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
|
|
831
|
+
*
|
|
832
|
+
* <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
|
|
833
|
+
* @example
|
|
834
|
+
* ```ts
|
|
835
|
+
* graph.updateComboData([{ id: 'combo-1', style: { x: 100, y: 100 } }]);
|
|
836
|
+
* ```
|
|
656
837
|
* @apiCategory data
|
|
657
838
|
*/
|
|
658
|
-
public updateComboData(
|
|
839
|
+
public updateComboData(
|
|
840
|
+
data: PartialNodeLikeData<ComboData>[] | ((prev: ComboData[]) => PartialNodeLikeData<ComboData>[]),
|
|
841
|
+
): void {
|
|
659
842
|
this.context.model.updateComboData(isFunction(data) ? data(this.getComboData()) : data);
|
|
660
843
|
}
|
|
661
844
|
|
|
662
845
|
/**
|
|
663
|
-
* <zh/>
|
|
846
|
+
* <zh/> 删除元素数据
|
|
664
847
|
*
|
|
665
|
-
* <en/> Remove
|
|
848
|
+
* <en/> Remove element data
|
|
666
849
|
* @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
|
|
850
|
+
* @example
|
|
851
|
+
* ```ts
|
|
852
|
+
* graph.removeData({
|
|
853
|
+
* nodes: ['node-1', 'node-2'],
|
|
854
|
+
* edges: ['edge-1'],
|
|
855
|
+
* });
|
|
856
|
+
* ```
|
|
667
857
|
* @apiCategory data
|
|
668
858
|
*/
|
|
669
859
|
public removeData(ids: DataID | ((data: GraphData) => DataID)): void {
|
|
@@ -671,10 +861,14 @@ export class Graph extends EventEmitter {
|
|
|
671
861
|
}
|
|
672
862
|
|
|
673
863
|
/**
|
|
674
|
-
* <zh/>
|
|
864
|
+
* <zh/> 删除节点数据
|
|
675
865
|
*
|
|
676
|
-
* <en/> Remove
|
|
866
|
+
* <en/> Remove node data
|
|
677
867
|
* @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
|
|
868
|
+
* @example
|
|
869
|
+
* ```ts
|
|
870
|
+
* graph.removeNodeData(['node-1', 'node-2']);
|
|
871
|
+
* ```
|
|
678
872
|
* @apiCategory data
|
|
679
873
|
*/
|
|
680
874
|
public removeNodeData(ids: ID[] | ((data: NodeData[]) => ID[])): void {
|
|
@@ -682,10 +876,18 @@ export class Graph extends EventEmitter {
|
|
|
682
876
|
}
|
|
683
877
|
|
|
684
878
|
/**
|
|
685
|
-
* <zh/>
|
|
879
|
+
* <zh/> 删除边数据
|
|
686
880
|
*
|
|
687
|
-
* <en/> Remove
|
|
881
|
+
* <en/> Remove edge data
|
|
688
882
|
* @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
|
|
883
|
+
* @remarks
|
|
884
|
+
* <zh/> 如果传入边数据时仅提供了 source 和 target,那么需要通过 `idOf` 方法获取边的实际 ID
|
|
885
|
+
*
|
|
886
|
+
* <en/> If only the source and target are provided when passing in the edge data, you need to get the actual ID of the edge through the `idOf` method
|
|
887
|
+
* @example
|
|
888
|
+
* ```ts
|
|
889
|
+
* graph.removeEdgeData(['edge-1']);
|
|
890
|
+
* ```
|
|
689
891
|
* @apiCategory data
|
|
690
892
|
*/
|
|
691
893
|
public removeEdgeData(ids: ID[] | ((data: EdgeData[]) => ID[])): void {
|
|
@@ -693,10 +895,14 @@ export class Graph extends EventEmitter {
|
|
|
693
895
|
}
|
|
694
896
|
|
|
695
897
|
/**
|
|
696
|
-
* <zh/>
|
|
898
|
+
* <zh/> 删除组合数据
|
|
697
899
|
*
|
|
698
|
-
* <en/> Remove
|
|
900
|
+
* <en/> Remove combo data
|
|
699
901
|
* @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
|
|
902
|
+
* @example
|
|
903
|
+
* ```ts
|
|
904
|
+
* graph.removeComboData(['combo-1']);
|
|
905
|
+
* ```
|
|
700
906
|
* @apiCategory data
|
|
701
907
|
*/
|
|
702
908
|
public removeComboData(ids: ID[] | ((data: ComboData[]) => ID[])): void {
|
|
@@ -788,6 +994,10 @@ export class Graph extends EventEmitter {
|
|
|
788
994
|
* <en/> Get node data in a specific state
|
|
789
995
|
* @param state - <zh/> 状态 | <en/> state
|
|
790
996
|
* @returns <zh/> 节点数据 | <en/> node data
|
|
997
|
+
* @example
|
|
998
|
+
* ```ts
|
|
999
|
+
* const nodes = graph.getElementDataByState('node', 'selected');
|
|
1000
|
+
* ```
|
|
791
1001
|
* @apiCategory data
|
|
792
1002
|
*/
|
|
793
1003
|
public getElementDataByState(elementType: 'node', state: State): NodeData[];
|
|
@@ -797,6 +1007,10 @@ export class Graph extends EventEmitter {
|
|
|
797
1007
|
* <en/> Get edge data in a specific state
|
|
798
1008
|
* @param state - <zh/> 状态 | <en/> state
|
|
799
1009
|
* @returns <zh/> 边数据 | <en/> edge data
|
|
1010
|
+
* @example
|
|
1011
|
+
* ```ts
|
|
1012
|
+
* const nodes = graph.getElementDataByState('edge', 'selected');
|
|
1013
|
+
* ```
|
|
800
1014
|
* @apiCategory data
|
|
801
1015
|
*/
|
|
802
1016
|
public getElementDataByState(elementType: 'edge', state: State): EdgeData[];
|
|
@@ -806,6 +1020,10 @@ export class Graph extends EventEmitter {
|
|
|
806
1020
|
* <en/> Get combo data in a specific state
|
|
807
1021
|
* @param state - <zh/> 状态 | <en/> state
|
|
808
1022
|
* @returns <zh/> 组合数据 | <en/> combo data
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```ts
|
|
1025
|
+
* const nodes = graph.getElementDataByState('node', 'selected');
|
|
1026
|
+
* ```
|
|
809
1027
|
* @apiCategory data
|
|
810
1028
|
*/
|
|
811
1029
|
public getElementDataByState(elementType: 'combo', state: State): ComboData[];
|
|
@@ -872,7 +1090,11 @@ export class Graph extends EventEmitter {
|
|
|
872
1090
|
* @remarks
|
|
873
1091
|
* <zh/> 此过程会执行数据更新、绘制元素、执行布局
|
|
874
1092
|
*
|
|
1093
|
+
* > ⚠️ render 为异步方法,如果需要在 render 后执行一些操作,可以使用 `await graph.render()` 或者监听 GraphEvent.AFTER_RENDER 事件
|
|
1094
|
+
*
|
|
875
1095
|
* <en/> This process will execute data update, element rendering, and layout execution
|
|
1096
|
+
*
|
|
1097
|
+
* > ⚠️ render is an asynchronous method. If you need to perform some operations after render, you can use `await graph.render()` or listen to the GraphEvent.AFTER_RENDER event
|
|
876
1098
|
* @apiCategory render
|
|
877
1099
|
*/
|
|
878
1100
|
public async render(): Promise<void> {
|
|
@@ -889,7 +1111,15 @@ export class Graph extends EventEmitter {
|
|
|
889
1111
|
*
|
|
890
1112
|
* <en/> Draw elements
|
|
891
1113
|
* @returns <zh/> 渲染结果 | <en/> draw result
|
|
892
|
-
* @
|
|
1114
|
+
* @remarks
|
|
1115
|
+
* <zh/> 仅执行元素绘制,不会重新布局
|
|
1116
|
+
*
|
|
1117
|
+
* <zh/> ⚠️ draw 为异步方法,如果需要在 draw 后执行一些操作,可以使用 `await graph.draw()` 或者监听 GraphEvent.AFTER_DRAW 事件
|
|
1118
|
+
*
|
|
1119
|
+
* <en/> Only execute element drawing, no re-layout
|
|
1120
|
+
*
|
|
1121
|
+
* <en/> ⚠️ draw is an asynchronous method. If you need to perform some operations after draw, you can use `await graph.draw()` or listen to the GraphEvent.AFTER_DRAW event
|
|
1122
|
+
* @apiCategory render
|
|
893
1123
|
*/
|
|
894
1124
|
public async draw(): Promise<void> {
|
|
895
1125
|
await this.prepare();
|
|
@@ -936,6 +1166,10 @@ export class Graph extends EventEmitter {
|
|
|
936
1166
|
* <zh/> 销毁当前图实例
|
|
937
1167
|
*
|
|
938
1168
|
* <en/> Destroy the current graph instance
|
|
1169
|
+
* @remarks
|
|
1170
|
+
* <zh/> 销毁后无法进行任何操作,如果需要重新使用,需要重新创建一个新的图实例
|
|
1171
|
+
*
|
|
1172
|
+
* <en/> After destruction, no operations can be performed. If you need to reuse it, you need to create a new graph instance
|
|
939
1173
|
* @apiCategory instance
|
|
940
1174
|
*/
|
|
941
1175
|
public destroy(): void {
|
|
@@ -1001,7 +1235,7 @@ export class Graph extends EventEmitter {
|
|
|
1001
1235
|
*
|
|
1002
1236
|
* <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
|
|
1003
1237
|
* @param options - <zh/> 适配配置 | <en/> fit options
|
|
1004
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1238
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1005
1239
|
* @apiCategory viewport
|
|
1006
1240
|
*/
|
|
1007
1241
|
public async fitView(options?: FitViewOptions, animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
@@ -1012,7 +1246,7 @@ export class Graph extends EventEmitter {
|
|
|
1012
1246
|
* <zh/> 将图平移至视口中心
|
|
1013
1247
|
*
|
|
1014
1248
|
* <en/> Move the graph to the center of the viewport
|
|
1015
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1249
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1016
1250
|
* @apiCategory viewport
|
|
1017
1251
|
*/
|
|
1018
1252
|
public async fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
@@ -1034,11 +1268,15 @@ export class Graph extends EventEmitter {
|
|
|
1034
1268
|
}
|
|
1035
1269
|
|
|
1036
1270
|
/**
|
|
1271
|
+
* <zh/> 聚焦元素
|
|
1272
|
+
*
|
|
1273
|
+
* <en/> Focus on element
|
|
1274
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1275
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1276
|
+
* @remarks
|
|
1037
1277
|
* <zh/> 移动图,使得元素对齐到视口中心
|
|
1038
1278
|
*
|
|
1039
1279
|
* <en/> Move the graph so that the element is aligned to the center of the viewport
|
|
1040
|
-
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1041
|
-
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
1042
1280
|
* @apiCategory viewport
|
|
1043
1281
|
*/
|
|
1044
1282
|
public async focusElement(id: ID | ID[], animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
@@ -1046,11 +1284,11 @@ export class Graph extends EventEmitter {
|
|
|
1046
1284
|
}
|
|
1047
1285
|
|
|
1048
1286
|
/**
|
|
1049
|
-
* <zh/>
|
|
1287
|
+
* <zh/> 基于当前缩放比例进行缩放(相对缩放)
|
|
1050
1288
|
*
|
|
1051
|
-
* <en/> Zoom based on the current zoom ratio
|
|
1289
|
+
* <en/> Zoom based on the current zoom ratio (relative zoom)
|
|
1052
1290
|
* @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
|
|
1053
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1291
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1054
1292
|
* @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
|
|
1055
1293
|
* @remarks
|
|
1056
1294
|
* <zh/>
|
|
@@ -1067,11 +1305,11 @@ export class Graph extends EventEmitter {
|
|
|
1067
1305
|
}
|
|
1068
1306
|
|
|
1069
1307
|
/**
|
|
1070
|
-
* <zh/>
|
|
1308
|
+
* <zh/> 缩放画布至指定比例(绝对缩放)
|
|
1071
1309
|
*
|
|
1072
|
-
* <en/> Zoom the canvas to the specified ratio
|
|
1310
|
+
* <en/> Zoom the canvas to the specified ratio (absolute zoom)
|
|
1073
1311
|
* @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
|
|
1074
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1312
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1075
1313
|
* @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
|
|
1076
1314
|
* @remarks
|
|
1077
1315
|
* <zh/>
|
|
@@ -1101,11 +1339,11 @@ export class Graph extends EventEmitter {
|
|
|
1101
1339
|
}
|
|
1102
1340
|
|
|
1103
1341
|
/**
|
|
1104
|
-
* <zh/>
|
|
1342
|
+
* <zh/> 基于当前旋转角度进行旋转(相对旋转)
|
|
1105
1343
|
*
|
|
1106
|
-
* <en/> Rotate based on the current rotation angle
|
|
1344
|
+
* <en/> Rotate based on the current rotation angle (relative rotation)
|
|
1107
1345
|
* @param angle - <zh/> 旋转角度 | <en/> rotation angle
|
|
1108
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1346
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1109
1347
|
* @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
|
|
1110
1348
|
* @apiCategory viewport
|
|
1111
1349
|
*/
|
|
@@ -1114,11 +1352,11 @@ export class Graph extends EventEmitter {
|
|
|
1114
1352
|
}
|
|
1115
1353
|
|
|
1116
1354
|
/**
|
|
1117
|
-
* <zh/> 旋转画布至指定角度
|
|
1355
|
+
* <zh/> 旋转画布至指定角度 (绝对旋转)
|
|
1118
1356
|
*
|
|
1119
|
-
* <en/> Rotate the canvas to the specified angle
|
|
1357
|
+
* <en/> Rotate the canvas to the specified angle (absolute rotation)
|
|
1120
1358
|
* @param angle - <zh/> 目标角度 | <en/> target angle
|
|
1121
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1359
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1122
1360
|
* @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
|
|
1123
1361
|
* @apiCategory viewport
|
|
1124
1362
|
*/
|
|
@@ -1138,11 +1376,11 @@ export class Graph extends EventEmitter {
|
|
|
1138
1376
|
}
|
|
1139
1377
|
|
|
1140
1378
|
/**
|
|
1141
|
-
* <zh/> 将图平移指定距离
|
|
1379
|
+
* <zh/> 将图平移指定距离 (相对平移)
|
|
1142
1380
|
*
|
|
1143
|
-
* <en/> Translate the graph by the specified distance
|
|
1381
|
+
* <en/> Translate the graph by the specified distance (relative translation)
|
|
1144
1382
|
* @param offset - <zh/> 偏移量 | <en/> offset
|
|
1145
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1383
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1146
1384
|
* @apiCategory viewport
|
|
1147
1385
|
*/
|
|
1148
1386
|
public async translateBy(offset: Point, animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
@@ -1150,11 +1388,11 @@ export class Graph extends EventEmitter {
|
|
|
1150
1388
|
}
|
|
1151
1389
|
|
|
1152
1390
|
/**
|
|
1153
|
-
* <zh/> 将图平移至指定位置
|
|
1391
|
+
* <zh/> 将图平移至指定位置 (绝对平移)
|
|
1154
1392
|
*
|
|
1155
|
-
* <en/> Translate the graph to the specified position
|
|
1393
|
+
* <en/> Translate the graph to the specified position (absolute translation)
|
|
1156
1394
|
* @param position - <zh/> 指定位置 | <en/> specified position
|
|
1157
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1395
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1158
1396
|
* @apiCategory viewport
|
|
1159
1397
|
*/
|
|
1160
1398
|
public async translateTo(position: Point, animation?: ViewportAnimationEffectTiming): Promise<void> {
|
|
@@ -1177,64 +1415,64 @@ export class Graph extends EventEmitter {
|
|
|
1177
1415
|
}
|
|
1178
1416
|
|
|
1179
1417
|
/**
|
|
1180
|
-
* <zh/> 将元素平移指定距离
|
|
1418
|
+
* <zh/> 将元素平移指定距离 (相对平移)
|
|
1181
1419
|
*
|
|
1182
|
-
* <en/> Translate the element by the specified distance
|
|
1420
|
+
* <en/> Translate the element by the specified distance (relative translation)
|
|
1183
1421
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1184
1422
|
* @param offset - <zh/> 偏移量 | <en/> offset
|
|
1185
1423
|
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1186
1424
|
* @apiCategory element
|
|
1187
1425
|
*/
|
|
1188
|
-
public async translateElementBy(id: ID, offset:
|
|
1426
|
+
public async translateElementBy(id: ID, offset: Point, animation?: boolean): Promise<void>;
|
|
1189
1427
|
/**
|
|
1190
|
-
* <zh/> 批量将元素平移指定距离
|
|
1428
|
+
* <zh/> 批量将元素平移指定距离 (相对平移)
|
|
1191
1429
|
*
|
|
1192
|
-
* <en/> Batch translate elements by the specified distance
|
|
1193
|
-
* @param offsets - <zh/> 偏移量配置 | <en/> offset
|
|
1430
|
+
* <en/> Batch translate elements by the specified distance (relative translation)
|
|
1431
|
+
* @param offsets - <zh/> 偏移量配置 | <en/> offset options
|
|
1194
1432
|
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1195
1433
|
* @apiCategory element
|
|
1196
1434
|
*/
|
|
1197
|
-
public async translateElementBy(offsets: Record<ID,
|
|
1435
|
+
public async translateElementBy(offsets: Record<ID, Point>, animation?: boolean): Promise<void>;
|
|
1198
1436
|
public async translateElementBy(
|
|
1199
|
-
args1: ID | Record<ID,
|
|
1200
|
-
args2?:
|
|
1437
|
+
args1: ID | Record<ID, Point>,
|
|
1438
|
+
args2?: Point | boolean,
|
|
1201
1439
|
args3: boolean = true,
|
|
1202
1440
|
): Promise<void> {
|
|
1203
1441
|
const [config, animation] = isObject(args1)
|
|
1204
1442
|
? [args1, (args2 as boolean) ?? true]
|
|
1205
|
-
: [{ [args1 as ID]: args2 as
|
|
1443
|
+
: [{ [args1 as ID]: args2 as Point }, args3];
|
|
1206
1444
|
|
|
1207
1445
|
Object.entries(config).forEach(([id, offset]) => this.context.model.translateNodeBy(id, offset));
|
|
1208
1446
|
await this.context.element!.draw({ animation })?.finished;
|
|
1209
1447
|
}
|
|
1210
1448
|
|
|
1211
1449
|
/**
|
|
1212
|
-
* <zh/> 将元素平移至指定位置
|
|
1450
|
+
* <zh/> 将元素平移至指定位置 (绝对平移)
|
|
1213
1451
|
*
|
|
1214
|
-
* <en/> Translate the element to the specified position
|
|
1452
|
+
* <en/> Translate the element to the specified position (absolute translation)
|
|
1215
1453
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1216
1454
|
* @param position - <zh/> 指定位置 | <en/> specified position
|
|
1217
1455
|
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1218
1456
|
* @apiCategory element
|
|
1219
1457
|
*/
|
|
1220
|
-
public async translateElementTo(id: ID, position:
|
|
1458
|
+
public async translateElementTo(id: ID, position: Point, animation?: boolean): Promise<void>;
|
|
1221
1459
|
/**
|
|
1222
|
-
* <zh/> 批量将元素平移至指定位置
|
|
1460
|
+
* <zh/> 批量将元素平移至指定位置 (绝对平移)
|
|
1223
1461
|
*
|
|
1224
|
-
* <en/> Batch translate elements to the specified position
|
|
1225
|
-
* @param positions - <zh/> 位置配置 | <en/> position
|
|
1462
|
+
* <en/> Batch translate elements to the specified position (absolute translation)
|
|
1463
|
+
* @param positions - <zh/> 位置配置 | <en/> position options
|
|
1226
1464
|
* @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
|
|
1227
1465
|
* @apiCategory element
|
|
1228
1466
|
*/
|
|
1229
|
-
public async translateElementTo(positions: Record<ID,
|
|
1467
|
+
public async translateElementTo(positions: Record<ID, Point>, animation?: boolean): Promise<void>;
|
|
1230
1468
|
public async translateElementTo(
|
|
1231
|
-
args1: ID | Record<ID,
|
|
1232
|
-
args2?: boolean |
|
|
1469
|
+
args1: ID | Record<ID, Point>,
|
|
1470
|
+
args2?: boolean | Point,
|
|
1233
1471
|
args3: boolean = true,
|
|
1234
1472
|
): Promise<void> {
|
|
1235
1473
|
const [config, animation] = isObject(args1)
|
|
1236
1474
|
? [args1, (args2 as boolean) ?? true]
|
|
1237
|
-
: [{ [args1 as ID]: args2 as
|
|
1475
|
+
: [{ [args1 as ID]: args2 as Point }, args3];
|
|
1238
1476
|
|
|
1239
1477
|
Object.entries(config).forEach(([id, position]) => this.context.model.translateNodeTo(id, position));
|
|
1240
1478
|
await this.context.element!.draw({ animation })?.finished;
|
|
@@ -1248,7 +1486,7 @@ export class Graph extends EventEmitter {
|
|
|
1248
1486
|
* @returns <zh/> 元素位置 | <en/> element position
|
|
1249
1487
|
* @apiCategory element
|
|
1250
1488
|
*/
|
|
1251
|
-
public getElementPosition(id: ID):
|
|
1489
|
+
public getElementPosition(id: ID): Point {
|
|
1252
1490
|
return this.context.model.getElementPosition(id);
|
|
1253
1491
|
}
|
|
1254
1492
|
|
|
@@ -1260,7 +1498,7 @@ export class Graph extends EventEmitter {
|
|
|
1260
1498
|
* @returns <zh/> 元素渲染样式 | <en/> element rendering style
|
|
1261
1499
|
* @apiCategory element
|
|
1262
1500
|
*/
|
|
1263
|
-
public getElementRenderStyle(id: ID) {
|
|
1501
|
+
public getElementRenderStyle(id: ID): Record<string, any> {
|
|
1264
1502
|
return omit(this.context.element!.getElement(id)!.attributes, ['context']);
|
|
1265
1503
|
}
|
|
1266
1504
|
|
|
@@ -1270,7 +1508,11 @@ export class Graph extends EventEmitter {
|
|
|
1270
1508
|
* <en/> Set element visibility
|
|
1271
1509
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1272
1510
|
* @param visibility - <zh/> 可见性 | <en/> visibility
|
|
1273
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1511
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1512
|
+
* @remarks
|
|
1513
|
+
* <zh/> 可见性配置包括 `visible` 和 `hidden` 两种状态
|
|
1514
|
+
*
|
|
1515
|
+
* <en/> Visibility configuration includes two states: `visible` and `hidden`
|
|
1274
1516
|
* @apiCategory element
|
|
1275
1517
|
*/
|
|
1276
1518
|
public async setElementVisibility(
|
|
@@ -1282,8 +1524,8 @@ export class Graph extends EventEmitter {
|
|
|
1282
1524
|
* <zh/> 批量设置元素可见性
|
|
1283
1525
|
*
|
|
1284
1526
|
* <en/> Batch set element visibility
|
|
1285
|
-
* @param visibility - <zh/> 可见性配置 | <en/> visibility
|
|
1286
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1527
|
+
* @param visibility - <zh/> 可见性配置 | <en/> visibility options
|
|
1528
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1287
1529
|
* @apiCategory element
|
|
1288
1530
|
*/
|
|
1289
1531
|
public async setElementVisibility(
|
|
@@ -1370,7 +1612,7 @@ export class Graph extends EventEmitter {
|
|
|
1370
1612
|
* <zh/> 批量设置元素层级
|
|
1371
1613
|
*
|
|
1372
1614
|
* <en/> Batch set element z-index
|
|
1373
|
-
* @param zIndex - <zh/> 层级配置 | <en/> z-index
|
|
1615
|
+
* @param zIndex - <zh/> 层级配置 | <en/> z-index options
|
|
1374
1616
|
* @apiCategory element
|
|
1375
1617
|
*/
|
|
1376
1618
|
public async setElementZIndex(zIndex: Record<ID, number>): Promise<void>;
|
|
@@ -1397,20 +1639,18 @@ export class Graph extends EventEmitter {
|
|
|
1397
1639
|
*/
|
|
1398
1640
|
public async frontElement(id: ID | ID[]): Promise<void> {
|
|
1399
1641
|
const ids = Array.isArray(id) ? id : [id];
|
|
1400
|
-
const { model } = this.context;
|
|
1642
|
+
const { model, element } = this.context;
|
|
1401
1643
|
const config: Record<ID, number> = {};
|
|
1402
1644
|
|
|
1403
1645
|
ids.map((_id) => {
|
|
1404
|
-
const zIndex =
|
|
1646
|
+
const zIndex = element!.getFrontZIndex(_id);
|
|
1405
1647
|
const elementType = model.getElementType(_id);
|
|
1406
1648
|
if (elementType === 'combo') {
|
|
1407
1649
|
const ancestor = model.getAncestorsData(_id, COMBO_KEY).at(-1) || this.getComboData(_id);
|
|
1408
|
-
const combos = [ancestor, ...model.getDescendantsData(idOf(ancestor))]
|
|
1409
|
-
|
|
1410
|
-
);
|
|
1411
|
-
const delta = zIndex - zIndexOf(ancestor);
|
|
1650
|
+
const combos = [ancestor, ...model.getDescendantsData(idOf(ancestor))];
|
|
1651
|
+
const delta = zIndex - element!.getElementZIndex(_id);
|
|
1412
1652
|
combos.forEach((combo) => {
|
|
1413
|
-
config[idOf(combo)] =
|
|
1653
|
+
config[idOf(combo)] = this.getElementZIndex(idOf(combo)) + delta;
|
|
1414
1654
|
});
|
|
1415
1655
|
} else config[_id] = zIndex;
|
|
1416
1656
|
});
|
|
@@ -1427,7 +1667,8 @@ export class Graph extends EventEmitter {
|
|
|
1427
1667
|
* @apiCategory element
|
|
1428
1668
|
*/
|
|
1429
1669
|
public getElementZIndex(id: ID): number {
|
|
1430
|
-
|
|
1670
|
+
const { model, element } = this.context;
|
|
1671
|
+
return model.getElementDataById(id)?.style?.zIndex ?? element!.getElementZIndex(id);
|
|
1431
1672
|
}
|
|
1432
1673
|
|
|
1433
1674
|
/**
|
|
@@ -1436,7 +1677,7 @@ export class Graph extends EventEmitter {
|
|
|
1436
1677
|
* <en/> Set element state
|
|
1437
1678
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
1438
1679
|
* @param state - <zh/> 状态 | <en/> state
|
|
1439
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1680
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1440
1681
|
* @apiCategory element
|
|
1441
1682
|
*/
|
|
1442
1683
|
public async setElementState(id: ID, state: State | State[], animation?: boolean): Promise<void>;
|
|
@@ -1444,8 +1685,8 @@ export class Graph extends EventEmitter {
|
|
|
1444
1685
|
* <zh/> 批量设置元素状态
|
|
1445
1686
|
*
|
|
1446
1687
|
* <en/> Batch set element state
|
|
1447
|
-
* @param state - <zh/> 状态配置 | <en/> state
|
|
1448
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1688
|
+
* @param state - <zh/> 状态配置 | <en/> state options
|
|
1689
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
1449
1690
|
* @apiCategory element
|
|
1450
1691
|
*/
|
|
1451
1692
|
public async setElementState(state: Record<ID, State | State[]>, animation?: boolean): Promise<void>;
|
|
@@ -1500,7 +1741,7 @@ export class Graph extends EventEmitter {
|
|
|
1500
1741
|
private isCollapsingExpanding = false;
|
|
1501
1742
|
|
|
1502
1743
|
/**
|
|
1503
|
-
* <zh/>
|
|
1744
|
+
* <zh/> 收起组合
|
|
1504
1745
|
*
|
|
1505
1746
|
* <en/> Collapse Combo
|
|
1506
1747
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
@@ -1524,7 +1765,7 @@ export class Graph extends EventEmitter {
|
|
|
1524
1765
|
}
|
|
1525
1766
|
|
|
1526
1767
|
/**
|
|
1527
|
-
* <zh/>
|
|
1768
|
+
* <zh/> 展开组合
|
|
1528
1769
|
*
|
|
1529
1770
|
* <en/> Expand Combo
|
|
1530
1771
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
@@ -1557,7 +1798,7 @@ export class Graph extends EventEmitter {
|
|
|
1557
1798
|
* <zh/> 导出画布内容为 DataURL
|
|
1558
1799
|
*
|
|
1559
1800
|
* <en/> Export canvas content as DataURL
|
|
1560
|
-
* @param options - <zh/> 导出配置 | <en/> export
|
|
1801
|
+
* @param options - <zh/> 导出配置 | <en/> export options
|
|
1561
1802
|
* @returns <zh/> DataURL | <en/> DataURL
|
|
1562
1803
|
* @apiCategory exportImage
|
|
1563
1804
|
*/
|
|
@@ -1650,7 +1891,7 @@ export class Graph extends EventEmitter {
|
|
|
1650
1891
|
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1651
1892
|
* @apiCategory event
|
|
1652
1893
|
*/
|
|
1653
|
-
public on<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void) {
|
|
1894
|
+
public on<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void): this {
|
|
1654
1895
|
return super.on(eventName, callback);
|
|
1655
1896
|
}
|
|
1656
1897
|
|
|
@@ -1663,7 +1904,38 @@ export class Graph extends EventEmitter {
|
|
|
1663
1904
|
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1664
1905
|
* @apiCategory event
|
|
1665
1906
|
*/
|
|
1666
|
-
public once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void) {
|
|
1907
|
+
public once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void): this {
|
|
1667
1908
|
return super.once(eventName, callback);
|
|
1668
1909
|
}
|
|
1910
|
+
|
|
1911
|
+
/**
|
|
1912
|
+
* <zh/> 移除全部事件监听
|
|
1913
|
+
*
|
|
1914
|
+
* <en/> Remove all event listeners
|
|
1915
|
+
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1916
|
+
* @apiCategory event
|
|
1917
|
+
*/
|
|
1918
|
+
public off(): this;
|
|
1919
|
+
/**
|
|
1920
|
+
* <zh/> 移除指定事件的全部监听
|
|
1921
|
+
*
|
|
1922
|
+
* <en/> Remove all listeners for the specified event
|
|
1923
|
+
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
1924
|
+
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1925
|
+
* @apiCategory event
|
|
1926
|
+
*/
|
|
1927
|
+
public off(eventName: string): this;
|
|
1928
|
+
/**
|
|
1929
|
+
* <zh/> 移除事件监听
|
|
1930
|
+
*
|
|
1931
|
+
* <en/> Remove event listener
|
|
1932
|
+
* @param eventName - <zh/> 事件名称 | <en/> event name
|
|
1933
|
+
* @param callback - <zh/> 回调函数 | <en/> callback function
|
|
1934
|
+
* @returns <zh/> Graph 实例 | <en/> Graph instance
|
|
1935
|
+
* @apiCategory event
|
|
1936
|
+
*/
|
|
1937
|
+
public off(eventName: string, callback: (...args: any[]) => void): this;
|
|
1938
|
+
public off(eventName?: string, callback?: (...args: any[]) => void) {
|
|
1939
|
+
return super.off(eventName, callback);
|
|
1940
|
+
}
|
|
1669
1941
|
}
|