@antv/g6 5.0.3 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en-US.md +118 -0
- package/README.md +118 -0
- package/dist/g6.min.js +2 -2
- package/dist/lib/behaviors/base-behavior.d.ts +1 -1
- package/dist/lib/behaviors/click-select.d.ts +17 -0
- package/dist/lib/behaviors/scroll-canvas.d.ts +1 -1
- package/dist/lib/behaviors/types.d.ts +0 -4
- package/dist/lib/behaviors/zoom-canvas.d.ts +1 -1
- package/dist/lib/constants/events/graph.d.ts +12 -0
- package/dist/lib/elements/shapes/badge.d.ts +1 -1
- package/dist/lib/exports.d.ts +2 -0
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/layouts/index.d.ts +0 -1
- package/dist/lib/plugins/types.d.ts +0 -2
- package/dist/lib/registry/extension/index.d.ts +17 -6
- package/dist/lib/registry/extension/types.d.ts +15 -33
- package/dist/lib/runtime/data.d.ts +1 -1
- package/dist/lib/runtime/element.d.ts +1 -1
- package/dist/lib/runtime/viewport.d.ts +3 -5
- package/dist/lib/spec/behavior.d.ts +4 -5
- package/dist/lib/spec/element/combo.d.ts +8 -4
- package/dist/lib/spec/element/edge.d.ts +8 -4
- package/dist/lib/spec/element/node.d.ts +8 -4
- package/dist/lib/spec/plugin.d.ts +4 -5
- package/dist/lib/spec/transform.d.ts +5 -6
- package/dist/lib/transforms/types.d.ts +1 -2
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/types/style.d.ts +2 -0
- package/dist/lib/utils/event/events.d.ts +4 -4
- package/dist/lib/utils/extension.d.ts +5 -2
- package/dist/lib/utils/style.d.ts +5 -2
- package/dist/lib/utils/transform.d.ts +1 -1
- package/dist/lib/version.d.ts +1 -0
- package/esm/behaviors/base-behavior.d.ts +1 -1
- package/esm/behaviors/base-behavior.js.map +1 -1
- package/esm/behaviors/click-select.d.ts +17 -0
- package/esm/behaviors/click-select.js +35 -4
- package/esm/behaviors/click-select.js.map +1 -1
- package/esm/behaviors/scroll-canvas.d.ts +1 -1
- package/esm/behaviors/scroll-canvas.js.map +1 -1
- package/esm/behaviors/types.d.ts +0 -4
- package/esm/behaviors/zoom-canvas.d.ts +1 -1
- package/esm/constants/events/graph.d.ts +12 -0
- package/esm/constants/events/graph.js +12 -0
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/elements/shapes/badge.d.ts +1 -1
- package/esm/exports.d.ts +2 -0
- package/esm/exports.js +1 -0
- package/esm/exports.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/layouts/index.d.ts +0 -1
- package/esm/plugins/camera-setting.js.map +1 -1
- package/esm/plugins/types.d.ts +0 -2
- package/esm/registry/extension/index.d.ts +17 -6
- package/esm/registry/extension/index.js +1 -1
- package/esm/registry/extension/index.js.map +1 -1
- package/esm/registry/extension/types.d.ts +15 -33
- package/esm/runtime/behavior.js +5 -0
- package/esm/runtime/behavior.js.map +1 -1
- package/esm/runtime/data.d.ts +1 -1
- package/esm/runtime/data.js +2 -0
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +1 -1
- package/esm/runtime/element.js +7 -4
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.js +3 -3
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +4 -1
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/viewport.d.ts +3 -5
- package/esm/runtime/viewport.js +18 -49
- package/esm/runtime/viewport.js.map +1 -1
- package/esm/spec/behavior.d.ts +4 -5
- package/esm/spec/element/combo.d.ts +8 -4
- package/esm/spec/element/edge.d.ts +8 -4
- package/esm/spec/element/node.d.ts +8 -4
- package/esm/spec/plugin.d.ts +4 -5
- package/esm/spec/transform.d.ts +5 -6
- package/esm/transforms/types.d.ts +1 -2
- package/esm/types/index.d.ts +0 -1
- package/esm/types/style.d.ts +2 -0
- package/esm/utils/animation.js +6 -1
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/event/events.d.ts +4 -4
- package/esm/utils/event/events.js.map +1 -1
- package/esm/utils/extension.d.ts +5 -2
- package/esm/utils/extension.js +5 -1
- package/esm/utils/extension.js.map +1 -1
- package/esm/utils/style.d.ts +5 -2
- package/esm/utils/style.js +5 -6
- package/esm/utils/style.js.map +1 -1
- package/esm/utils/transform.d.ts +1 -1
- package/esm/version.d.ts +1 -0
- package/esm/version.js +2 -0
- package/esm/version.js.map +1 -0
- package/lib/behaviors/base-behavior.d.ts +1 -1
- package/lib/behaviors/base-behavior.js.map +1 -1
- package/lib/behaviors/click-select.d.ts +17 -0
- package/lib/behaviors/click-select.js +33 -2
- package/lib/behaviors/click-select.js.map +1 -1
- package/lib/behaviors/scroll-canvas.d.ts +1 -1
- package/lib/behaviors/scroll-canvas.js.map +1 -1
- package/lib/behaviors/types.d.ts +0 -4
- package/lib/behaviors/zoom-canvas.d.ts +1 -1
- package/lib/constants/events/graph.d.ts +12 -0
- package/lib/constants/events/graph.js +12 -0
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/elements/effect.js +1 -2
- package/lib/elements/effect.js.map +1 -1
- package/lib/elements/shapes/badge.d.ts +1 -1
- package/lib/exports.d.ts +2 -0
- package/lib/exports.js +3 -1
- package/lib/exports.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/layouts/index.d.ts +0 -1
- package/lib/plugins/camera-setting.js.map +1 -1
- package/lib/plugins/contextmenu/util.js +2 -2
- package/lib/plugins/contextmenu/util.js.map +1 -1
- package/lib/plugins/history/util.js +2 -3
- package/lib/plugins/history/util.js.map +1 -1
- package/lib/plugins/hull/util.js +1 -2
- package/lib/plugins/hull/util.js.map +1 -1
- package/lib/plugins/toolbar/util.js +2 -2
- package/lib/plugins/toolbar/util.js.map +1 -1
- package/lib/plugins/types.d.ts +0 -2
- package/lib/plugins/watermark/util.js +2 -3
- package/lib/plugins/watermark/util.js.map +1 -1
- package/lib/registry/extension/index.d.ts +17 -6
- package/lib/registry/extension/index.js +1 -1
- package/lib/registry/extension/index.js.map +1 -1
- package/lib/registry/extension/types.d.ts +15 -33
- package/lib/registry/index.js +4 -5
- package/lib/registry/index.js.map +1 -1
- package/lib/runtime/behavior.js +5 -0
- package/lib/runtime/behavior.js.map +1 -1
- package/lib/runtime/data.d.ts +1 -1
- package/lib/runtime/data.js +2 -0
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +1 -1
- package/lib/runtime/element.js +7 -4
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.js +3 -3
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +4 -1
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/viewport.d.ts +3 -5
- package/lib/runtime/viewport.js +18 -49
- package/lib/runtime/viewport.js.map +1 -1
- package/lib/spec/behavior.d.ts +4 -5
- package/lib/spec/element/combo.d.ts +8 -4
- package/lib/spec/element/edge.d.ts +8 -4
- package/lib/spec/element/node.d.ts +8 -4
- package/lib/spec/plugin.d.ts +4 -5
- package/lib/spec/transform.d.ts +5 -6
- package/lib/themes/base.js +1 -2
- package/lib/themes/base.js.map +1 -1
- package/lib/transforms/types.d.ts +1 -2
- package/lib/transforms/utils.js +1 -2
- package/lib/transforms/utils.js.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/style.d.ts +2 -0
- package/lib/utils/anchor.js +1 -2
- package/lib/utils/anchor.js.map +1 -1
- package/lib/utils/animation.js +11 -7
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/array.js +1 -2
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/bbox.js +13 -14
- package/lib/utils/bbox.js.map +1 -1
- package/lib/utils/cache.js +4 -5
- package/lib/utils/cache.js.map +1 -1
- package/lib/utils/change.js +2 -3
- package/lib/utils/change.js.map +1 -1
- package/lib/utils/collapsibility.js +1 -2
- package/lib/utils/collapsibility.js.map +1 -1
- package/lib/utils/data.js +3 -4
- package/lib/utils/data.js.map +1 -1
- package/lib/utils/diff.js +1 -2
- package/lib/utils/diff.js.map +1 -1
- package/lib/utils/dom.js +4 -5
- package/lib/utils/dom.js.map +1 -1
- package/lib/utils/edge.js +18 -18
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/element.js +26 -27
- package/lib/utils/element.js.map +1 -1
- package/lib/utils/event/events.d.ts +4 -4
- package/lib/utils/event/events.js.map +1 -1
- package/lib/utils/event/index.js +2 -3
- package/lib/utils/event/index.js.map +1 -1
- package/lib/utils/extension.d.ts +5 -2
- package/lib/utils/extension.js +6 -3
- package/lib/utils/extension.js.map +1 -1
- package/lib/utils/graphlib.js +3 -4
- package/lib/utils/graphlib.js.map +1 -1
- package/lib/utils/id.js +3 -4
- package/lib/utils/id.js.map +1 -1
- package/lib/utils/is.js +4 -5
- package/lib/utils/is.js.map +1 -1
- package/lib/utils/layout.js +7 -8
- package/lib/utils/layout.js.map +1 -1
- package/lib/utils/line.js +2 -3
- package/lib/utils/line.js.map +1 -1
- package/lib/utils/math.js +1 -2
- package/lib/utils/math.js.map +1 -1
- package/lib/utils/node.js +1 -2
- package/lib/utils/node.js.map +1 -1
- package/lib/utils/padding.js +1 -2
- package/lib/utils/padding.js.map +1 -1
- package/lib/utils/palette.js +3 -4
- package/lib/utils/palette.js.map +1 -1
- package/lib/utils/path.js +4 -4
- package/lib/utils/path.js.map +1 -1
- package/lib/utils/placement.js +1 -2
- package/lib/utils/placement.js.map +1 -1
- package/lib/utils/point.js +21 -22
- package/lib/utils/point.js.map +1 -1
- package/lib/utils/polygon.js +1 -2
- package/lib/utils/polygon.js.map +1 -1
- package/lib/utils/position.js +5 -5
- package/lib/utils/position.js.map +1 -1
- package/lib/utils/prefix.js +7 -8
- package/lib/utils/prefix.js.map +1 -1
- package/lib/utils/relation.js +2 -3
- package/lib/utils/relation.js.map +1 -1
- package/lib/utils/router/orth.js +9 -10
- package/lib/utils/router/orth.js.map +1 -1
- package/lib/utils/shape.js +1 -2
- package/lib/utils/shape.js.map +1 -1
- package/lib/utils/size.js +1 -2
- package/lib/utils/size.js.map +1 -1
- package/lib/utils/style.d.ts +5 -2
- package/lib/utils/style.js +8 -10
- package/lib/utils/style.js.map +1 -1
- package/lib/utils/text.js +3 -4
- package/lib/utils/text.js.map +1 -1
- package/lib/utils/theme.js +1 -2
- package/lib/utils/theme.js.map +1 -1
- package/lib/utils/transform.d.ts +1 -1
- package/lib/utils/transform.js +2 -2
- package/lib/utils/transform.js.map +1 -1
- package/lib/utils/traverse.js +2 -3
- package/lib/utils/traverse.js.map +1 -1
- package/lib/utils/tree.js +1 -2
- package/lib/utils/tree.js.map +1 -1
- package/lib/utils/vector.js +16 -17
- package/lib/utils/vector.js.map +1 -1
- package/lib/utils/visibility.js +1 -2
- package/lib/utils/visibility.js.map +1 -1
- package/lib/version.d.ts +1 -0
- package/lib/version.js +5 -0
- package/lib/version.js.map +1 -0
- package/package.json +6 -3
- package/src/behaviors/base-behavior.ts +1 -1
- package/src/behaviors/click-select.ts +35 -4
- package/src/behaviors/scroll-canvas.ts +1 -1
- package/src/behaviors/types.ts +0 -4
- package/src/constants/events/graph.ts +12 -0
- package/src/exports.ts +2 -0
- package/src/index.ts +1 -1
- package/src/plugins/camera-setting.ts +2 -2
- package/src/plugins/types.ts +0 -2
- package/src/registry/extension/index.ts +15 -8
- package/src/registry/extension/types.ts +15 -40
- package/src/runtime/behavior.ts +5 -0
- package/src/runtime/data.ts +1 -0
- package/src/runtime/element.ts +7 -4
- package/src/runtime/graph.ts +3 -3
- package/src/runtime/layout.ts +5 -2
- package/src/runtime/viewport.ts +17 -48
- package/src/spec/behavior.ts +4 -5
- package/src/spec/element/combo.ts +16 -4
- package/src/spec/element/edge.ts +16 -4
- package/src/spec/element/node.ts +16 -4
- package/src/spec/plugin.ts +4 -5
- package/src/spec/transform.ts +5 -6
- package/src/transforms/types.ts +1 -2
- package/src/types/index.ts +0 -1
- package/src/types/style.ts +2 -0
- package/src/utils/animation.ts +7 -1
- package/src/utils/event/events.ts +2 -0
- package/src/utils/extension.ts +10 -3
- package/src/utils/style.ts +11 -6
- package/src/version.ts +1 -0
- package/dist/lib/types/callable.d.ts +0 -19
- package/esm/types/callable.d.ts +0 -19
- package/esm/types/callable.js +0 -2
- package/esm/types/callable.js.map +0 -1
- package/lib/types/callable.d.ts +0 -19
- package/lib/types/callable.js +0 -3
- package/lib/types/callable.js.map +0 -1
- package/src/types/callable.ts +0 -21
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { isFunction } from '@antv/util';
|
|
2
|
-
import { CanvasEvent, CommonEvent } from '../constants';
|
|
2
|
+
import { CanvasEvent, CommonEvent, GraphEvent } from '../constants';
|
|
3
3
|
import { ELEMENT_TYPES } from '../constants/element';
|
|
4
4
|
import type { RuntimeContext } from '../runtime/types';
|
|
5
5
|
import type { ElementType, ID, IPointerEvent, State } from '../types';
|
|
6
|
-
import {
|
|
6
|
+
import type { ElementLifeCycleEvent } from '../utils/event';
|
|
7
|
+
import { idOf, idsOf } from '../utils/id';
|
|
7
8
|
import { getElementNthDegreeIds } from '../utils/relation';
|
|
8
9
|
import type { ShortcutKey } from '../utils/shortcut';
|
|
9
10
|
import { Shortcut } from '../utils/shortcut';
|
|
@@ -137,6 +138,7 @@ export class ClickSelect extends BaseBehavior<ClickSelectOptions> {
|
|
|
137
138
|
graph.on(`${type}:${CommonEvent.CLICK}`, this.onClickSelect);
|
|
138
139
|
});
|
|
139
140
|
graph.on(CanvasEvent.CLICK, this.onClickCanvas);
|
|
141
|
+
graph.on(GraphEvent.AFTER_ELEMENT_UPDATE, this.syncState);
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
private onClickSelect = (event: IPointerEvent) => {
|
|
@@ -158,7 +160,14 @@ export class ClickSelect extends BaseBehavior<ClickSelectOptions> {
|
|
|
158
160
|
return multiple && this.shortcut.match(trigger);
|
|
159
161
|
}
|
|
160
162
|
|
|
161
|
-
|
|
163
|
+
/**
|
|
164
|
+
* <zh/> syncState 会忽略因交互操作导致的状态更新
|
|
165
|
+
*
|
|
166
|
+
* <en/> syncState will ignore state updates caused by interactive operations
|
|
167
|
+
*/
|
|
168
|
+
private updating = false;
|
|
169
|
+
|
|
170
|
+
private async updateState(event: IPointerEvent) {
|
|
162
171
|
const { state: select, unselectedState: unselect, neighborState: neighbor, animation, degree } = this.options;
|
|
163
172
|
if (!select && !unselect) return;
|
|
164
173
|
|
|
@@ -218,9 +227,30 @@ export class ClickSelect extends BaseBehavior<ClickSelectOptions> {
|
|
|
218
227
|
}
|
|
219
228
|
});
|
|
220
229
|
|
|
221
|
-
|
|
230
|
+
this.updating = true;
|
|
231
|
+
await graph.setElementState(states, animation);
|
|
232
|
+
this.updating = false;
|
|
222
233
|
}
|
|
223
234
|
|
|
235
|
+
/**
|
|
236
|
+
* <zh/> 同步状态
|
|
237
|
+
*
|
|
238
|
+
* <en/> Sync state
|
|
239
|
+
* @remarks
|
|
240
|
+
* <zh/> 避免其他操作更新状态后,this.select 与实际状态不一致
|
|
241
|
+
*
|
|
242
|
+
* <en/> Avoid inconsistency between this.select and the actual state after other operations update the state
|
|
243
|
+
* @param event - <zh/> 元素生命周期事件 | <en/> Element life cycle event
|
|
244
|
+
*/
|
|
245
|
+
private syncState = (event: ElementLifeCycleEvent) => {
|
|
246
|
+
if (this.updating) return;
|
|
247
|
+
const { data } = event;
|
|
248
|
+
const id = idOf(data);
|
|
249
|
+
const states = data.states || [];
|
|
250
|
+
if (states.includes(this.options.state)) this.select.add(id);
|
|
251
|
+
else this.select.delete(id);
|
|
252
|
+
};
|
|
253
|
+
|
|
224
254
|
private validate(event: IPointerEvent) {
|
|
225
255
|
if (this.destroyed) return false;
|
|
226
256
|
const { enable } = this.options;
|
|
@@ -235,6 +265,7 @@ export class ClickSelect extends BaseBehavior<ClickSelectOptions> {
|
|
|
235
265
|
graph.off(`${type}:${CommonEvent.CLICK}`, this.onClickSelect);
|
|
236
266
|
});
|
|
237
267
|
graph.off(CanvasEvent.CLICK, this.onClickCanvas);
|
|
268
|
+
graph.off(GraphEvent.AFTER_ELEMENT_UPDATE, this.syncState);
|
|
238
269
|
}
|
|
239
270
|
|
|
240
271
|
public destroy() {
|
|
@@ -63,7 +63,7 @@ export interface ScrollCanvasOptions extends BaseBehaviorOptions {
|
|
|
63
63
|
* <en/> Scroll canvas behavior
|
|
64
64
|
*/
|
|
65
65
|
export class ScrollCanvas extends BaseBehavior<ScrollCanvasOptions> {
|
|
66
|
-
static defaultOptions: ScrollCanvasOptions = {
|
|
66
|
+
static defaultOptions: Partial<ScrollCanvasOptions> = {
|
|
67
67
|
enable: true,
|
|
68
68
|
sensitivity: 1,
|
|
69
69
|
};
|
package/src/behaviors/types.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import type { BaseBehavior } from './base-behavior';
|
|
2
|
-
import type { DragCanvasOptions } from './drag-canvas';
|
|
3
|
-
import type { ScrollCanvasOptions } from './scroll-canvas';
|
|
4
|
-
import type { ZoomCanvasOptions } from './zoom-canvas';
|
|
5
2
|
|
|
6
|
-
export type BuiltInBehaviorOptions = DragCanvasOptions | ZoomCanvasOptions | ScrollCanvasOptions;
|
|
7
3
|
export type Behavior = BaseBehavior<any>;
|
|
@@ -119,6 +119,18 @@ export enum GraphEvent {
|
|
|
119
119
|
* <en/> After layout
|
|
120
120
|
*/
|
|
121
121
|
AFTER_LAYOUT = 'afterlayout',
|
|
122
|
+
/**
|
|
123
|
+
* <zh/> 布局过程之前,用于流水线布局过程获取当前执行的布局
|
|
124
|
+
*
|
|
125
|
+
* <en/> Before the layout process, used to get the current layout being executed in the pipeline layout process
|
|
126
|
+
*/
|
|
127
|
+
BEFORE_STAGE_LAYOUT = 'beforestagelayout',
|
|
128
|
+
/**
|
|
129
|
+
* <zh/> 布局过程之后,用于流水线布局过程获取当前执行的布局
|
|
130
|
+
*
|
|
131
|
+
* <en/> After the layout process, used to get the current layout being executed in the pipeline layout process
|
|
132
|
+
*/
|
|
133
|
+
AFTER_STAGE_LAYOUT = 'afterstagelayout',
|
|
122
134
|
/**
|
|
123
135
|
* <zh/> 可视区域变化之前
|
|
124
136
|
*
|
package/src/exports.ts
CHANGED
|
@@ -78,6 +78,7 @@ export {
|
|
|
78
78
|
export { getExtension, getExtensions, register } from './registry';
|
|
79
79
|
export { Graph } from './runtime/graph';
|
|
80
80
|
export { BaseTransform } from './transforms';
|
|
81
|
+
export { isCollapsed } from './utils/collapsibility';
|
|
81
82
|
export { idOf } from './utils/id';
|
|
82
83
|
export { invokeLayoutMethod } from './utils/layout';
|
|
83
84
|
export { omitStyleProps, subStyleProps } from './utils/prefix';
|
|
@@ -189,6 +190,7 @@ export type { AnimationStage } from './spec/element/animation';
|
|
|
189
190
|
export type { LayoutOptions, STDLayoutOptions, SingleLayoutOptions } from './spec/layout';
|
|
190
191
|
export type { CustomPluginOption } from './spec/plugin';
|
|
191
192
|
export type { BaseTransformOptions } from './transforms';
|
|
193
|
+
export type { DrawData } from './transforms/types';
|
|
192
194
|
export type {
|
|
193
195
|
BaseElementStyleProps,
|
|
194
196
|
CardinalPlacement,
|
package/src/index.ts
CHANGED
|
@@ -137,12 +137,12 @@ export class CameraSetting extends BasePlugin<CameraSettingOptions> {
|
|
|
137
137
|
azimuth: 'setAzimuth',
|
|
138
138
|
} as const;
|
|
139
139
|
|
|
140
|
-
const valueMapper =
|
|
140
|
+
const valueMapper = (key: string, value: string) => {
|
|
141
141
|
switch (key) {
|
|
142
142
|
case 'projectionMode':
|
|
143
143
|
return value === 'perspective' ? 1 : 0;
|
|
144
144
|
case 'cameraType':
|
|
145
|
-
return { orbiting: 0, exploring: 1, tracking: 2 }[value]
|
|
145
|
+
return { orbiting: 0, exploring: 1, tracking: 2 }[value]!;
|
|
146
146
|
case 'aspect':
|
|
147
147
|
if (typeof value === 'number') return value;
|
|
148
148
|
return this.getCanvasAspect();
|
package/src/plugins/types.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type EventEmitter from '@antv/event-emitter';
|
|
2
2
|
import { getExtension } from '..';
|
|
3
|
+
import type { Graph } from '../../runtime/graph';
|
|
3
4
|
import type { RuntimeContext } from '../../runtime/types';
|
|
4
5
|
import type { IEvent } from '../../types';
|
|
5
6
|
import { arrayDiff } from '../../utils/diff';
|
|
6
7
|
import { parseExtensions } from '../../utils/extension';
|
|
7
|
-
import type {
|
|
8
|
+
import type { STDExtensionOption } from './types';
|
|
8
9
|
|
|
9
|
-
export abstract class ExtensionController<
|
|
10
|
+
export abstract class ExtensionController<E extends BaseExtension<any>> {
|
|
10
11
|
protected context: RuntimeContext;
|
|
11
12
|
|
|
12
13
|
protected extensions: STDExtensionOption[] = [];
|
|
13
14
|
|
|
14
|
-
protected extensionMap: Record<string,
|
|
15
|
+
protected extensionMap: Record<string, E> = {};
|
|
15
16
|
|
|
16
17
|
public abstract category: 'plugin' | 'behavior' | 'transform';
|
|
17
18
|
|
|
@@ -19,8 +20,14 @@ export abstract class ExtensionController<Extension extends BaseExtension<Loosel
|
|
|
19
20
|
this.context = context;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
public setExtensions(
|
|
23
|
-
|
|
23
|
+
public setExtensions(
|
|
24
|
+
extensions: (
|
|
25
|
+
| string
|
|
26
|
+
| { type: string; [keys: string]: unknown }
|
|
27
|
+
| ((this: Graph) => { type: string; [keys: string]: unknown })
|
|
28
|
+
)[],
|
|
29
|
+
) {
|
|
30
|
+
const stdExtensions = parseExtensions(this.context.graph, this.category, extensions) as STDExtensionOption[];
|
|
24
31
|
const { enter, update, exit, keep } = arrayDiff(this.extensions, stdExtensions, (extension) => extension.key);
|
|
25
32
|
|
|
26
33
|
this.createExtensions(enter);
|
|
@@ -38,7 +45,7 @@ export abstract class ExtensionController<Extension extends BaseExtension<Loosel
|
|
|
38
45
|
if (!Ctor) return;
|
|
39
46
|
|
|
40
47
|
const instance = new Ctor(this.context, extension);
|
|
41
|
-
this.extensionMap[key] = instance as
|
|
48
|
+
this.extensionMap[key] = instance as E;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
protected createExtensions(extensions: STDExtensionOption[]) {
|
|
@@ -83,7 +90,7 @@ export abstract class ExtensionController<Extension extends BaseExtension<Loosel
|
|
|
83
90
|
*
|
|
84
91
|
* <en/> Base class for extension instance
|
|
85
92
|
*/
|
|
86
|
-
export class BaseExtension<T extends
|
|
93
|
+
export class BaseExtension<T extends { type: string; key?: string; [key: string]: unknown }> {
|
|
87
94
|
protected context: RuntimeContext;
|
|
88
95
|
|
|
89
96
|
protected options: Required<T>;
|
|
@@ -92,7 +99,7 @@ export class BaseExtension<T extends LooselyExtensionOption> {
|
|
|
92
99
|
|
|
93
100
|
public destroyed = false;
|
|
94
101
|
|
|
95
|
-
constructor(context: RuntimeContext, options: T) {
|
|
102
|
+
constructor(context: RuntimeContext, options: Partial<T>) {
|
|
96
103
|
this.context = context;
|
|
97
104
|
this.options = options as Required<T>;
|
|
98
105
|
}
|
|
@@ -1,45 +1,20 @@
|
|
|
1
|
-
interface ExtensionMetaOptions {
|
|
2
|
-
type: string;
|
|
3
|
-
key: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
interface CustomExtensionOptions {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* <zh/> 扩展配置项
|
|
12
|
-
*
|
|
13
|
-
* <en/> Extension options
|
|
14
|
-
*/
|
|
15
|
-
export type ExtensionOptions<Registry extends CustomExtensionOptions = CustomExtensionOptions> = ExtensionOption<
|
|
16
|
-
Registry | LooselyExtensionOption
|
|
17
|
-
>[];
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* <zh/> 扩展配置项
|
|
21
|
-
*
|
|
22
|
-
* <en/> Extension option
|
|
23
|
-
*/
|
|
24
|
-
type ExtensionOption<Registry extends CustomExtensionOptions> = AbbrExtensionOption<Registry>;
|
|
25
|
-
|
|
26
1
|
/**
|
|
27
2
|
* <zh/> 标准扩展配置项
|
|
28
3
|
*
|
|
29
4
|
* <en/> Standard extension options
|
|
30
5
|
*/
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
6
|
+
export interface STDExtensionOption {
|
|
7
|
+
/**
|
|
8
|
+
* <zh/> 扩展类型
|
|
9
|
+
*
|
|
10
|
+
* <en/> Extension type
|
|
11
|
+
*/
|
|
12
|
+
type: string;
|
|
13
|
+
/**
|
|
14
|
+
* <zh/> 扩展 key,即唯一标识
|
|
15
|
+
*
|
|
16
|
+
* <en/> Extension key, that is, the unique identifier
|
|
17
|
+
*/
|
|
18
|
+
key: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
package/src/runtime/behavior.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { CommonEvent, ContainerEvent } from '../constants';
|
|
|
4
4
|
import { ExtensionController } from '../registry/extension';
|
|
5
5
|
import type { BehaviorOptions, CustomBehaviorOption } from '../spec/behavior';
|
|
6
6
|
import type { Target } from '../types';
|
|
7
|
+
import { isToBeDestroyed } from '../utils/element';
|
|
7
8
|
import { eventTargetOf } from '../utils/event';
|
|
8
9
|
import type { RuntimeContext } from './types';
|
|
9
10
|
|
|
@@ -70,6 +71,10 @@ export class BehaviorController extends ExtensionController<BaseBehavior<CustomB
|
|
|
70
71
|
if (!target) return;
|
|
71
72
|
const { graph, canvas } = this.context;
|
|
72
73
|
const { type: targetType, element: targetElement } = target;
|
|
74
|
+
// 即将销毁或已销毁的元素不再触发事件
|
|
75
|
+
// Elements that are about to be destroyed or have been destroyed no longer trigger events
|
|
76
|
+
if ('destroyed' in targetElement && (isToBeDestroyed(targetElement) || targetElement.destroyed)) return;
|
|
77
|
+
|
|
73
78
|
const { type, detail, button } = event;
|
|
74
79
|
const stdEvent = { ...event, target: targetElement, targetType, originalTarget };
|
|
75
80
|
|
package/src/runtime/data.ts
CHANGED
|
@@ -570,6 +570,7 @@ export class DataController {
|
|
|
570
570
|
const { model } = this;
|
|
571
571
|
|
|
572
572
|
const id = idOf(datum);
|
|
573
|
+
if (!model.hasNode(id)) return;
|
|
573
574
|
const original = toG6Data(model.getNode(id));
|
|
574
575
|
const value = mergeElementsData(original, datum);
|
|
575
576
|
model.mergeNodeData(id, value);
|
package/src/runtime/element.ts
CHANGED
|
@@ -68,7 +68,7 @@ export class ElementController {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
public getElementType(elementType: ElementType, datum: ElementDatum) {
|
|
71
|
-
const { options } = this.context;
|
|
71
|
+
const { options, graph } = this.context;
|
|
72
72
|
const userDefinedType = options[elementType]?.type || datum.type;
|
|
73
73
|
|
|
74
74
|
if (!userDefinedType) {
|
|
@@ -77,7 +77,8 @@ export class ElementController {
|
|
|
77
77
|
else return 'circle';
|
|
78
78
|
}
|
|
79
79
|
if (typeof userDefinedType === 'string') return userDefinedType;
|
|
80
|
-
|
|
80
|
+
// @ts-expect-error skip type check
|
|
81
|
+
return userDefinedType.call(graph, datum);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
private getTheme(elementType: ElementType) {
|
|
@@ -134,12 +135,13 @@ export class ElementController {
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
private computeElementsDefaultStyle(ids?: ID[]) {
|
|
138
|
+
const { graph } = this.context;
|
|
137
139
|
this.forEachElementData((elementType, elementData) => {
|
|
138
140
|
const length = elementData.length;
|
|
139
141
|
for (let i = 0; i < length; i++) {
|
|
140
142
|
const datum = elementData[i];
|
|
141
143
|
if (ids === undefined || ids.includes(idOf(datum))) {
|
|
142
|
-
this.computeElementDefaultStyle(elementType, { datum });
|
|
144
|
+
this.computeElementDefaultStyle(elementType, { datum, graph });
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
});
|
|
@@ -190,13 +192,14 @@ export class ElementController {
|
|
|
190
192
|
* @param ids - <zh/> 计算指定元素的状态样式 | <en/> compute state style of specified elements
|
|
191
193
|
*/
|
|
192
194
|
private computeElementsStatesStyle(ids?: ID[]) {
|
|
195
|
+
const { graph } = this.context;
|
|
193
196
|
this.forEachElementData((elementType, elementData) => {
|
|
194
197
|
const length = elementData.length;
|
|
195
198
|
for (let i = 0; i < length; i++) {
|
|
196
199
|
const datum = elementData[i];
|
|
197
200
|
if (ids === undefined || ids.includes(idOf(datum))) {
|
|
198
201
|
const states = this.getElementState(idOf(datum));
|
|
199
|
-
this.computeElementStatesStyle(elementType, states, { datum });
|
|
202
|
+
this.computeElementStatesStyle(elementType, states, { datum, graph });
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
205
|
});
|
package/src/runtime/graph.ts
CHANGED
|
@@ -355,7 +355,7 @@ export class Graph extends EventEmitter {
|
|
|
355
355
|
public updateBehavior(behavior: UpdateBehaviorOption): void {
|
|
356
356
|
this.setBehaviors((behaviors) =>
|
|
357
357
|
behaviors.map((_behavior) => {
|
|
358
|
-
if (
|
|
358
|
+
if (typeof _behavior === 'object' && _behavior.key === behavior.key) {
|
|
359
359
|
return { ..._behavior, ...behavior };
|
|
360
360
|
}
|
|
361
361
|
return _behavior;
|
|
@@ -414,7 +414,7 @@ export class Graph extends EventEmitter {
|
|
|
414
414
|
public updatePlugin(plugin: UpdatePluginOption): void {
|
|
415
415
|
this.setPlugins((plugins) =>
|
|
416
416
|
plugins.map((_plugin) => {
|
|
417
|
-
if (
|
|
417
|
+
if (typeof _plugin === 'object' && _plugin.key === plugin.key) {
|
|
418
418
|
return { ..._plugin, ...plugin };
|
|
419
419
|
}
|
|
420
420
|
return _plugin;
|
|
@@ -482,7 +482,7 @@ export class Graph extends EventEmitter {
|
|
|
482
482
|
public updateTransform(transform: UpdateTransformOption): void {
|
|
483
483
|
this.setTransforms((transforms) =>
|
|
484
484
|
transforms.map((_transform) => {
|
|
485
|
-
if (
|
|
485
|
+
if (typeof _transform === 'object' && _transform.key === transform.key) {
|
|
486
486
|
return { ..._transform, ...transform };
|
|
487
487
|
}
|
|
488
488
|
return _transform;
|
package/src/runtime/layout.ts
CHANGED
|
@@ -56,9 +56,12 @@ export class LayoutController {
|
|
|
56
56
|
emit(graph, new GraphLifeCycleEvent(GraphEvent.BEFORE_LAYOUT));
|
|
57
57
|
for (const options of pipeline) {
|
|
58
58
|
const index = pipeline.indexOf(options);
|
|
59
|
-
|
|
60
59
|
const data = this.getLayoutData(options);
|
|
61
|
-
const
|
|
60
|
+
const opts = { ...this.presetOptions, ...options };
|
|
61
|
+
|
|
62
|
+
emit(graph, new GraphLifeCycleEvent(GraphEvent.BEFORE_STAGE_LAYOUT, { options: opts, index }));
|
|
63
|
+
const result = await this.stepLayout(data, opts, index);
|
|
64
|
+
emit(graph, new GraphLifeCycleEvent(GraphEvent.AFTER_STAGE_LAYOUT, { options: opts, index }));
|
|
62
65
|
|
|
63
66
|
if (!options.animation) {
|
|
64
67
|
this.updateElementPosition(result, false);
|
package/src/runtime/viewport.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AABB } from '@antv/g';
|
|
2
2
|
import { clamp, isNumber, pick } from '@antv/util';
|
|
3
3
|
import { AnimationType, GraphEvent } from '../constants';
|
|
4
|
-
import type { FitViewOptions, ID, Point, TransformOptions,
|
|
4
|
+
import type { FitViewOptions, ID, Point, TransformOptions, ViewportAnimationEffectTiming } from '../types';
|
|
5
5
|
import { getAnimationOptions } from '../utils/animation';
|
|
6
6
|
import { getBBoxSize, getCombinedBBox } from '../utils/bbox';
|
|
7
7
|
import { AnimateEvent, ViewportEvent, emit } from '../utils/event';
|
|
@@ -96,28 +96,14 @@ export class ViewportController {
|
|
|
96
96
|
return this.camera.getRoll();
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
private
|
|
100
|
-
const currentZoom = this.getZoom();
|
|
101
|
-
const { camera } = this;
|
|
102
|
-
const { mode, translate = [] } = options;
|
|
103
|
-
const [x = 0, y = 0] = translate;
|
|
104
|
-
const [cx = 0, cy = 0] = this.getCanvasCenter();
|
|
105
|
-
const [px, py] = camera.getPosition();
|
|
106
|
-
|
|
107
|
-
const delta = divide([-x, -y], currentZoom);
|
|
108
|
-
|
|
109
|
-
const value = mode === 'relative' ? delta : add([cx - px, cy - py], delta);
|
|
110
|
-
return value as [number, number];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
private getAnimationTranslateArgs(options: TransformOptions) {
|
|
99
|
+
private getTranslateOptions(options: TransformOptions) {
|
|
114
100
|
const { camera } = this;
|
|
115
101
|
const { mode, translate = [] } = options;
|
|
116
102
|
const currentZoom = this.getZoom();
|
|
117
103
|
|
|
118
104
|
const position = camera.getPosition();
|
|
119
105
|
const focalPoint = camera.getFocalPoint();
|
|
120
|
-
const
|
|
106
|
+
const [cx, cy] = this.getCanvasCenter();
|
|
121
107
|
|
|
122
108
|
const [x = 0, y = 0, z = 0] = translate;
|
|
123
109
|
|
|
@@ -129,23 +115,18 @@ export class ViewportController {
|
|
|
129
115
|
focalPoint: add(focalPoint, delta),
|
|
130
116
|
}
|
|
131
117
|
: {
|
|
132
|
-
position: add(
|
|
133
|
-
focalPoint: add(focalPoint, delta),
|
|
118
|
+
position: add([cx, cy, position[2]], delta),
|
|
119
|
+
focalPoint: add([cx, cy, focalPoint[2]], delta),
|
|
134
120
|
};
|
|
135
121
|
}
|
|
136
122
|
|
|
137
|
-
private
|
|
138
|
-
const { mode, rotate = 0 } = options;
|
|
139
|
-
return mode === 'relative' ? rotate : rotate - this.camera.getRoll();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
private getAnimationRotateArgs(options: TransformOptions) {
|
|
123
|
+
private getRotateOptions(options: TransformOptions) {
|
|
143
124
|
const { mode, rotate = 0 } = options;
|
|
144
125
|
const roll = mode === 'relative' ? this.camera.getRoll() + rotate : rotate;
|
|
145
126
|
return { roll };
|
|
146
127
|
}
|
|
147
128
|
|
|
148
|
-
private
|
|
129
|
+
private getZoomOptions(options: TransformOptions) {
|
|
149
130
|
const { zoomRange } = this.context.options;
|
|
150
131
|
const currentZoom = this.camera.getZoom();
|
|
151
132
|
const { mode, scale = 1 } = options;
|
|
@@ -153,20 +134,19 @@ export class ViewportController {
|
|
|
153
134
|
}
|
|
154
135
|
|
|
155
136
|
public async transform(options: TransformOptions, animation?: ViewportAnimationEffectTiming) {
|
|
156
|
-
const { camera } = this;
|
|
157
137
|
const { graph } = this.context;
|
|
158
|
-
const { translate, rotate, scale
|
|
138
|
+
const { translate, rotate, scale } = options;
|
|
159
139
|
this.cancelAnimation();
|
|
160
140
|
|
|
161
141
|
emit(graph, new ViewportEvent(GraphEvent.BEFORE_TRANSFORM, options));
|
|
162
142
|
const _animation = this.getAnimation(animation);
|
|
163
143
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (isNumber(scale)) Object.assign(landmarkOptions, { zoom: this.getZoomArgs(options) });
|
|
144
|
+
const landmarkOptions: Parameters<typeof this.camera.createLandmark>[1] = {};
|
|
145
|
+
if (translate) Object.assign(landmarkOptions, this.getTranslateOptions(options));
|
|
146
|
+
if (isNumber(rotate)) Object.assign(landmarkOptions, this.getRotateOptions(options));
|
|
147
|
+
if (isNumber(scale)) Object.assign(landmarkOptions, { zoom: this.getZoomOptions(options) });
|
|
169
148
|
|
|
149
|
+
if (_animation) {
|
|
170
150
|
emit(graph, new AnimateEvent(GraphEvent.BEFORE_ANIMATE, AnimationType.TRANSFORM, null, options));
|
|
171
151
|
|
|
172
152
|
return new Promise<void>((resolve) => {
|
|
@@ -180,18 +160,9 @@ export class ViewportController {
|
|
|
180
160
|
});
|
|
181
161
|
});
|
|
182
162
|
} else {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (origin) camera.pan(origin[0] - x, origin[1] - y);
|
|
187
|
-
const value = this.getRotateArgs(options);
|
|
188
|
-
camera.rotate(0, 0, value);
|
|
189
|
-
if (origin) camera.pan(x - origin[0], y - origin[1]);
|
|
190
|
-
}
|
|
191
|
-
if (isNumber(scale)) {
|
|
192
|
-
const targetZoom = this.getZoomArgs(options);
|
|
193
|
-
camera.setZoomByViewportPoint(targetZoom, origin as Vector2);
|
|
194
|
-
}
|
|
163
|
+
this.camera.gotoLandmark(this.createLandmark(landmarkOptions), {
|
|
164
|
+
duration: 0,
|
|
165
|
+
});
|
|
195
166
|
|
|
196
167
|
emit(graph, new ViewportEvent(GraphEvent.AFTER_TRANSFORM, options));
|
|
197
168
|
}
|
|
@@ -227,9 +198,7 @@ export class ViewportController {
|
|
|
227
198
|
scale,
|
|
228
199
|
translate: add(
|
|
229
200
|
subtract(this.getCanvasCenter(), this.getBBoxInViewport(canvasBounds).center),
|
|
230
|
-
|
|
231
|
-
// When animation is enabled, zoom and translate are performed simultaneously, so they need to be divided by the scaling ratio
|
|
232
|
-
_animation ? divide(this.paddingOffset, scale) : this.paddingOffset,
|
|
201
|
+
divide(this.paddingOffset, scale),
|
|
233
202
|
),
|
|
234
203
|
},
|
|
235
204
|
_animation,
|
package/src/spec/behavior.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ExtensionOptions } from '../registry/extension/types';
|
|
1
|
+
import type { Graph } from '../runtime/graph';
|
|
3
2
|
|
|
4
|
-
export type BehaviorOptions =
|
|
3
|
+
export type BehaviorOptions = (string | CustomBehaviorOption | ((this: Graph) => CustomBehaviorOption))[];
|
|
5
4
|
|
|
6
5
|
export interface UpdateBehaviorOption {
|
|
7
6
|
key: string;
|
|
8
|
-
[key: string]:
|
|
7
|
+
[key: string]: unknown;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export interface CustomBehaviorOption extends Record<string, any> {
|
|
@@ -14,7 +13,7 @@ export interface CustomBehaviorOption extends Record<string, any> {
|
|
|
14
13
|
*
|
|
15
14
|
* <en/> Behavior type
|
|
16
15
|
*/
|
|
17
|
-
type
|
|
16
|
+
type: string;
|
|
18
17
|
/**
|
|
19
18
|
* <zh/> 交互 key,即唯一标识
|
|
20
19
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AnimationOptions } from '../../animations/types';
|
|
2
2
|
import type { BaseComboStyleProps } from '../../elements/combos';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Graph } from '../../runtime/graph';
|
|
4
4
|
import type { ComboData } from '../data';
|
|
5
5
|
import type { AnimationStage } from './animation';
|
|
6
6
|
import type { PaletteOptions } from './palette';
|
|
@@ -16,19 +16,31 @@ export interface ComboOptions {
|
|
|
16
16
|
*
|
|
17
17
|
* <en/> Combo type
|
|
18
18
|
*/
|
|
19
|
-
type?: string | ((datum: ComboData) => string);
|
|
19
|
+
type?: string | ((this: Graph, datum: ComboData) => string);
|
|
20
20
|
/**
|
|
21
21
|
* <zh/> 组合样式
|
|
22
22
|
*
|
|
23
23
|
* <en/> Combo style
|
|
24
24
|
*/
|
|
25
|
-
style?:
|
|
25
|
+
style?:
|
|
26
|
+
| ComboStyle
|
|
27
|
+
| ((this: Graph, data: ComboData) => ComboStyle)
|
|
28
|
+
| {
|
|
29
|
+
[K in keyof ComboStyle]: ComboStyle[K] | ((this: Graph, data: ComboData) => ComboStyle[K]);
|
|
30
|
+
};
|
|
26
31
|
/**
|
|
27
32
|
* <zh/> 组合状态样式
|
|
28
33
|
*
|
|
29
34
|
* <en/> Combo state style
|
|
30
35
|
*/
|
|
31
|
-
state?: Record<
|
|
36
|
+
state?: Record<
|
|
37
|
+
string,
|
|
38
|
+
| ComboStyle
|
|
39
|
+
| ((this: Graph, data: ComboData) => ComboStyle)
|
|
40
|
+
| {
|
|
41
|
+
[K in keyof ComboStyle]: ComboStyle[K] | ((this: Graph, data: ComboData) => ComboStyle[K]);
|
|
42
|
+
}
|
|
43
|
+
>;
|
|
32
44
|
/**
|
|
33
45
|
* <zh/> 组合动画
|
|
34
46
|
*
|
package/src/spec/element/edge.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AnimationOptions } from '../../animations/types';
|
|
2
2
|
import type { BaseEdgeStyleProps } from '../../elements/edges';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Graph } from '../../runtime/graph';
|
|
4
4
|
import type { EdgeData } from '../data';
|
|
5
5
|
import type { AnimationStage } from './animation';
|
|
6
6
|
import type { PaletteOptions } from './palette';
|
|
@@ -16,19 +16,31 @@ export interface EdgeOptions {
|
|
|
16
16
|
*
|
|
17
17
|
* <en/> Edge type
|
|
18
18
|
*/
|
|
19
|
-
type?: string | ((datum: EdgeData) => string);
|
|
19
|
+
type?: string | ((this: Graph, datum: EdgeData) => string);
|
|
20
20
|
/**
|
|
21
21
|
* <zh/> 边样式
|
|
22
22
|
*
|
|
23
23
|
* <en/> Edge style
|
|
24
24
|
*/
|
|
25
|
-
style?:
|
|
25
|
+
style?:
|
|
26
|
+
| EdgeStyle
|
|
27
|
+
| ((this: Graph, data: EdgeData) => EdgeStyle)
|
|
28
|
+
| {
|
|
29
|
+
[K in keyof EdgeStyle]: EdgeStyle[K] | ((this: Graph, data: EdgeData) => EdgeStyle[K]);
|
|
30
|
+
};
|
|
26
31
|
/**
|
|
27
32
|
* <zh/> 边状态样式
|
|
28
33
|
*
|
|
29
34
|
* <en/> Edge state style
|
|
30
35
|
*/
|
|
31
|
-
state?: Record<
|
|
36
|
+
state?: Record<
|
|
37
|
+
string,
|
|
38
|
+
| EdgeStyle
|
|
39
|
+
| ((this: Graph, data: EdgeData) => EdgeStyle)
|
|
40
|
+
| {
|
|
41
|
+
[K in keyof EdgeStyle]: EdgeStyle[K] | ((this: Graph, data: EdgeData) => EdgeStyle[K]);
|
|
42
|
+
}
|
|
43
|
+
>;
|
|
32
44
|
/**
|
|
33
45
|
* <zh/> 边动画
|
|
34
46
|
*
|