@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/esm/runtime/graph.js
CHANGED
|
@@ -7,7 +7,6 @@ import { sizeOf } from '../utils/dom';
|
|
|
7
7
|
import { GraphLifeCycleEvent, emit } from '../utils/event';
|
|
8
8
|
import { idOf } from '../utils/id';
|
|
9
9
|
import { parsePoint, toPointObject } from '../utils/point';
|
|
10
|
-
import { zIndexOf } from '../utils/style';
|
|
11
10
|
import { subtract } from '../utils/vector';
|
|
12
11
|
import { Animation } from './animation';
|
|
13
12
|
import { BatchController } from './batch';
|
|
@@ -118,7 +117,7 @@ export class Graph extends EventEmitter {
|
|
|
118
117
|
return this.options.background;
|
|
119
118
|
}
|
|
120
119
|
/**
|
|
121
|
-
* <zh/>
|
|
120
|
+
* <zh/> 获取当前画布容器的尺寸
|
|
122
121
|
*
|
|
123
122
|
* <en/> Get the size of the current canvas container
|
|
124
123
|
* @returns <zh/> 画布尺寸 | <en/> canvas size
|
|
@@ -130,7 +129,7 @@ export class Graph extends EventEmitter {
|
|
|
130
129
|
return [this.options.width || 0, this.options.height || 0];
|
|
131
130
|
}
|
|
132
131
|
/**
|
|
133
|
-
* <zh/>
|
|
132
|
+
* <zh/> 获取当前画布容器的尺寸
|
|
134
133
|
*
|
|
135
134
|
* <en/> Get the size of the current canvas container
|
|
136
135
|
* @param width - <zh/> 画布宽度 | <en/> canvas width
|
|
@@ -165,7 +164,11 @@ export class Graph extends EventEmitter {
|
|
|
165
164
|
* <zh/> 设置节点样式映射
|
|
166
165
|
*
|
|
167
166
|
* <en/> Set node mapper
|
|
168
|
-
* @param node - <zh/> 节点配置 | <en/> node
|
|
167
|
+
* @param node - <zh/> 节点配置 | <en/> node options
|
|
168
|
+
* @remarks
|
|
169
|
+
* <zh/> 即 `options.node` 的值
|
|
170
|
+
*
|
|
171
|
+
* <en/> The value of `options.node`
|
|
169
172
|
* @apiCategory element
|
|
170
173
|
*/
|
|
171
174
|
setNode(node) {
|
|
@@ -176,7 +179,11 @@ export class Graph extends EventEmitter {
|
|
|
176
179
|
* <zh/> 设置边样式映射
|
|
177
180
|
*
|
|
178
181
|
* <en/> Set edge mapper
|
|
179
|
-
* @param edge - <zh/> 边配置 | <en/> edge
|
|
182
|
+
* @param edge - <zh/> 边配置 | <en/> edge options
|
|
183
|
+
* @remarks
|
|
184
|
+
* <zh/> 即 `options.edge` 的值
|
|
185
|
+
*
|
|
186
|
+
* <en/> The value of `options.edge`
|
|
180
187
|
* @apiCategory element
|
|
181
188
|
*/
|
|
182
189
|
setEdge(edge) {
|
|
@@ -187,7 +194,11 @@ export class Graph extends EventEmitter {
|
|
|
187
194
|
* <zh/> 设置组合样式映射
|
|
188
195
|
*
|
|
189
196
|
* <en/> Set combo mapper
|
|
190
|
-
* @param combo - <zh/> 组合配置 | <en/> combo
|
|
197
|
+
* @param combo - <zh/> 组合配置 | <en/> combo options
|
|
198
|
+
* @remarks
|
|
199
|
+
* <zh/> 即 `options.combo` 的值
|
|
200
|
+
*
|
|
201
|
+
* <en/> The value of `options.combo`
|
|
191
202
|
* @apiCategory element
|
|
192
203
|
*/
|
|
193
204
|
setCombo(combo) {
|
|
@@ -198,7 +209,7 @@ export class Graph extends EventEmitter {
|
|
|
198
209
|
* <zh/> 获取主题
|
|
199
210
|
*
|
|
200
211
|
* <en/> Get theme
|
|
201
|
-
* @returns <zh/>
|
|
212
|
+
* @returns <zh/> 当前主题 | <en/> current theme
|
|
202
213
|
* @apiCategory theme
|
|
203
214
|
*/
|
|
204
215
|
getTheme() {
|
|
@@ -208,7 +219,11 @@ export class Graph extends EventEmitter {
|
|
|
208
219
|
* <zh/> 设置主题
|
|
209
220
|
*
|
|
210
221
|
* <en/> Set theme
|
|
211
|
-
* @param theme - <zh/>
|
|
222
|
+
* @param theme - <zh/> 主题名 | <en/> theme name
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* graph.setTheme('dark');
|
|
226
|
+
* ```
|
|
212
227
|
* @apiCategory theme
|
|
213
228
|
*/
|
|
214
229
|
setTheme(theme) {
|
|
@@ -222,17 +237,23 @@ export class Graph extends EventEmitter {
|
|
|
222
237
|
* <zh/> 设置布局
|
|
223
238
|
*
|
|
224
239
|
* <en/> Set layout
|
|
225
|
-
* @param layout - <zh/> 布局配置 | <en/> layout
|
|
240
|
+
* @param layout - <zh/> 布局配置 | <en/> layout options
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* graph.setLayout({
|
|
244
|
+
* type: 'dagre',
|
|
245
|
+
* })
|
|
246
|
+
* ```
|
|
226
247
|
* @apiCategory layout
|
|
227
248
|
*/
|
|
228
249
|
setLayout(layout) {
|
|
229
250
|
this.options.layout = isFunction(layout) ? layout(this.getLayout()) : layout;
|
|
230
251
|
}
|
|
231
252
|
/**
|
|
232
|
-
* <zh/>
|
|
253
|
+
* <zh/> 获取布局配置
|
|
233
254
|
*
|
|
234
|
-
* <en/> Get layout
|
|
235
|
-
* @returns <zh/> 布局配置 | <en/> layout
|
|
255
|
+
* <en/> Get layout options
|
|
256
|
+
* @returns <zh/> 布局配置 | <en/> layout options
|
|
236
257
|
* @apiCategory layout
|
|
237
258
|
*/
|
|
238
259
|
getLayout() {
|
|
@@ -242,7 +263,15 @@ export class Graph extends EventEmitter {
|
|
|
242
263
|
* <zh/> 设置交互
|
|
243
264
|
*
|
|
244
265
|
* <en/> Set behaviors
|
|
245
|
-
* @param behaviors - <zh/> 交互配置 | <en/> behavior
|
|
266
|
+
* @param behaviors - <zh/> 交互配置 | <en/> behavior options
|
|
267
|
+
* @remarks
|
|
268
|
+
* <zh/> 设置的交互会全量替换原有的交互,如果需要新增交互可以使用如下方式:
|
|
269
|
+
*
|
|
270
|
+
* <en/> The set behavior will completely replace the original behavior. If you need to add behavior, you can use the following method:
|
|
271
|
+
*
|
|
272
|
+
* ```ts
|
|
273
|
+
* graph.setBehaviors((behaviors) => [...behaviors, { type: 'zoom-canvas' }])
|
|
274
|
+
* ```
|
|
246
275
|
* @apiCategory behavior
|
|
247
276
|
*/
|
|
248
277
|
setBehaviors(behaviors) {
|
|
@@ -250,10 +279,21 @@ export class Graph extends EventEmitter {
|
|
|
250
279
|
this.context.behavior?.setBehaviors(this.options.behaviors);
|
|
251
280
|
}
|
|
252
281
|
/**
|
|
253
|
-
* <zh/>
|
|
282
|
+
* <zh/> 更新指定的交互配置
|
|
283
|
+
*
|
|
284
|
+
* <en/> Update specified behavior options
|
|
285
|
+
* @param behavior - <zh/> 交互配置 | <en/> behavior options
|
|
286
|
+
* @remarks
|
|
287
|
+
* <zh/> 如果要更新一个交互,那么必须在交互配置中指定 key 字段,例如:
|
|
288
|
+
*
|
|
289
|
+
* <en/> If you want to update a behavior, you must specify the key field in the behavior options, for example:
|
|
290
|
+
* ```ts
|
|
291
|
+
* {
|
|
292
|
+
* behaviors: [{ type: 'zoom-canvas', key: 'zoom-canvas' }]
|
|
293
|
+
* }
|
|
254
294
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
295
|
+
* graph.updateBehavior({ key: 'zoom-canvas', enable: false })
|
|
296
|
+
* ```
|
|
257
297
|
* @apiCategory behavior
|
|
258
298
|
*/
|
|
259
299
|
updateBehavior(behavior) {
|
|
@@ -265,20 +305,27 @@ export class Graph extends EventEmitter {
|
|
|
265
305
|
}));
|
|
266
306
|
}
|
|
267
307
|
/**
|
|
268
|
-
* <zh/>
|
|
308
|
+
* <zh/> 获取交互配置
|
|
269
309
|
*
|
|
270
|
-
* <en/> Get behaviors
|
|
271
|
-
* @returns <zh/> 交互配置 | <en/> behavior
|
|
310
|
+
* <en/> Get behaviors options
|
|
311
|
+
* @returns <zh/> 交互配置 | <en/> behavior options
|
|
272
312
|
* @apiCategory behavior
|
|
273
313
|
*/
|
|
274
314
|
getBehaviors() {
|
|
275
315
|
return this.options.behaviors || [];
|
|
276
316
|
}
|
|
277
317
|
/**
|
|
278
|
-
* <zh/>
|
|
318
|
+
* <zh/> 设置插件配置
|
|
279
319
|
*
|
|
280
|
-
* <en/> Set plugins
|
|
281
|
-
* @param plugins - <zh/> 插件配置 | <en/> plugin
|
|
320
|
+
* <en/> Set plugins options
|
|
321
|
+
* @param plugins - <zh/> 插件配置 | <en/> plugin options
|
|
322
|
+
* @remarks
|
|
323
|
+
* <zh/> 设置的插件会全量替换原有的插件配置,如果需要新增插件可以使用如下方式:
|
|
324
|
+
*
|
|
325
|
+
* <en/> The set plugin will completely replace the original plugin configuration. If you need to add a plugin, you can use the following method:
|
|
326
|
+
* ```ts
|
|
327
|
+
* graph.setPlugins((plugins) => [...plugins, { key: 'grid-line' }])
|
|
328
|
+
* ```
|
|
282
329
|
* @apiCategory plugin
|
|
283
330
|
*/
|
|
284
331
|
setPlugins(plugins) {
|
|
@@ -286,10 +333,21 @@ export class Graph extends EventEmitter {
|
|
|
286
333
|
this.context.plugin?.setPlugins(this.options.plugins);
|
|
287
334
|
}
|
|
288
335
|
/**
|
|
289
|
-
* <zh/>
|
|
336
|
+
* <zh/> 更新插件配置
|
|
290
337
|
*
|
|
291
|
-
* <en/> Update plugin
|
|
292
|
-
* @param plugin - <zh/> 插件配置 | <en/> plugin
|
|
338
|
+
* <en/> Update plugin options
|
|
339
|
+
* @param plugin - <zh/> 插件配置 | <en/> plugin options
|
|
340
|
+
* @remarks
|
|
341
|
+
* <zh/> 如果要更新一个插件,那么必须在插件配置中指定 key 字段,例如:
|
|
342
|
+
*
|
|
343
|
+
* <en/> If you want to update a plugin, you must specify the key field in the plugin options, for example:
|
|
344
|
+
* ```ts
|
|
345
|
+
* {
|
|
346
|
+
* plugins: [{ key: 'grid-line' }]
|
|
347
|
+
* }
|
|
348
|
+
*
|
|
349
|
+
* graph.updatePlugin({ key: 'grid-line', follow: true })
|
|
350
|
+
* ```
|
|
293
351
|
* @apiCategory plugin
|
|
294
352
|
*/
|
|
295
353
|
updatePlugin(plugin) {
|
|
@@ -301,10 +359,10 @@ export class Graph extends EventEmitter {
|
|
|
301
359
|
}));
|
|
302
360
|
}
|
|
303
361
|
/**
|
|
304
|
-
* <zh/>
|
|
362
|
+
* <zh/> 获取插件配置
|
|
305
363
|
*
|
|
306
|
-
* <en/> Get plugins
|
|
307
|
-
* @returns <zh/> 插件配置 | <en/> plugin
|
|
364
|
+
* <en/> Get plugins options
|
|
365
|
+
* @returns <zh/> 插件配置 | <en/> plugin options
|
|
308
366
|
* @apiCategory plugin
|
|
309
367
|
*/
|
|
310
368
|
getPlugins() {
|
|
@@ -316,6 +374,17 @@ export class Graph extends EventEmitter {
|
|
|
316
374
|
* <en/> Get plugin instance
|
|
317
375
|
* @param key - <zh/> 插件 key | <en/> plugin key
|
|
318
376
|
* @returns <zh/> 插件实例 | <en/> plugin instance
|
|
377
|
+
* @remarks
|
|
378
|
+
* <zh/> 一些插件提供了 API 方法可供调用,例如全屏插件可以调用 `request` 和 `exit` 方法来请求和退出全屏
|
|
379
|
+
*
|
|
380
|
+
* <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
|
|
381
|
+
* ```ts
|
|
382
|
+
* const fullscreen = graph.getPluginInstance('fullscreen');
|
|
383
|
+
*
|
|
384
|
+
* fullscreen.request();
|
|
385
|
+
*
|
|
386
|
+
* fullscreen.exit();
|
|
387
|
+
* ```
|
|
319
388
|
* @apiCategory plugin
|
|
320
389
|
*/
|
|
321
390
|
getPluginInstance(key) {
|
|
@@ -325,7 +394,11 @@ export class Graph extends EventEmitter {
|
|
|
325
394
|
* <zh/> 设置数据转换器
|
|
326
395
|
*
|
|
327
396
|
* <en/> Set data transforms
|
|
328
|
-
* @param transforms - <zh/> 数据转换配置 | <en/> data transform
|
|
397
|
+
* @param transforms - <zh/> 数据转换配置 | <en/> data transform options
|
|
398
|
+
* @remarks
|
|
399
|
+
* <zh/> 数据转换器能够在图渲染过程中执行数据转换,目前支持在渲染前对绘制数据进行转化。
|
|
400
|
+
*
|
|
401
|
+
* <en/> Data transforms can perform data transformation during the rendering process of the graph. Currently, it supports transforming the drawing data before rendering.
|
|
329
402
|
* @apiCategory transform
|
|
330
403
|
*/
|
|
331
404
|
setTransforms(transforms) {
|
|
@@ -336,7 +409,7 @@ export class Graph extends EventEmitter {
|
|
|
336
409
|
* <zh/> 更新数据转换器
|
|
337
410
|
*
|
|
338
411
|
* <en/> Update data transform
|
|
339
|
-
* @param transform - <zh/>
|
|
412
|
+
* @param transform - <zh/> 数据转换器配置 | <en/> data transform options
|
|
340
413
|
* @apiCategory transform
|
|
341
414
|
*/
|
|
342
415
|
updateTransform(transform) {
|
|
@@ -349,20 +422,23 @@ export class Graph extends EventEmitter {
|
|
|
349
422
|
this.context.model.refreshData();
|
|
350
423
|
}
|
|
351
424
|
/**
|
|
352
|
-
* <zh/>
|
|
425
|
+
* <zh/> 获取数据转换器配置
|
|
353
426
|
*
|
|
354
|
-
* <en/> Get data transforms
|
|
355
|
-
* @returns <zh/>
|
|
427
|
+
* <en/> Get data transforms options
|
|
428
|
+
* @returns <zh/> 数据转换配置 | <en/> data transform options
|
|
356
429
|
* @apiCategory transform
|
|
357
430
|
*/
|
|
358
431
|
getTransforms() {
|
|
359
432
|
return this.options.transforms || [];
|
|
360
433
|
}
|
|
361
434
|
/**
|
|
362
|
-
* <zh/>
|
|
435
|
+
* <zh/> 获取图数据
|
|
436
|
+
*
|
|
437
|
+
* <en/> Get graph data
|
|
438
|
+
* @returns <zh/> 图数据 | <en/> Graph data
|
|
439
|
+
* <zh/> 获取当前图的数据,包括节点、边、组合数据
|
|
363
440
|
*
|
|
364
|
-
* <en/> Get data
|
|
365
|
-
* @returns <zh/> 数据 | <en/> data
|
|
441
|
+
* <en/> Get the data of the current graph, including node, edge, and combo data
|
|
366
442
|
* @apiCategory data
|
|
367
443
|
*/
|
|
368
444
|
getData() {
|
|
@@ -399,6 +475,10 @@ export class Graph extends EventEmitter {
|
|
|
399
475
|
*
|
|
400
476
|
* <en/> Set full data
|
|
401
477
|
* @param data - <zh/> 数据 | <en/> data
|
|
478
|
+
* @remarks
|
|
479
|
+
* <zh/> 设置全量数据会替换当前图中的所有数据,G6 会自动进行数据差异计算
|
|
480
|
+
*
|
|
481
|
+
* <en/> Setting full data will replace all data in the current graph, and G6 will automatically calculate the data difference
|
|
402
482
|
* @apiCategory data
|
|
403
483
|
*/
|
|
404
484
|
setData(data) {
|
|
@@ -409,6 +489,13 @@ export class Graph extends EventEmitter {
|
|
|
409
489
|
*
|
|
410
490
|
* <en/> Add element data
|
|
411
491
|
* @param data - <zh/> 元素数据 | <en/> element data
|
|
492
|
+
* @example
|
|
493
|
+
* ```ts
|
|
494
|
+
* graph.addData({
|
|
495
|
+
* nodes: [{ id: 'node-1' }, { id: 'node-2' }],
|
|
496
|
+
* edges: [{ source: 'node-1', target: 'node-2' }],
|
|
497
|
+
* });
|
|
498
|
+
* ```
|
|
412
499
|
* @apiCategory data
|
|
413
500
|
*/
|
|
414
501
|
addData(data) {
|
|
@@ -419,6 +506,10 @@ export class Graph extends EventEmitter {
|
|
|
419
506
|
*
|
|
420
507
|
* <en/> Add node data
|
|
421
508
|
* @param data - <zh/> 节点数据 | <en/> node data
|
|
509
|
+
* @example
|
|
510
|
+
* ```ts
|
|
511
|
+
* graph.addNodeData([{ id: 'node-1' }, { id: 'node-2' }]);
|
|
512
|
+
* ```
|
|
422
513
|
* @apiCategory data
|
|
423
514
|
*/
|
|
424
515
|
addNodeData(data) {
|
|
@@ -429,6 +520,10 @@ export class Graph extends EventEmitter {
|
|
|
429
520
|
*
|
|
430
521
|
* <en/> Add edge data
|
|
431
522
|
* @param data - <zh/> 边数据 | <en/> edge data
|
|
523
|
+
* @example
|
|
524
|
+
* ```ts
|
|
525
|
+
* graph.addEdgeData([{ source: 'node-1', target: 'node-2' }]);
|
|
526
|
+
* ```
|
|
432
527
|
* @apiCategory data
|
|
433
528
|
*/
|
|
434
529
|
addEdgeData(data) {
|
|
@@ -439,16 +534,45 @@ export class Graph extends EventEmitter {
|
|
|
439
534
|
*
|
|
440
535
|
* <en/> Add combo data
|
|
441
536
|
* @param data - <zh/> 组合数据 | <en/> combo data
|
|
537
|
+
* @example
|
|
538
|
+
* ```ts
|
|
539
|
+
* graph.addComboData([{ id: 'combo-1' }]);
|
|
540
|
+
* ```
|
|
442
541
|
* @apiCategory data
|
|
443
542
|
*/
|
|
444
543
|
addComboData(data) {
|
|
445
544
|
this.context.model.addComboData(isFunction(data) ? data(this.getComboData()) : data);
|
|
446
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* <zh/> 为树图节点添加子节点数据
|
|
548
|
+
*
|
|
549
|
+
* <en/> Add child node data to the tree node
|
|
550
|
+
* @param parentId - <zh/> 父节点 ID | <en/> parent node ID
|
|
551
|
+
* @param childrenData - <zh/> 子节点数据 | <en/> child node data
|
|
552
|
+
* @remarks
|
|
553
|
+
* <zh/> 为组合添加子节点使用 addNodeData / addComboData 方法
|
|
554
|
+
*
|
|
555
|
+
* <en/> Use addNodeData / addComboData method to add child nodes to the combo
|
|
556
|
+
*/
|
|
557
|
+
addChildrenData(parentId, childrenData) {
|
|
558
|
+
this.context.model.addChildrenData(parentId, childrenData);
|
|
559
|
+
}
|
|
447
560
|
/**
|
|
448
561
|
* <zh/> 更新元素数据
|
|
449
562
|
*
|
|
450
563
|
* <en/> Update element data
|
|
451
564
|
* @param data - <zh/> 元素数据 | <en/> element data
|
|
565
|
+
* @remarks
|
|
566
|
+
* <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
|
|
567
|
+
*
|
|
568
|
+
* <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
|
|
569
|
+
* @example
|
|
570
|
+
* ```ts
|
|
571
|
+
* graph.updateData({
|
|
572
|
+
* nodes: [{ id: 'node-1', style: { x: 100, y: 100 } }],
|
|
573
|
+
* edges: [{ id: 'edge-1', style: { lineWidth: 2 } }]
|
|
574
|
+
* });
|
|
575
|
+
* ```
|
|
452
576
|
* @apiCategory data
|
|
453
577
|
*/
|
|
454
578
|
updateData(data) {
|
|
@@ -459,6 +583,14 @@ export class Graph extends EventEmitter {
|
|
|
459
583
|
*
|
|
460
584
|
* <en/> Update node data
|
|
461
585
|
* @param data - <zh/> 节点数据 | <en/> node data
|
|
586
|
+
* @remarks
|
|
587
|
+
* <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
|
|
588
|
+
*
|
|
589
|
+
* <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
|
|
590
|
+
* @example
|
|
591
|
+
* ```ts
|
|
592
|
+
* graph.updateNodeData([{ id: 'node-1', style: { x: 100, y: 100 } }]);
|
|
593
|
+
* ```
|
|
462
594
|
* @apiCategory data
|
|
463
595
|
*/
|
|
464
596
|
updateNodeData(data) {
|
|
@@ -469,6 +601,14 @@ export class Graph extends EventEmitter {
|
|
|
469
601
|
*
|
|
470
602
|
* <en/> Update edge data
|
|
471
603
|
* @param data - <zh/> 边数据 | <en/> edge data
|
|
604
|
+
* @remarks
|
|
605
|
+
* <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
|
|
606
|
+
*
|
|
607
|
+
* <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
|
|
608
|
+
* @example
|
|
609
|
+
* ```ts
|
|
610
|
+
* graph.updateEdgeData([{ id: 'edge-1', style: { lineWidth: 2 } }]);
|
|
611
|
+
* ```
|
|
472
612
|
* @apiCategory data
|
|
473
613
|
*/
|
|
474
614
|
updateEdgeData(data) {
|
|
@@ -479,46 +619,77 @@ export class Graph extends EventEmitter {
|
|
|
479
619
|
*
|
|
480
620
|
* <en/> Update combo data
|
|
481
621
|
* @param data - <zh/> 组合数据 | <en/> combo data
|
|
622
|
+
* @remarks
|
|
623
|
+
* <zh/> 只需要传入需要更新的数据即可,不必传入完整的数据
|
|
624
|
+
*
|
|
625
|
+
* <en/> Just pass in the data that needs to be updated, no need to pass in the complete data
|
|
626
|
+
* @example
|
|
627
|
+
* ```ts
|
|
628
|
+
* graph.updateComboData([{ id: 'combo-1', style: { x: 100, y: 100 } }]);
|
|
629
|
+
* ```
|
|
482
630
|
* @apiCategory data
|
|
483
631
|
*/
|
|
484
632
|
updateComboData(data) {
|
|
485
633
|
this.context.model.updateComboData(isFunction(data) ? data(this.getComboData()) : data);
|
|
486
634
|
}
|
|
487
635
|
/**
|
|
488
|
-
* <zh/>
|
|
636
|
+
* <zh/> 删除元素数据
|
|
489
637
|
*
|
|
490
|
-
* <en/> Remove
|
|
638
|
+
* <en/> Remove element data
|
|
491
639
|
* @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
|
|
640
|
+
* @example
|
|
641
|
+
* ```ts
|
|
642
|
+
* graph.removeData({
|
|
643
|
+
* nodes: ['node-1', 'node-2'],
|
|
644
|
+
* edges: ['edge-1'],
|
|
645
|
+
* });
|
|
646
|
+
* ```
|
|
492
647
|
* @apiCategory data
|
|
493
648
|
*/
|
|
494
649
|
removeData(ids) {
|
|
495
650
|
this.context.model.removeData(isFunction(ids) ? ids(this.getData()) : ids);
|
|
496
651
|
}
|
|
497
652
|
/**
|
|
498
|
-
* <zh/>
|
|
653
|
+
* <zh/> 删除节点数据
|
|
499
654
|
*
|
|
500
|
-
* <en/> Remove
|
|
655
|
+
* <en/> Remove node data
|
|
501
656
|
* @param ids - <zh/> 节点 ID 数组 | <en/> node ID array
|
|
657
|
+
* @example
|
|
658
|
+
* ```ts
|
|
659
|
+
* graph.removeNodeData(['node-1', 'node-2']);
|
|
660
|
+
* ```
|
|
502
661
|
* @apiCategory data
|
|
503
662
|
*/
|
|
504
663
|
removeNodeData(ids) {
|
|
505
664
|
this.context.model.removeNodeData(isFunction(ids) ? ids(this.getNodeData()) : ids);
|
|
506
665
|
}
|
|
507
666
|
/**
|
|
508
|
-
* <zh/>
|
|
667
|
+
* <zh/> 删除边数据
|
|
509
668
|
*
|
|
510
|
-
* <en/> Remove
|
|
669
|
+
* <en/> Remove edge data
|
|
511
670
|
* @param ids - <zh/> 边 ID 数组 | <en/> edge ID array
|
|
671
|
+
* @remarks
|
|
672
|
+
* <zh/> 如果传入边数据时仅提供了 source 和 target,那么需要通过 `idOf` 方法获取边的实际 ID
|
|
673
|
+
*
|
|
674
|
+
* <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
|
|
675
|
+
* @example
|
|
676
|
+
* ```ts
|
|
677
|
+
* graph.removeEdgeData(['edge-1']);
|
|
678
|
+
* ```
|
|
512
679
|
* @apiCategory data
|
|
513
680
|
*/
|
|
514
681
|
removeEdgeData(ids) {
|
|
515
682
|
this.context.model.removeEdgeData(isFunction(ids) ? ids(this.getEdgeData()) : ids);
|
|
516
683
|
}
|
|
517
684
|
/**
|
|
518
|
-
* <zh/>
|
|
685
|
+
* <zh/> 删除组合数据
|
|
519
686
|
*
|
|
520
|
-
* <en/> Remove
|
|
687
|
+
* <en/> Remove combo data
|
|
521
688
|
* @param ids - <zh/> 组合 ID 数组 | <en/> 组合 ID array
|
|
689
|
+
* @example
|
|
690
|
+
* ```ts
|
|
691
|
+
* graph.removeComboData(['combo-1']);
|
|
692
|
+
* ```
|
|
522
693
|
* @apiCategory data
|
|
523
694
|
*/
|
|
524
695
|
removeComboData(ids) {
|
|
@@ -660,7 +831,11 @@ export class Graph extends EventEmitter {
|
|
|
660
831
|
* @remarks
|
|
661
832
|
* <zh/> 此过程会执行数据更新、绘制元素、执行布局
|
|
662
833
|
*
|
|
834
|
+
* > ⚠️ render 为异步方法,如果需要在 render 后执行一些操作,可以使用 `await graph.render()` 或者监听 GraphEvent.AFTER_RENDER 事件
|
|
835
|
+
*
|
|
663
836
|
* <en/> This process will execute data update, element rendering, and layout execution
|
|
837
|
+
*
|
|
838
|
+
* > ⚠️ 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
|
|
664
839
|
* @apiCategory render
|
|
665
840
|
*/
|
|
666
841
|
async render() {
|
|
@@ -676,7 +851,15 @@ export class Graph extends EventEmitter {
|
|
|
676
851
|
*
|
|
677
852
|
* <en/> Draw elements
|
|
678
853
|
* @returns <zh/> 渲染结果 | <en/> draw result
|
|
679
|
-
* @
|
|
854
|
+
* @remarks
|
|
855
|
+
* <zh/> 仅执行元素绘制,不会重新布局
|
|
856
|
+
*
|
|
857
|
+
* <zh/> ⚠️ draw 为异步方法,如果需要在 draw 后执行一些操作,可以使用 `await graph.draw()` 或者监听 GraphEvent.AFTER_DRAW 事件
|
|
858
|
+
*
|
|
859
|
+
* <en/> Only execute element drawing, no re-layout
|
|
860
|
+
*
|
|
861
|
+
* <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
|
|
862
|
+
* @apiCategory render
|
|
680
863
|
*/
|
|
681
864
|
async draw() {
|
|
682
865
|
await this.prepare();
|
|
@@ -719,6 +902,10 @@ export class Graph extends EventEmitter {
|
|
|
719
902
|
* <zh/> 销毁当前图实例
|
|
720
903
|
*
|
|
721
904
|
* <en/> Destroy the current graph instance
|
|
905
|
+
* @remarks
|
|
906
|
+
* <zh/> 销毁后无法进行任何操作,如果需要重新使用,需要重新创建一个新的图实例
|
|
907
|
+
*
|
|
908
|
+
* <en/> After destruction, no operations can be performed. If you need to reuse it, you need to create a new graph instance
|
|
722
909
|
* @apiCategory instance
|
|
723
910
|
*/
|
|
724
911
|
destroy() {
|
|
@@ -762,7 +949,7 @@ export class Graph extends EventEmitter {
|
|
|
762
949
|
*
|
|
763
950
|
* <en/> Zoom the graph to fit the viewport and move it to the center of the viewport
|
|
764
951
|
* @param options - <zh/> 适配配置 | <en/> fit options
|
|
765
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
952
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
766
953
|
* @apiCategory viewport
|
|
767
954
|
*/
|
|
768
955
|
async fitView(options, animation) {
|
|
@@ -772,7 +959,7 @@ export class Graph extends EventEmitter {
|
|
|
772
959
|
* <zh/> 将图平移至视口中心
|
|
773
960
|
*
|
|
774
961
|
* <en/> Move the graph to the center of the viewport
|
|
775
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
962
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
776
963
|
* @apiCategory viewport
|
|
777
964
|
*/
|
|
778
965
|
async fitCenter(animation) {
|
|
@@ -797,22 +984,26 @@ export class Graph extends EventEmitter {
|
|
|
797
984
|
}
|
|
798
985
|
}
|
|
799
986
|
/**
|
|
987
|
+
* <zh/> 聚焦元素
|
|
988
|
+
*
|
|
989
|
+
* <en/> Focus on element
|
|
990
|
+
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
991
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
992
|
+
* @remarks
|
|
800
993
|
* <zh/> 移动图,使得元素对齐到视口中心
|
|
801
994
|
*
|
|
802
995
|
* <en/> Move the graph so that the element is aligned to the center of the viewport
|
|
803
|
-
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
804
|
-
* @param animation - <zh/> 动画配置 | <en/> animation configuration
|
|
805
996
|
* @apiCategory viewport
|
|
806
997
|
*/
|
|
807
998
|
async focusElement(id, animation) {
|
|
808
999
|
await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], animation);
|
|
809
1000
|
}
|
|
810
1001
|
/**
|
|
811
|
-
* <zh/>
|
|
1002
|
+
* <zh/> 基于当前缩放比例进行缩放(相对缩放)
|
|
812
1003
|
*
|
|
813
|
-
* <en/> Zoom based on the current zoom ratio
|
|
1004
|
+
* <en/> Zoom based on the current zoom ratio (relative zoom)
|
|
814
1005
|
* @param ratio - <zh/> 缩放比例 | <en/> zoom ratio
|
|
815
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1006
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
816
1007
|
* @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
|
|
817
1008
|
* @remarks
|
|
818
1009
|
* <zh/>
|
|
@@ -828,11 +1019,11 @@ export class Graph extends EventEmitter {
|
|
|
828
1019
|
await this.context.viewport.transform({ mode: 'relative', scale: ratio, origin }, animation);
|
|
829
1020
|
}
|
|
830
1021
|
/**
|
|
831
|
-
* <zh/>
|
|
1022
|
+
* <zh/> 缩放画布至指定比例(绝对缩放)
|
|
832
1023
|
*
|
|
833
|
-
* <en/> Zoom the canvas to the specified ratio
|
|
1024
|
+
* <en/> Zoom the canvas to the specified ratio (absolute zoom)
|
|
834
1025
|
* @param zoom - <zh/> 指定缩放比例 | <en/> specified zoom ratio
|
|
835
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1026
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
836
1027
|
* @param origin - <zh/> 缩放中心(视口坐标) | <en/> zoom center(viewport coordinates)
|
|
837
1028
|
* @remarks
|
|
838
1029
|
* <zh/>
|
|
@@ -860,11 +1051,11 @@ export class Graph extends EventEmitter {
|
|
|
860
1051
|
return this.context.viewport.getZoom();
|
|
861
1052
|
}
|
|
862
1053
|
/**
|
|
863
|
-
* <zh/>
|
|
1054
|
+
* <zh/> 基于当前旋转角度进行旋转(相对旋转)
|
|
864
1055
|
*
|
|
865
|
-
* <en/> Rotate based on the current rotation angle
|
|
1056
|
+
* <en/> Rotate based on the current rotation angle (relative rotation)
|
|
866
1057
|
* @param angle - <zh/> 旋转角度 | <en/> rotation angle
|
|
867
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1058
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
868
1059
|
* @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
|
|
869
1060
|
* @apiCategory viewport
|
|
870
1061
|
*/
|
|
@@ -872,11 +1063,11 @@ export class Graph extends EventEmitter {
|
|
|
872
1063
|
await this.context.viewport.transform({ mode: 'relative', rotate: angle, origin }, animation);
|
|
873
1064
|
}
|
|
874
1065
|
/**
|
|
875
|
-
* <zh/> 旋转画布至指定角度
|
|
1066
|
+
* <zh/> 旋转画布至指定角度 (绝对旋转)
|
|
876
1067
|
*
|
|
877
|
-
* <en/> Rotate the canvas to the specified angle
|
|
1068
|
+
* <en/> Rotate the canvas to the specified angle (absolute rotation)
|
|
878
1069
|
* @param angle - <zh/> 目标角度 | <en/> target angle
|
|
879
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1070
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
880
1071
|
* @param origin - <zh/> 旋转中心(视口坐标) | <en/> rotation center(viewport coordinates)
|
|
881
1072
|
* @apiCategory viewport
|
|
882
1073
|
*/
|
|
@@ -894,22 +1085,22 @@ export class Graph extends EventEmitter {
|
|
|
894
1085
|
return this.context.viewport.getRotation();
|
|
895
1086
|
}
|
|
896
1087
|
/**
|
|
897
|
-
* <zh/> 将图平移指定距离
|
|
1088
|
+
* <zh/> 将图平移指定距离 (相对平移)
|
|
898
1089
|
*
|
|
899
|
-
* <en/> Translate the graph by the specified distance
|
|
1090
|
+
* <en/> Translate the graph by the specified distance (relative translation)
|
|
900
1091
|
* @param offset - <zh/> 偏移量 | <en/> offset
|
|
901
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1092
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
902
1093
|
* @apiCategory viewport
|
|
903
1094
|
*/
|
|
904
1095
|
async translateBy(offset, animation) {
|
|
905
1096
|
await this.context.viewport.transform({ mode: 'relative', translate: offset }, animation);
|
|
906
1097
|
}
|
|
907
1098
|
/**
|
|
908
|
-
* <zh/> 将图平移至指定位置
|
|
1099
|
+
* <zh/> 将图平移至指定位置 (绝对平移)
|
|
909
1100
|
*
|
|
910
|
-
* <en/> Translate the graph to the specified position
|
|
1101
|
+
* <en/> Translate the graph to the specified position (absolute translation)
|
|
911
1102
|
* @param position - <zh/> 指定位置 | <en/> specified position
|
|
912
|
-
* @param animation - <zh/> 动画配置 | <en/> animation
|
|
1103
|
+
* @param animation - <zh/> 动画配置 | <en/> animation options
|
|
913
1104
|
* @apiCategory viewport
|
|
914
1105
|
*/
|
|
915
1106
|
async translateTo(position, animation) {
|
|
@@ -1036,17 +1227,17 @@ export class Graph extends EventEmitter {
|
|
|
1036
1227
|
*/
|
|
1037
1228
|
async frontElement(id) {
|
|
1038
1229
|
const ids = Array.isArray(id) ? id : [id];
|
|
1039
|
-
const { model } = this.context;
|
|
1230
|
+
const { model, element } = this.context;
|
|
1040
1231
|
const config = {};
|
|
1041
1232
|
ids.map((_id) => {
|
|
1042
|
-
const zIndex =
|
|
1233
|
+
const zIndex = element.getFrontZIndex(_id);
|
|
1043
1234
|
const elementType = model.getElementType(_id);
|
|
1044
1235
|
if (elementType === 'combo') {
|
|
1045
1236
|
const ancestor = model.getAncestorsData(_id, COMBO_KEY).at(-1) || this.getComboData(_id);
|
|
1046
|
-
const combos = [ancestor, ...model.getDescendantsData(idOf(ancestor))]
|
|
1047
|
-
const delta = zIndex -
|
|
1237
|
+
const combos = [ancestor, ...model.getDescendantsData(idOf(ancestor))];
|
|
1238
|
+
const delta = zIndex - element.getElementZIndex(_id);
|
|
1048
1239
|
combos.forEach((combo) => {
|
|
1049
|
-
config[idOf(combo)] =
|
|
1240
|
+
config[idOf(combo)] = this.getElementZIndex(idOf(combo)) + delta;
|
|
1050
1241
|
});
|
|
1051
1242
|
}
|
|
1052
1243
|
else
|
|
@@ -1063,7 +1254,8 @@ export class Graph extends EventEmitter {
|
|
|
1063
1254
|
* @apiCategory element
|
|
1064
1255
|
*/
|
|
1065
1256
|
getElementZIndex(id) {
|
|
1066
|
-
|
|
1257
|
+
const { model, element } = this.context;
|
|
1258
|
+
return model.getElementDataById(id)?.style?.zIndex ?? element.getElementZIndex(id);
|
|
1067
1259
|
}
|
|
1068
1260
|
async setElementState(args1, args2, args3 = true) {
|
|
1069
1261
|
const [config, animation] = isObject(args1)
|
|
@@ -1106,7 +1298,7 @@ export class Graph extends EventEmitter {
|
|
|
1106
1298
|
}
|
|
1107
1299
|
isCollapsingExpanding = false;
|
|
1108
1300
|
/**
|
|
1109
|
-
* <zh/>
|
|
1301
|
+
* <zh/> 收起组合
|
|
1110
1302
|
*
|
|
1111
1303
|
* <en/> Collapse Combo
|
|
1112
1304
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
@@ -1129,7 +1321,7 @@ export class Graph extends EventEmitter {
|
|
|
1129
1321
|
this.isCollapsingExpanding = false;
|
|
1130
1322
|
}
|
|
1131
1323
|
/**
|
|
1132
|
-
* <zh/>
|
|
1324
|
+
* <zh/> 展开组合
|
|
1133
1325
|
*
|
|
1134
1326
|
* <en/> Expand Combo
|
|
1135
1327
|
* @param id - <zh/> 元素 ID | <en/> element ID
|
|
@@ -1162,7 +1354,7 @@ export class Graph extends EventEmitter {
|
|
|
1162
1354
|
* <zh/> 导出画布内容为 DataURL
|
|
1163
1355
|
*
|
|
1164
1356
|
* <en/> Export canvas content as DataURL
|
|
1165
|
-
* @param options - <zh/> 导出配置 | <en/> export
|
|
1357
|
+
* @param options - <zh/> 导出配置 | <en/> export options
|
|
1166
1358
|
* @returns <zh/> DataURL | <en/> DataURL
|
|
1167
1359
|
* @apiCategory exportImage
|
|
1168
1360
|
*/
|
|
@@ -1262,5 +1454,8 @@ export class Graph extends EventEmitter {
|
|
|
1262
1454
|
once(eventName, callback) {
|
|
1263
1455
|
return super.once(eventName, callback);
|
|
1264
1456
|
}
|
|
1457
|
+
off(eventName, callback) {
|
|
1458
|
+
return super.off(eventName, callback);
|
|
1459
|
+
}
|
|
1265
1460
|
}
|
|
1266
1461
|
//# sourceMappingURL=graph.js.map
|