@antv/g6 5.0.0-beta.34 → 5.0.0-beta.35
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/animations/types.d.ts +3 -4
- package/dist/lib/behaviors/base-behavior.d.ts +2 -1
- package/dist/lib/behaviors/brush-select.d.ts +31 -13
- package/dist/lib/behaviors/click-element.d.ts +28 -5
- package/dist/lib/behaviors/collapse-expand.d.ts +2 -0
- package/dist/lib/behaviors/drag-canvas.d.ts +7 -0
- package/dist/lib/behaviors/drag-element.d.ts +2 -2
- package/dist/lib/behaviors/index.d.ts +2 -0
- package/dist/lib/behaviors/lasso-select.d.ts +2 -1
- package/dist/lib/behaviors/scroll-canvas.d.ts +64 -0
- package/dist/lib/behaviors/types.d.ts +2 -1
- package/dist/lib/behaviors/zoom-canvas.d.ts +1 -1
- package/dist/lib/constants/events/graph.d.ts +5 -1
- package/dist/lib/elements/combos/base-combo.d.ts +1 -1
- package/dist/lib/elements/edges/base-edge.d.ts +0 -5
- package/dist/lib/elements/nodes/base-node.d.ts +1 -7
- package/dist/lib/elements/shapes/badge.d.ts +1 -1
- package/dist/lib/{plugins/hull/shape.d.ts → elements/shapes/contour.d.ts} +17 -17
- package/dist/lib/elements/shapes/index.d.ts +2 -0
- package/dist/lib/exports.d.ts +12 -20
- package/dist/lib/plugins/bubble-sets.d.ts +45 -0
- package/dist/lib/plugins/camera-setting.d.ts +4 -2
- package/dist/lib/plugins/contextmenu.d.ts +1 -0
- package/dist/lib/plugins/grid-line.d.ts +51 -8
- package/dist/lib/plugins/hull/index.d.ts +43 -11
- package/dist/lib/plugins/index.d.ts +4 -0
- package/dist/lib/plugins/timebar.d.ts +225 -0
- package/dist/lib/plugins/tooltip.d.ts +2 -2
- package/dist/lib/registry/index.d.ts +1 -1
- package/dist/lib/runtime/data.d.ts +9 -3
- package/dist/lib/runtime/element.d.ts +3 -7
- package/dist/lib/runtime/graph.d.ts +530 -42
- package/dist/lib/runtime/types.d.ts +3 -3
- package/dist/lib/runtime/viewport.d.ts +2 -2
- package/dist/lib/spec/canvas.d.ts +6 -2
- package/{lib/spec/spec.d.ts → dist/lib/spec/graph.d.ts} +12 -4
- package/dist/lib/spec/index.d.ts +1 -1
- package/dist/lib/spec/theme.d.ts +1 -4
- package/dist/lib/spec/viewport.d.ts +1 -1
- package/dist/lib/themes/types.d.ts +0 -1
- package/dist/lib/transforms/process-parallel-edges.d.ts +1 -1
- package/dist/lib/types/data.d.ts +2 -2
- package/dist/lib/types/viewport.d.ts +4 -4
- package/dist/lib/utils/animation.d.ts +5 -5
- package/dist/lib/utils/data.d.ts +2 -2
- package/dist/lib/utils/element.d.ts +1 -1
- package/dist/lib/utils/event/events.d.ts +1 -1
- package/dist/lib/utils/event/index.d.ts +1 -1
- package/dist/lib/utils/palette.d.ts +1 -1
- package/dist/lib/utils/relation.d.ts +2 -2
- package/dist/lib/utils/visibility.d.ts +1 -1
- package/esm/animations/types.d.ts +3 -4
- package/esm/behaviors/base-behavior.d.ts +2 -1
- package/esm/behaviors/brush-select.d.ts +31 -13
- package/esm/behaviors/brush-select.js +7 -2
- package/esm/behaviors/brush-select.js.map +1 -1
- package/esm/behaviors/click-element.d.ts +28 -5
- package/esm/behaviors/click-element.js +11 -0
- package/esm/behaviors/click-element.js.map +1 -1
- package/esm/behaviors/collapse-expand.d.ts +2 -0
- package/esm/behaviors/collapse-expand.js +2 -2
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/drag-canvas.d.ts +7 -0
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +2 -2
- package/esm/behaviors/index.d.ts +2 -0
- package/esm/behaviors/index.js +1 -0
- package/esm/behaviors/index.js.map +1 -1
- package/esm/behaviors/lasso-select.d.ts +2 -1
- package/esm/behaviors/lasso-select.js +1 -1
- package/esm/behaviors/lasso-select.js.map +1 -1
- package/esm/behaviors/scroll-canvas.d.ts +64 -0
- package/esm/behaviors/scroll-canvas.js +80 -0
- package/esm/behaviors/scroll-canvas.js.map +1 -0
- package/esm/behaviors/types.d.ts +2 -1
- package/esm/behaviors/zoom-canvas.d.ts +1 -1
- package/esm/constants/events/graph.d.ts +5 -1
- package/esm/constants/events/graph.js +4 -0
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/elements/combos/base-combo.d.ts +1 -1
- package/esm/elements/edges/base-edge.d.ts +0 -5
- package/esm/elements/edges/base-edge.js +1 -2
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +1 -7
- package/esm/elements/nodes/base-node.js +2 -2
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/shapes/badge.d.ts +1 -1
- package/{lib/plugins/hull/shape.d.ts → esm/elements/shapes/contour.d.ts} +17 -17
- package/esm/{plugins/hull/shape.js → elements/shapes/contour.js} +12 -11
- package/esm/elements/shapes/contour.js.map +1 -0
- package/esm/elements/shapes/index.d.ts +2 -0
- package/esm/elements/shapes/index.js +1 -0
- package/esm/elements/shapes/index.js.map +1 -1
- package/esm/exports.d.ts +12 -20
- package/esm/exports.js +6 -17
- package/esm/exports.js.map +1 -1
- package/esm/plugins/bubble-sets.d.ts +45 -0
- package/esm/plugins/bubble-sets.js +212 -0
- package/esm/plugins/bubble-sets.js.map +1 -0
- package/esm/plugins/camera-setting.d.ts +4 -2
- package/esm/plugins/camera-setting.js.map +1 -1
- package/esm/plugins/contextmenu.d.ts +1 -0
- package/esm/plugins/contextmenu.js +1 -0
- package/esm/plugins/contextmenu.js.map +1 -1
- package/esm/plugins/grid-line.d.ts +51 -8
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/history/utils.js +6 -2
- package/esm/plugins/history/utils.js.map +1 -1
- package/esm/plugins/hull/index.d.ts +43 -11
- package/esm/plugins/hull/index.js +46 -16
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/index.d.ts +4 -0
- package/esm/plugins/index.js +2 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/legend.js +2 -1
- package/esm/plugins/legend.js.map +1 -1
- package/esm/plugins/timebar.d.ts +225 -0
- package/esm/plugins/timebar.js +253 -0
- package/esm/plugins/timebar.js.map +1 -0
- package/esm/plugins/tooltip.d.ts +2 -2
- package/esm/registry/build-in.js +10 -7
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/index.d.ts +1 -1
- package/esm/registry/index.js +1 -1
- package/esm/runtime/canvas.js +2 -2
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +9 -3
- package/esm/runtime/data.js +20 -3
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +3 -7
- package/esm/runtime/element.js +6 -4
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +530 -42
- package/esm/runtime/graph.js +409 -33
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/types.d.ts +3 -3
- package/esm/runtime/viewport.d.ts +2 -2
- package/esm/runtime/viewport.js +2 -2
- package/esm/spec/canvas.d.ts +6 -2
- package/{dist/lib/spec/spec.d.ts → esm/spec/graph.d.ts} +12 -4
- package/esm/spec/graph.js +2 -0
- package/esm/spec/graph.js.map +1 -0
- package/esm/spec/index.d.ts +1 -1
- package/esm/spec/theme.d.ts +1 -4
- package/esm/spec/viewport.d.ts +1 -1
- package/esm/themes/base.js +9 -9
- package/esm/themes/base.js.map +1 -1
- package/esm/themes/types.d.ts +0 -1
- package/esm/transforms/process-parallel-edges.d.ts +1 -1
- package/esm/types/data.d.ts +2 -2
- package/esm/types/viewport.d.ts +4 -4
- package/esm/utils/animation.d.ts +5 -5
- package/esm/utils/animation.js +2 -2
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/change.js +8 -1
- package/esm/utils/change.js.map +1 -1
- package/esm/utils/data.d.ts +2 -2
- package/esm/utils/data.js +2 -2
- package/esm/utils/element.d.ts +1 -1
- package/esm/utils/element.js +2 -2
- package/esm/utils/event/events.d.ts +1 -1
- package/esm/utils/event/events.js.map +1 -1
- package/esm/utils/event/index.d.ts +1 -1
- package/esm/utils/event/index.js +1 -1
- package/esm/utils/palette.d.ts +1 -1
- package/esm/utils/palette.js +1 -1
- package/esm/utils/relation.d.ts +2 -2
- package/esm/utils/relation.js +2 -2
- package/esm/utils/visibility.d.ts +1 -1
- package/esm/utils/visibility.js +1 -1
- package/lib/animations/types.d.ts +3 -4
- package/lib/behaviors/base-behavior.d.ts +2 -1
- package/lib/behaviors/brush-select.d.ts +31 -13
- package/lib/behaviors/brush-select.js +7 -2
- package/lib/behaviors/brush-select.js.map +1 -1
- package/lib/behaviors/click-element.d.ts +28 -5
- package/lib/behaviors/click-element.js +11 -0
- package/lib/behaviors/click-element.js.map +1 -1
- package/lib/behaviors/collapse-expand.d.ts +2 -0
- package/lib/behaviors/collapse-expand.js +2 -2
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/drag-canvas.d.ts +7 -0
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +2 -2
- package/lib/behaviors/index.d.ts +2 -0
- package/lib/behaviors/index.js +3 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/behaviors/lasso-select.d.ts +2 -1
- package/lib/behaviors/lasso-select.js +1 -1
- package/lib/behaviors/lasso-select.js.map +1 -1
- package/lib/behaviors/scroll-canvas.d.ts +64 -0
- package/lib/behaviors/scroll-canvas.js +84 -0
- package/lib/behaviors/scroll-canvas.js.map +1 -0
- package/lib/behaviors/types.d.ts +2 -1
- package/lib/behaviors/zoom-canvas.d.ts +1 -1
- package/lib/constants/events/graph.d.ts +5 -1
- package/lib/constants/events/graph.js +4 -0
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/elements/combos/base-combo.d.ts +1 -1
- package/lib/elements/edges/base-edge.d.ts +0 -5
- package/lib/elements/edges/base-edge.js +1 -2
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +1 -7
- package/lib/elements/nodes/base-node.js +2 -2
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/shapes/badge.d.ts +1 -1
- package/{esm/plugins/hull/shape.d.ts → lib/elements/shapes/contour.d.ts} +17 -17
- package/lib/{plugins/hull/shape.js → elements/shapes/contour.js} +15 -14
- package/lib/elements/shapes/contour.js.map +1 -0
- package/lib/elements/shapes/index.d.ts +2 -0
- package/lib/elements/shapes/index.js +3 -1
- package/lib/elements/shapes/index.js.map +1 -1
- package/lib/exports.d.ts +12 -20
- package/lib/exports.js +46 -17
- package/lib/exports.js.map +1 -1
- package/lib/plugins/bubble-sets.d.ts +45 -0
- package/lib/plugins/bubble-sets.js +216 -0
- package/lib/plugins/bubble-sets.js.map +1 -0
- package/lib/plugins/camera-setting.d.ts +4 -2
- package/lib/plugins/camera-setting.js.map +1 -1
- package/lib/plugins/contextmenu.d.ts +1 -0
- package/lib/plugins/contextmenu.js +1 -0
- package/lib/plugins/contextmenu.js.map +1 -1
- package/lib/plugins/grid-line.d.ts +51 -8
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/history/utils.js +6 -2
- package/lib/plugins/history/utils.js.map +1 -1
- package/lib/plugins/hull/index.d.ts +43 -11
- package/lib/plugins/hull/index.js +46 -16
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/index.d.ts +4 -0
- package/lib/plugins/index.js +5 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/legend.js +2 -1
- package/lib/plugins/legend.js.map +1 -1
- package/lib/plugins/timebar.d.ts +225 -0
- package/lib/plugins/timebar.js +257 -0
- package/lib/plugins/timebar.js.map +1 -0
- package/lib/plugins/tooltip.d.ts +2 -2
- package/lib/registry/build-in.js +8 -5
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/index.d.ts +1 -1
- package/lib/registry/index.js +1 -1
- package/lib/runtime/canvas.js +2 -2
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +9 -3
- package/lib/runtime/data.js +20 -3
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +3 -7
- package/lib/runtime/element.js +6 -4
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +530 -42
- package/lib/runtime/graph.js +409 -33
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/types.d.ts +3 -3
- package/lib/runtime/viewport.d.ts +2 -2
- package/lib/runtime/viewport.js +2 -2
- package/lib/spec/canvas.d.ts +6 -2
- package/{esm/spec/spec.d.ts → lib/spec/graph.d.ts} +12 -4
- package/lib/spec/{spec.js → graph.js} +1 -1
- package/lib/spec/graph.js.map +1 -0
- package/lib/spec/index.d.ts +1 -1
- package/lib/spec/theme.d.ts +1 -4
- package/lib/spec/viewport.d.ts +1 -1
- package/lib/themes/base.js +9 -9
- package/lib/themes/base.js.map +1 -1
- package/lib/themes/types.d.ts +0 -1
- package/lib/transforms/process-parallel-edges.d.ts +1 -1
- package/lib/types/data.d.ts +2 -2
- package/lib/types/viewport.d.ts +4 -4
- package/lib/utils/animation.d.ts +5 -5
- package/lib/utils/animation.js +2 -2
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/change.js +8 -1
- package/lib/utils/change.js.map +1 -1
- package/lib/utils/data.d.ts +2 -2
- package/lib/utils/data.js +2 -2
- package/lib/utils/element.d.ts +1 -1
- package/lib/utils/element.js +2 -2
- package/lib/utils/event/events.d.ts +1 -1
- package/lib/utils/event/events.js.map +1 -1
- package/lib/utils/event/index.d.ts +1 -1
- package/lib/utils/event/index.js +1 -1
- package/lib/utils/palette.d.ts +1 -1
- package/lib/utils/palette.js +1 -1
- package/lib/utils/relation.d.ts +2 -2
- package/lib/utils/relation.js +2 -2
- package/lib/utils/visibility.d.ts +1 -1
- package/lib/utils/visibility.js +1 -1
- package/package.json +2 -1
- package/src/animations/types.ts +3 -4
- package/src/behaviors/base-behavior.ts +1 -1
- package/src/behaviors/brush-select.ts +33 -14
- package/src/behaviors/click-element.ts +28 -5
- package/src/behaviors/collapse-expand.ts +4 -2
- package/src/behaviors/drag-canvas.ts +7 -0
- package/src/behaviors/drag-element.ts +2 -2
- package/src/behaviors/index.ts +2 -0
- package/src/behaviors/lasso-select.ts +2 -2
- package/src/behaviors/scroll-canvas.ts +143 -0
- package/src/behaviors/types.ts +2 -1
- package/src/behaviors/zoom-canvas.ts +1 -1
- package/src/constants/events/graph.ts +4 -0
- package/src/elements/combos/base-combo.ts +1 -1
- package/src/elements/edges/base-edge.ts +1 -7
- package/src/elements/nodes/base-node.ts +3 -12
- package/src/{plugins/hull/shape.ts → elements/shapes/contour.ts} +27 -34
- package/src/elements/shapes/index.ts +2 -0
- package/src/exports.ts +104 -24
- package/src/plugins/bubble-sets.ts +268 -0
- package/src/plugins/camera-setting.ts +4 -2
- package/src/plugins/contextmenu.ts +1 -0
- package/src/plugins/grid-line.ts +51 -8
- package/src/plugins/history/utils.ts +6 -2
- package/src/plugins/hull/index.ts +57 -20
- package/src/plugins/index.ts +4 -0
- package/src/plugins/legend.ts +3 -1
- package/src/plugins/timebar.ts +450 -0
- package/src/plugins/tooltip.ts +2 -2
- package/src/registry/build-in.ts +21 -6
- package/src/registry/index.ts +1 -1
- package/src/runtime/canvas.ts +2 -2
- package/src/runtime/data.ts +21 -3
- package/src/runtime/element.ts +5 -4
- package/src/runtime/graph.ts +543 -48
- package/src/runtime/types.ts +3 -3
- package/src/runtime/viewport.ts +2 -2
- package/src/spec/canvas.ts +6 -2
- package/src/spec/{spec.ts → graph.ts} +12 -4
- package/src/spec/index.ts +1 -1
- package/src/spec/theme.ts +1 -5
- package/src/spec/viewport.ts +1 -1
- package/src/themes/base.ts +9 -9
- package/src/themes/types.ts +0 -2
- package/src/transforms/process-parallel-edges.ts +1 -1
- package/src/types/data.ts +2 -2
- package/src/types/viewport.ts +4 -4
- package/src/utils/animation.ts +4 -4
- package/src/utils/change.ts +6 -1
- package/src/utils/data.ts +2 -2
- package/src/utils/element.ts +2 -2
- package/src/utils/event/events.ts +3 -1
- package/src/utils/event/index.ts +1 -1
- package/src/utils/palette.ts +1 -1
- package/src/utils/relation.ts +2 -2
- package/src/utils/visibility.ts +1 -1
- package/esm/plugins/hull/shape.js.map +0 -1
- package/esm/spec/spec.js +0 -2
- package/esm/spec/spec.js.map +0 -1
- package/lib/plugins/hull/shape.js.map +0 -1
- package/lib/spec/spec.js.map +0 -1
package/src/behaviors/types.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { BaseBehavior } from './base-behavior';
|
|
2
2
|
import type { DragCanvasOptions } from './drag-canvas';
|
|
3
|
+
import type { ScrollCanvasOptions } from './scroll-canvas';
|
|
3
4
|
import type { ZoomCanvasOptions } from './zoom-canvas';
|
|
4
5
|
|
|
5
6
|
export type { States } from './brush-select';
|
|
6
7
|
|
|
7
|
-
export type BuiltInBehaviorOptions = DragCanvasOptions | ZoomCanvasOptions;
|
|
8
|
+
export type BuiltInBehaviorOptions = DragCanvasOptions | ZoomCanvasOptions | ScrollCanvasOptions;
|
|
8
9
|
export type Behavior = BaseBehavior<any>;
|
|
@@ -26,7 +26,7 @@ export interface ZoomCanvasOptions extends BaseBehaviorOptions {
|
|
|
26
26
|
* <zh/> 触发缩放的方式
|
|
27
27
|
*
|
|
28
28
|
* <en/> The way to trigger zoom
|
|
29
|
-
* @
|
|
29
|
+
* @remarks
|
|
30
30
|
* <zh/>
|
|
31
31
|
* - 数组:组合快捷键,默认使用滚轮缩放,['Control'] 表示按住 Control 键滚动鼠标滚轮时触发缩放
|
|
32
32
|
* - 对象:缩放快捷键,例如 { zoomIn: ['Control', '+'], zoomOut: ['Control', '-'], reset: ['Control', '0'] }
|
|
@@ -51,4 +51,8 @@ export enum GraphEvent {
|
|
|
51
51
|
BATCH_START = 'batchstart',
|
|
52
52
|
/** <zh/> 批处理结束 | <en/> Batch processing ends */
|
|
53
53
|
BATCH_END = 'batchend',
|
|
54
|
+
/** <zh/> 销毁开始之前 | <en/> Before destruction */
|
|
55
|
+
BEFORE_DESTROY = 'beforedestroy',
|
|
56
|
+
/** <zh/> 销毁结束之后 | <en/> After destruction */
|
|
57
|
+
AFTER_DESTROY = 'afterdestroy',
|
|
54
58
|
}
|
|
@@ -57,7 +57,7 @@ export type BaseComboStyleProps<T extends Record<string, unknown> = Record<strin
|
|
|
57
57
|
* <zh/> Combo 的子元素数据
|
|
58
58
|
*
|
|
59
59
|
* <en/> The data of the children of combo
|
|
60
|
-
* @
|
|
60
|
+
* @remarks
|
|
61
61
|
* <zh/> 如果 combo 是收起状态,children 可能为空,通过 childrenData 能够获取完整的子元素数据
|
|
62
62
|
*
|
|
63
63
|
* <en/> If the combo is collapsed, children may be empty, and the complete child element data can be obtained through childrenData
|
|
@@ -78,11 +78,6 @@ export type BaseEdgeStyleProps = BaseElementStyleProps &
|
|
|
78
78
|
* <en/> Offset of the end arrow
|
|
79
79
|
*/
|
|
80
80
|
endArrowOffset?: number;
|
|
81
|
-
/**
|
|
82
|
-
* <zh/> 主色
|
|
83
|
-
* <en/> Subject color
|
|
84
|
-
*/
|
|
85
|
-
color?: string;
|
|
86
81
|
/**
|
|
87
82
|
* <zh/> 边的起点 shape
|
|
88
83
|
* <en/> The source shape. Represents the start of the edge
|
|
@@ -151,13 +146,12 @@ export abstract class BaseEdge extends BaseShape<BaseEdgeStyleProps> {
|
|
|
151
146
|
}
|
|
152
147
|
|
|
153
148
|
protected getKeyStyle(attributes: ParsedBaseEdgeStyleProps): PathStyleProps {
|
|
154
|
-
const { sourceNode, targetNode,
|
|
149
|
+
const { sourceNode, targetNode, ...style } = this.getGraphicStyle(attributes);
|
|
155
150
|
|
|
156
151
|
const path = isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
|
|
157
152
|
return {
|
|
158
153
|
path,
|
|
159
154
|
...omitStyleProps(style, ['halo', 'label', 'startArrow', 'endArrow']),
|
|
160
|
-
stroke: color || stroke,
|
|
161
155
|
};
|
|
162
156
|
}
|
|
163
157
|
|
|
@@ -59,18 +59,12 @@ export type BaseNodeStyleProps<T extends Record<string, unknown> = Record<string
|
|
|
59
59
|
* <en/> The size of node, which is a shortcut to set the width and height of node
|
|
60
60
|
*/
|
|
61
61
|
size?: Size;
|
|
62
|
-
/**
|
|
63
|
-
* <zh/> 主色
|
|
64
|
-
*
|
|
65
|
-
* <en/> Subject color
|
|
66
|
-
*/
|
|
67
|
-
color?: string;
|
|
68
62
|
/**
|
|
69
63
|
* @deprecated
|
|
70
64
|
* <zh/> 解决类型 style.getPropertyValue 问题,不要使用该属性
|
|
71
65
|
*
|
|
72
66
|
* <en/> Solve the problem of style.getPropertyValue, do not use this property
|
|
73
|
-
* @
|
|
67
|
+
* @remarks
|
|
74
68
|
* <zh/> 移除该属性会导致 Polygon 及其子类与 Node 不兼容
|
|
75
69
|
*
|
|
76
70
|
* <en/> Removing this property will cause Polygon and its subclasses to be incompatible with Node
|
|
@@ -200,12 +194,9 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
200
194
|
}
|
|
201
195
|
|
|
202
196
|
protected getKeyStyle(attributes: Required<S>) {
|
|
203
|
-
const
|
|
197
|
+
const style = this.getGraphicStyle(attributes);
|
|
204
198
|
|
|
205
|
-
return Object.assign(
|
|
206
|
-
{ fill: color || fill },
|
|
207
|
-
omitStyleProps(style, ['label', 'halo', 'icon', 'badge', 'port']),
|
|
208
|
-
) as any;
|
|
199
|
+
return Object.assign(omitStyleProps(style, ['label', 'halo', 'icon', 'badge', 'port'])) as any;
|
|
209
200
|
}
|
|
210
201
|
|
|
211
202
|
protected getLabelStyle(attributes: Required<S>): false | LabelStyleProps {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, Group, PathStyleProps } from '@antv/g';
|
|
2
2
|
import { Path } from '@antv/g';
|
|
3
3
|
import { deepMix } from '@antv/util';
|
|
4
|
-
import type { LabelStyleProps } from '../../elements/shapes';
|
|
5
|
-
import { BaseShape, Label } from '../../elements/shapes';
|
|
6
4
|
import type { CardinalPlacement, PrefixObject } from '../../types';
|
|
7
5
|
import { getPolygonTextStyleByPlacement } from '../../utils/polygon';
|
|
8
6
|
import { subStyleProps } from '../../utils/prefix';
|
|
9
7
|
import { getWordWrapWidthByBox } from '../../utils/text';
|
|
8
|
+
import type { LabelStyleProps } from '../shapes';
|
|
9
|
+
import { BaseShape } from './base-shape';
|
|
10
|
+
import { Label } from './label';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
interface ContourLabelStyleProps extends LabelStyleProps {
|
|
12
13
|
/**
|
|
13
14
|
* <zh/> 标签位置,可选值为 'top'、'right'、'bottom'、'left'、'center';默认为 'bottom'
|
|
14
15
|
* <en/> Label position, optional values are 'top', 'right', 'bottom', 'left', 'center'; default is 'bottom'
|
|
@@ -18,10 +19,10 @@ type HullLabelStyleProps = LabelStyleProps & {
|
|
|
18
19
|
* <zh/> 标签是否贴合轮廓,默认为 true
|
|
19
20
|
* <en/> Whether the label is close to the contour, default is true
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
closeToPath?: boolean;
|
|
22
23
|
/**
|
|
23
|
-
* <zh/> 标签是否跟随轮廓旋转,默认为 true,仅在
|
|
24
|
-
* <en/> Whether the label rotates with the contour, default is true. Only effective when
|
|
24
|
+
* <zh/> 标签是否跟随轮廓旋转,默认为 true,仅在 closeToPath 为 true 时生效
|
|
25
|
+
* <en/> Whether the label rotates with the contour, default is true. Only effective when closeToPath is true
|
|
25
26
|
*/
|
|
26
27
|
autoRotate?: boolean;
|
|
27
28
|
/**
|
|
@@ -39,58 +40,50 @@ type HullLabelStyleProps = LabelStyleProps & {
|
|
|
39
40
|
* <en/> The maximum width of the text, which will be automatically ellipsis if exceeded
|
|
40
41
|
*/
|
|
41
42
|
maxWidth?: number;
|
|
42
|
-
}
|
|
43
|
+
}
|
|
43
44
|
|
|
44
|
-
export type
|
|
45
|
+
export type ContourStyleProps = PathStyleProps & {
|
|
45
46
|
label?: boolean;
|
|
46
|
-
} & PrefixObject<
|
|
47
|
-
type
|
|
48
|
-
type
|
|
47
|
+
} & PrefixObject<ContourLabelStyleProps, 'label'>;
|
|
48
|
+
type ParsedContourStyleProps = Required<ContourStyleProps>;
|
|
49
|
+
type ContourOptions = DisplayObjectConfig<ContourStyleProps>;
|
|
49
50
|
|
|
50
|
-
export class
|
|
51
|
-
static defaultStyleProps: Partial<
|
|
51
|
+
export class Contour extends BaseShape<ContourStyleProps> {
|
|
52
|
+
static defaultStyleProps: Partial<ContourStyleProps> = {
|
|
52
53
|
label: true,
|
|
53
54
|
labelPlacement: 'bottom',
|
|
54
|
-
|
|
55
|
+
labelCloseToPath: true,
|
|
55
56
|
labelAutoRotate: true,
|
|
56
57
|
labelOffsetX: 0,
|
|
57
58
|
labelOffsetY: 0,
|
|
58
59
|
};
|
|
59
60
|
|
|
60
|
-
constructor(options:
|
|
61
|
-
super(deepMix({}, { style:
|
|
61
|
+
constructor(options: ContourOptions) {
|
|
62
|
+
super(deepMix({}, { style: Contour.defaultStyleProps }, options));
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
protected getLabelStyle(attributes:
|
|
65
|
+
protected getLabelStyle(attributes: ParsedContourStyleProps): LabelStyleProps | false {
|
|
65
66
|
if (!attributes.label || !attributes.path || attributes.path.length === 0) return false;
|
|
66
|
-
const { maxWidth, offsetX, offsetY, autoRotate, placement,
|
|
67
|
-
Required<
|
|
67
|
+
const { maxWidth, offsetX, offsetY, autoRotate, placement, closeToPath, ...labelStyle } = subStyleProps<
|
|
68
|
+
Required<ContourLabelStyleProps>
|
|
68
69
|
>(this.getGraphicStyle(attributes), 'label');
|
|
69
70
|
|
|
70
|
-
const
|
|
71
|
-
const
|
|
71
|
+
const key = this.shapeMap.key;
|
|
72
|
+
const keyBounds = key?.getRenderBounds();
|
|
72
73
|
|
|
73
74
|
return Object.assign(
|
|
74
|
-
getPolygonTextStyleByPlacement(
|
|
75
|
-
|
|
76
|
-
placement,
|
|
77
|
-
offsetX,
|
|
78
|
-
offsetY,
|
|
79
|
-
closeToHull,
|
|
80
|
-
attributes.path,
|
|
81
|
-
autoRotate,
|
|
82
|
-
),
|
|
83
|
-
{ wordWrapWidth: getWordWrapWidthByBox(contourBounds, maxWidth) },
|
|
75
|
+
getPolygonTextStyleByPlacement(keyBounds, placement, offsetX, offsetY, closeToPath, attributes.path, autoRotate),
|
|
76
|
+
{ wordWrapWidth: getWordWrapWidthByBox(keyBounds, maxWidth) },
|
|
84
77
|
labelStyle,
|
|
85
78
|
);
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
protected
|
|
81
|
+
protected getKeyStyle(attributes: ParsedContourStyleProps): PathStyleProps {
|
|
89
82
|
return this.getGraphicStyle(attributes);
|
|
90
83
|
}
|
|
91
84
|
|
|
92
|
-
public render(attributes:
|
|
93
|
-
this.upsert('
|
|
85
|
+
public render(attributes: ParsedContourStyleProps, container: Group): void {
|
|
86
|
+
this.upsert('key', Path, this.getKeyStyle(attributes), container);
|
|
94
87
|
this.upsert('label', Label, this.getLabelStyle(attributes), container);
|
|
95
88
|
}
|
|
96
89
|
}
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
export { Badge } from './badge';
|
|
8
8
|
export { BaseShape } from './base-shape';
|
|
9
|
+
export { Contour } from './contour';
|
|
9
10
|
export { Icon } from './icon';
|
|
10
11
|
export { Label } from './label';
|
|
11
12
|
|
|
12
13
|
export type { BadgeStyleProps } from './badge';
|
|
13
14
|
export type { BaseShapeStyleProps } from './base-shape';
|
|
15
|
+
export type { ContourStyleProps } from './contour';
|
|
14
16
|
export type { IconStyleProps } from './icon';
|
|
15
17
|
export type { LabelStyleProps } from './label';
|
package/src/exports.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export {
|
|
2
|
+
BaseBehavior,
|
|
3
|
+
BrushSelect,
|
|
4
|
+
ClickElement,
|
|
5
|
+
CollapseExpand,
|
|
6
|
+
CreateEdge,
|
|
7
|
+
DragCanvas,
|
|
8
|
+
DragElement,
|
|
9
|
+
DragElementForce,
|
|
10
|
+
FocusElement,
|
|
11
|
+
HoverElement,
|
|
12
|
+
LassoSelect,
|
|
13
|
+
ZoomCanvas,
|
|
14
|
+
} from './behaviors';
|
|
7
15
|
export {
|
|
8
16
|
CanvasEvent,
|
|
9
17
|
ComboEvent,
|
|
@@ -30,14 +38,80 @@ export {
|
|
|
30
38
|
Triangle,
|
|
31
39
|
} from './elements/nodes';
|
|
32
40
|
export { BaseShape } from './elements/shapes';
|
|
33
|
-
export {
|
|
41
|
+
export {
|
|
42
|
+
AntVDagreLayout,
|
|
43
|
+
CircularLayout,
|
|
44
|
+
ComboCombinedLayout,
|
|
45
|
+
ConcentricLayout,
|
|
46
|
+
D3Force3DLayout,
|
|
47
|
+
D3ForceLayout,
|
|
48
|
+
DagreLayout,
|
|
49
|
+
ForceAtlas2Layout,
|
|
50
|
+
ForceLayout,
|
|
51
|
+
FruchtermanLayout,
|
|
52
|
+
GridLayout,
|
|
53
|
+
MDSLayout,
|
|
54
|
+
RadialLayout,
|
|
55
|
+
RandomLayout,
|
|
56
|
+
compactBox,
|
|
57
|
+
dendrogram,
|
|
58
|
+
indented,
|
|
59
|
+
mindmap,
|
|
60
|
+
} from './layouts';
|
|
61
|
+
export {
|
|
62
|
+
BasePlugin,
|
|
63
|
+
BubbleSets,
|
|
64
|
+
CameraSetting,
|
|
65
|
+
Contextmenu,
|
|
66
|
+
GridLine,
|
|
67
|
+
History,
|
|
68
|
+
Hull,
|
|
69
|
+
Legend,
|
|
70
|
+
Timebar,
|
|
71
|
+
Toolbar,
|
|
72
|
+
Tooltip,
|
|
73
|
+
Watermark,
|
|
74
|
+
} from './plugins';
|
|
34
75
|
export { getExtension, getExtensions, register } from './registry';
|
|
35
76
|
export { Graph } from './runtime/graph';
|
|
36
77
|
export { BaseTransform } from './transforms';
|
|
78
|
+
export { idOf } from './utils/id';
|
|
79
|
+
export { omitStyleProps, subStyleProps } from './utils/prefix';
|
|
37
80
|
export { Shortcut } from './utils/shortcut';
|
|
38
81
|
export { parseSize } from './utils/size';
|
|
82
|
+
export { treeToGraphData } from './utils/tree';
|
|
39
83
|
|
|
40
|
-
export type {
|
|
84
|
+
export type { BaseStyleProps } from '@antv/g';
|
|
85
|
+
export type {
|
|
86
|
+
AntVDagreLayoutOptions,
|
|
87
|
+
CircularLayoutOptions,
|
|
88
|
+
ComboCombinedLayoutOptions,
|
|
89
|
+
ConcentricLayoutOptions,
|
|
90
|
+
D3Force3DLayoutOptions,
|
|
91
|
+
D3ForceLayoutOptions,
|
|
92
|
+
DagreLayoutOptions,
|
|
93
|
+
ForceAtlas2LayoutOptions,
|
|
94
|
+
ForceLayoutOptions,
|
|
95
|
+
FruchtermanLayoutOptions,
|
|
96
|
+
GridLayoutOptions,
|
|
97
|
+
MDSLayoutOptions,
|
|
98
|
+
RadialLayoutOptions,
|
|
99
|
+
RandomLayoutOptions,
|
|
100
|
+
} from '@antv/layout';
|
|
101
|
+
export type {
|
|
102
|
+
BaseBehaviorOptions,
|
|
103
|
+
BrushSelectOptions,
|
|
104
|
+
ClickElementOptions,
|
|
105
|
+
CollapseExpandOptions,
|
|
106
|
+
CreateEdgeOptions,
|
|
107
|
+
DragCanvasOptions,
|
|
108
|
+
DragElementForceOptions,
|
|
109
|
+
DragElementOptions,
|
|
110
|
+
FocusElementOptions,
|
|
111
|
+
HoverElementOptions,
|
|
112
|
+
LassoSelectOptions,
|
|
113
|
+
ZoomCanvasOptions,
|
|
114
|
+
} from './behaviors';
|
|
41
115
|
export type { BaseComboStyleProps, CircleComboStyleProps, RectComboStyleProps } from './elements/combos';
|
|
42
116
|
export type {
|
|
43
117
|
BaseEdgeStyleProps,
|
|
@@ -61,7 +135,20 @@ export type {
|
|
|
61
135
|
TriangleStyleProps,
|
|
62
136
|
} from './elements/nodes';
|
|
63
137
|
export type { BaseShapeStyleProps } from './elements/shapes';
|
|
64
|
-
export type {
|
|
138
|
+
export type {
|
|
139
|
+
BasePluginOptions,
|
|
140
|
+
BubbleSetsOptions,
|
|
141
|
+
CameraSettingOptions,
|
|
142
|
+
ContextmenuOptions,
|
|
143
|
+
GridLineOptions,
|
|
144
|
+
HistoryOptions,
|
|
145
|
+
HullOptions,
|
|
146
|
+
LegendOptions,
|
|
147
|
+
TimebarOptions,
|
|
148
|
+
ToolbarOptions,
|
|
149
|
+
TooltipOptions,
|
|
150
|
+
WatermarkOptions,
|
|
151
|
+
} from './plugins';
|
|
65
152
|
export type { RuntimeContext } from './runtime/types';
|
|
66
153
|
export type {
|
|
67
154
|
BehaviorOptions,
|
|
@@ -70,8 +157,8 @@ export type {
|
|
|
70
157
|
ComboOptions,
|
|
71
158
|
EdgeData,
|
|
72
159
|
EdgeOptions,
|
|
73
|
-
G6Spec,
|
|
74
160
|
GraphData,
|
|
161
|
+
GraphOptions,
|
|
75
162
|
LayoutOptions,
|
|
76
163
|
NodeData,
|
|
77
164
|
NodeOptions,
|
|
@@ -81,9 +168,13 @@ export type {
|
|
|
81
168
|
} from './spec';
|
|
82
169
|
export type { BaseTransformOptions } from './transforms';
|
|
83
170
|
export type {
|
|
171
|
+
CardinalPlacement,
|
|
84
172
|
Combo,
|
|
173
|
+
CornerPlacement,
|
|
174
|
+
DirectionalPlacement,
|
|
85
175
|
Edge,
|
|
86
176
|
Element,
|
|
177
|
+
ElementType,
|
|
87
178
|
IAnimateEvent,
|
|
88
179
|
ID,
|
|
89
180
|
IDragEvent,
|
|
@@ -95,23 +186,12 @@ export type {
|
|
|
95
186
|
IViewportEvent,
|
|
96
187
|
IWheelEvent,
|
|
97
188
|
Node,
|
|
189
|
+
Placement,
|
|
98
190
|
Point,
|
|
191
|
+
RelativePlacement,
|
|
192
|
+
State,
|
|
99
193
|
Vector2,
|
|
100
194
|
Vector3,
|
|
101
195
|
ViewportAnimationEffectTiming,
|
|
102
196
|
} from './types';
|
|
103
197
|
export type { ShortcutKey } from './utils/shortcut';
|
|
104
|
-
|
|
105
|
-
const Utils = {
|
|
106
|
-
idOf,
|
|
107
|
-
treeToGraphData,
|
|
108
|
-
subStyleProps,
|
|
109
|
-
omitStyleProps,
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const Theme = {
|
|
113
|
-
dark,
|
|
114
|
-
light,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export { Theme, Utils };
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import type { PathArray } from '@antv/util';
|
|
2
|
+
import { deepMix, isEqual, isFunction } from '@antv/util';
|
|
3
|
+
import type { IBubbleSetOptions, ILine, IRectangle } from 'bubblesets-js';
|
|
4
|
+
import { BubbleSets as BubbleSetsJS, Line, Rectangle, defaultOptions } from 'bubblesets-js';
|
|
5
|
+
import { GraphEvent } from '../constants';
|
|
6
|
+
import type { ContourStyleProps } from '../elements/shapes';
|
|
7
|
+
import { Contour } from '../elements/shapes';
|
|
8
|
+
import type { Graph } from '../runtime/graph';
|
|
9
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
10
|
+
import type { CallableValue, ID } from '../types';
|
|
11
|
+
import { getBBoxHeight, getBBoxWidth } from '../utils/bbox';
|
|
12
|
+
import { arrayDiff } from '../utils/diff';
|
|
13
|
+
import type { ElementLifeCycleEvent } from '../utils/event';
|
|
14
|
+
import { idOf } from '../utils/id';
|
|
15
|
+
import { getClosedSpline } from '../utils/path';
|
|
16
|
+
import { parsePoint } from '../utils/point';
|
|
17
|
+
import type { BasePluginOptions } from './base-plugin';
|
|
18
|
+
import { BasePlugin } from './base-plugin';
|
|
19
|
+
|
|
20
|
+
export interface BubbleSetsOptions extends BasePluginOptions, IBubbleSetOptions, ContourStyleProps {
|
|
21
|
+
/**
|
|
22
|
+
* <zh/> 成员元素,包括节点和边
|
|
23
|
+
*
|
|
24
|
+
* <en/> Member elements, including nodes and edges
|
|
25
|
+
*/
|
|
26
|
+
members: ID[];
|
|
27
|
+
/**
|
|
28
|
+
* <zh/> 需要避开的元素,在绘制轮廓时不会包含这些元素。目前支持设置节点
|
|
29
|
+
*
|
|
30
|
+
* <en/> Elements to avoid, these elements will not be included when drawing the contour, currently only nodes are supported
|
|
31
|
+
*/
|
|
32
|
+
avoidMembers?: ID[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class BubbleSets extends BasePlugin<BubbleSetsOptions> {
|
|
36
|
+
private shape!: Contour;
|
|
37
|
+
|
|
38
|
+
private bubbleSets!: BubbleSetsJS;
|
|
39
|
+
|
|
40
|
+
private path!: PathArray;
|
|
41
|
+
|
|
42
|
+
private members: Map<ID, IRectangle | ILine> = new Map();
|
|
43
|
+
|
|
44
|
+
private avoidMembers: Map<ID, IRectangle | ILine> = new Map();
|
|
45
|
+
|
|
46
|
+
private bubbleSetOptions: IBubbleSetOptions = {};
|
|
47
|
+
|
|
48
|
+
static defaultOptions: Partial<BubbleSetsOptions> = {
|
|
49
|
+
members: [],
|
|
50
|
+
avoidMembers: [],
|
|
51
|
+
/** shape style */
|
|
52
|
+
fill: 'lightblue',
|
|
53
|
+
stroke: 'blue',
|
|
54
|
+
opacity: 0.2,
|
|
55
|
+
/** bubbleSetJS config */
|
|
56
|
+
...defaultOptions,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
constructor(context: RuntimeContext, options: BubbleSetsOptions) {
|
|
60
|
+
super(context, deepMix({}, BubbleSets.defaultOptions, options));
|
|
61
|
+
|
|
62
|
+
this.bindEvents();
|
|
63
|
+
|
|
64
|
+
this.bubbleSets = new BubbleSetsJS(this.options);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private bindEvents() {
|
|
68
|
+
this.context.graph.on(GraphEvent.AFTER_RENDER, this.drawBubbleSets);
|
|
69
|
+
this.context.graph.on(GraphEvent.AFTER_ELEMENT_UPDATE, this.updateBubbleSetsPath);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private init() {
|
|
73
|
+
this.bubbleSets = new BubbleSetsJS(this.options);
|
|
74
|
+
this.members = new Map();
|
|
75
|
+
this.avoidMembers = new Map();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private parseOptions() {
|
|
79
|
+
const { type, key, members, avoidMembers, ...rest } = this.options;
|
|
80
|
+
const res = Object.keys(rest).reduce(
|
|
81
|
+
(acc: { style: ContourStyleProps; bubbleSetOptions: IBubbleSetOptions }, key: string) => {
|
|
82
|
+
if (key in defaultOptions) {
|
|
83
|
+
acc.bubbleSetOptions[key as keyof IBubbleSetOptions] = rest[key];
|
|
84
|
+
} else {
|
|
85
|
+
acc.style[key as keyof ContourStyleProps] = rest[key];
|
|
86
|
+
}
|
|
87
|
+
return acc;
|
|
88
|
+
},
|
|
89
|
+
{ style: {}, bubbleSetOptions: {} },
|
|
90
|
+
);
|
|
91
|
+
return { type, key, members, avoidMembers, ...res };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private drawBubbleSets = () => {
|
|
95
|
+
const { style, bubbleSetOptions } = this.parseOptions();
|
|
96
|
+
if (!isEqual(this.bubbleSetOptions, bubbleSetOptions)) this.init();
|
|
97
|
+
this.bubbleSetOptions = { ...bubbleSetOptions };
|
|
98
|
+
|
|
99
|
+
const finalStyle = { ...style, path: this.getPath() };
|
|
100
|
+
if (!this.shape) {
|
|
101
|
+
this.shape = new Contour({ style: finalStyle });
|
|
102
|
+
this.context.canvas.appendChild(this.shape);
|
|
103
|
+
} else {
|
|
104
|
+
this.shape.update(finalStyle);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
private updateBubbleSetsPath = (event: ElementLifeCycleEvent) => {
|
|
109
|
+
if (!this.shape) return;
|
|
110
|
+
const id = idOf(event.data);
|
|
111
|
+
if (![...this.options.members, ...this.options.avoidMembers].includes(id)) return;
|
|
112
|
+
this.shape.update({ ...this.parseOptions().style, path: this.getPath(id) });
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
private getPath = (forceUpdateId?: ID): PathArray => {
|
|
116
|
+
const { graph } = this.context;
|
|
117
|
+
|
|
118
|
+
const currMembers = this.options.members;
|
|
119
|
+
const prevMembers = [...this.members.keys()];
|
|
120
|
+
const currAvoidMembers = this.options.avoidMembers;
|
|
121
|
+
const prevAvoidMembers = [...this.avoidMembers.keys()];
|
|
122
|
+
|
|
123
|
+
if (!forceUpdateId && isEqual(currMembers, prevMembers) && isEqual(currAvoidMembers, prevAvoidMembers))
|
|
124
|
+
return this.path;
|
|
125
|
+
|
|
126
|
+
const { enter: membersToEnter = [], exit: membersToExit = [] } = arrayDiff(prevMembers, currMembers, (d) => d);
|
|
127
|
+
const { enter: avoidMembersToEnter = [], exit: avoidMembersToExit = [] } = arrayDiff(
|
|
128
|
+
prevAvoidMembers,
|
|
129
|
+
currAvoidMembers,
|
|
130
|
+
(d) => d,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
if (forceUpdateId) {
|
|
134
|
+
membersToExit.push(forceUpdateId);
|
|
135
|
+
membersToEnter.push(forceUpdateId);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const updateBubbleSets = (ids: ID[], isEntering: boolean, isMember: boolean) => {
|
|
139
|
+
ids.forEach((id) => {
|
|
140
|
+
const members = isMember ? this.members : this.avoidMembers;
|
|
141
|
+
const pushMember = isMember ? 'pushMember' : 'pushNonMember';
|
|
142
|
+
const removeMember = isMember ? 'removeMember' : 'removeNonMember';
|
|
143
|
+
if (isEntering) {
|
|
144
|
+
let area: IRectangle | ILine;
|
|
145
|
+
if (graph.getElementType(id) === 'edge') {
|
|
146
|
+
[area] = convertToLine(graph, id);
|
|
147
|
+
this.bubbleSets.pushEdge(area);
|
|
148
|
+
} else {
|
|
149
|
+
[area] = convertToRectangle(graph, id);
|
|
150
|
+
this.bubbleSets[pushMember](area);
|
|
151
|
+
}
|
|
152
|
+
members.set(id, area);
|
|
153
|
+
} else {
|
|
154
|
+
const area = members.get(id);
|
|
155
|
+
if (area) {
|
|
156
|
+
if (graph.getElementType(id) === 'edge') {
|
|
157
|
+
this.bubbleSets.removeEdge(area as ILine);
|
|
158
|
+
} else {
|
|
159
|
+
this.bubbleSets[removeMember](area as IRectangle);
|
|
160
|
+
}
|
|
161
|
+
members.delete(id);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
updateBubbleSets(membersToExit, false, true);
|
|
168
|
+
updateBubbleSets(membersToEnter, true, true);
|
|
169
|
+
updateBubbleSets(avoidMembersToExit, false, false);
|
|
170
|
+
updateBubbleSets(avoidMembersToEnter, true, false);
|
|
171
|
+
|
|
172
|
+
const pointPath = this.bubbleSets.compute();
|
|
173
|
+
const cleanPath = pointPath.sample(8).simplify(0).bSplines().simplify(0);
|
|
174
|
+
this.path = getClosedSpline(cleanPath.points.map(parsePoint));
|
|
175
|
+
return this.path;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
public addMember(members: ID | ID[]) {
|
|
179
|
+
const membersToAdd = Array.isArray(members) ? members : [members];
|
|
180
|
+
if (membersToAdd.some((member) => this.options.avoidMembers.includes(member))) {
|
|
181
|
+
this.options.avoidMembers = this.options.avoidMembers.filter((id) => !membersToAdd.includes(id));
|
|
182
|
+
}
|
|
183
|
+
this.options.members = [...new Set([...this.options.members, ...membersToAdd])];
|
|
184
|
+
this.drawBubbleSets();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
public removeMember(members: ID | ID[]) {
|
|
188
|
+
const membersToRemove = Array.isArray(members) ? members : [members];
|
|
189
|
+
this.options.members = this.options.members.filter((id) => !membersToRemove.includes(id));
|
|
190
|
+
this.drawBubbleSets();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public updateMember(members: CallableValue<ID[]>) {
|
|
194
|
+
this.options.members = isFunction(members) ? members(this.options.members) : members;
|
|
195
|
+
this.drawBubbleSets();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public getMember() {
|
|
199
|
+
return this.options.members;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public addAvoidMember(avoidMembers: ID | ID[]) {
|
|
203
|
+
const avoidMembersToAdd = Array.isArray(avoidMembers) ? avoidMembers : [avoidMembers];
|
|
204
|
+
if (avoidMembersToAdd.some((AvoidMember) => this.options.members.includes(AvoidMember))) {
|
|
205
|
+
this.options.members = this.options.members.filter((id) => !avoidMembersToAdd.includes(id));
|
|
206
|
+
}
|
|
207
|
+
this.options.avoidMembers = [...new Set([...this.options.avoidMembers, ...avoidMembersToAdd])];
|
|
208
|
+
this.drawBubbleSets();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public removeAvoidMember(avoidMembers: ID | ID[]) {
|
|
212
|
+
const avoidMembersToRemove = Array.isArray(avoidMembers) ? avoidMembers : [avoidMembers];
|
|
213
|
+
if (this.options.avoidMembers.some((member) => avoidMembersToRemove.includes(member))) {
|
|
214
|
+
this.options.avoidMembers = this.options.avoidMembers.filter((id) => !avoidMembersToRemove.includes(id));
|
|
215
|
+
this.drawBubbleSets();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
public updateAvoidMember(avoidMembers: ID | ID[]) {
|
|
220
|
+
this.options.avoidMembers = Array.isArray(avoidMembers) ? avoidMembers : [avoidMembers];
|
|
221
|
+
this.drawBubbleSets();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public getAvoidMember() {
|
|
225
|
+
return this.options.avoidMembers;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public destroy(): void {
|
|
229
|
+
this.context.graph.off(GraphEvent.AFTER_RENDER, this.drawBubbleSets);
|
|
230
|
+
this.context.graph.off(GraphEvent.AFTER_ELEMENT_UPDATE, this.updateBubbleSetsPath);
|
|
231
|
+
this.shape.destroy();
|
|
232
|
+
super.destroy();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* <zh/> 将节点转换为 BubbleSetJS 支持的矩形
|
|
238
|
+
*
|
|
239
|
+
* <en/> Convert nodes to rectangles supported by BubbleSetJS
|
|
240
|
+
* @param graph - <zh/> 图实例 | <en/> graph instance
|
|
241
|
+
* @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
|
|
242
|
+
* @returns <zh/> 矩形数组 | <en/> rectangle array
|
|
243
|
+
*/
|
|
244
|
+
const convertToRectangle = (graph: Graph, ids: ID | ID[]): IRectangle[] => {
|
|
245
|
+
const idArr = Array.isArray(ids) ? ids : [ids];
|
|
246
|
+
return idArr.map((id) => {
|
|
247
|
+
const bbox = graph.getElementRenderBounds(id);
|
|
248
|
+
return new Rectangle(bbox.min[0], bbox.min[1], getBBoxWidth(bbox), getBBoxHeight(bbox));
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* <zh/> 将边转换为 BubbleSetJS 支持的线
|
|
254
|
+
*
|
|
255
|
+
* <en/> Convert edges to lines supported by BubbleSetJS
|
|
256
|
+
* @param graph - <zh/> 图实例 | <en/> graph instance
|
|
257
|
+
* @param ids - <zh/> 元素 ID 数组 | <en/> element ID array
|
|
258
|
+
* @returns <zh/> 线数组 | <en/> line array
|
|
259
|
+
*/
|
|
260
|
+
const convertToLine = (graph: Graph, ids: ID | ID[]): ILine[] => {
|
|
261
|
+
const idArr = Array.isArray(ids) ? ids : [ids];
|
|
262
|
+
return idArr.map((id) => {
|
|
263
|
+
const data = graph.getEdgeData(id);
|
|
264
|
+
const source = graph.getElementPosition(data.source);
|
|
265
|
+
const target = graph.getElementPosition(data.target);
|
|
266
|
+
return Line.from({ x1: source[0], y1: source[1], x2: target[0], y2: target[1] });
|
|
267
|
+
});
|
|
268
|
+
};
|