@antv/g6 5.0.18 → 5.0.20
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/drag-canvas.d.ts +9 -0
- package/dist/lib/behaviors/drag-element.d.ts +0 -1
- package/dist/lib/behaviors/hover-activate.d.ts +14 -1
- package/dist/lib/behaviors/scroll-canvas.d.ts +9 -0
- package/dist/lib/elements/combos/circle.d.ts +1 -1
- package/dist/lib/elements/edges/cubic-radial.d.ts +24 -0
- package/dist/lib/elements/edges/index.d.ts +2 -0
- package/dist/lib/elements/effect.d.ts +7 -30
- package/dist/lib/elements/nodes/base-node.d.ts +2 -1
- package/dist/lib/elements/nodes/circle.d.ts +1 -1
- package/dist/lib/elements/nodes/ellipse.d.ts +1 -1
- package/dist/lib/elements/shapes/base-shape.d.ts +1 -1
- package/dist/lib/elements/shapes/polygon.d.ts +1 -1
- package/dist/lib/exports.d.ts +6 -5
- package/dist/lib/runtime/data.d.ts +1 -0
- package/dist/lib/runtime/element.d.ts +1 -0
- package/dist/lib/runtime/graph.d.ts +2 -0
- package/dist/lib/runtime/layout.d.ts +1 -0
- package/dist/lib/transforms/base-transform.d.ts +1 -0
- package/dist/lib/transforms/index.d.ts +3 -0
- package/dist/lib/transforms/position-radial-labels.d.ts +27 -0
- package/dist/lib/types/element.d.ts +2 -1
- package/dist/lib/utils/data.d.ts +14 -0
- package/dist/lib/utils/diff.d.ts +2 -1
- package/dist/lib/utils/point.d.ts +17 -5
- package/dist/lib/utils/position.d.ts +8 -0
- package/dist/lib/utils/relation.d.ts +6 -4
- package/dist/lib/utils/vector.d.ts +8 -0
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/drag-canvas.d.ts +9 -0
- package/esm/behaviors/drag-canvas.js +28 -3
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +0 -1
- package/esm/behaviors/drag-element.js +14 -7
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/hover-activate.d.ts +14 -1
- package/esm/behaviors/hover-activate.js +3 -2
- package/esm/behaviors/hover-activate.js.map +1 -1
- package/esm/behaviors/scroll-canvas.d.ts +9 -0
- package/esm/behaviors/scroll-canvas.js +31 -4
- package/esm/behaviors/scroll-canvas.js.map +1 -1
- package/esm/elements/combos/base-combo.js +6 -12
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/combos/circle.d.ts +1 -1
- package/esm/elements/combos/circle.js +2 -2
- package/esm/elements/combos/circle.js.map +1 -1
- package/esm/elements/edges/base-edge.js +18 -29
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/edges/cubic-radial.d.ts +24 -0
- package/esm/elements/edges/cubic-radial.js +52 -0
- package/esm/elements/edges/cubic-radial.js.map +1 -0
- package/esm/elements/edges/index.d.ts +2 -0
- package/esm/elements/edges/index.js +1 -0
- package/esm/elements/edges/index.js.map +1 -1
- package/esm/elements/effect.d.ts +7 -30
- package/esm/elements/effect.js +20 -50
- package/esm/elements/effect.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +2 -1
- package/esm/elements/nodes/base-node.js +24 -31
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/circle.d.ts +1 -1
- package/esm/elements/nodes/circle.js +2 -2
- package/esm/elements/nodes/circle.js.map +1 -1
- package/esm/elements/nodes/ellipse.d.ts +1 -1
- package/esm/elements/nodes/ellipse.js +2 -2
- package/esm/elements/nodes/ellipse.js.map +1 -1
- package/esm/elements/shapes/base-shape.d.ts +1 -1
- package/esm/elements/shapes/base-shape.js +1 -1
- package/esm/elements/shapes/polygon.d.ts +1 -1
- package/esm/elements/shapes/polygon.js +2 -2
- package/esm/elements/shapes/polygon.js.map +1 -1
- package/esm/exports.d.ts +6 -5
- package/esm/exports.js +4 -3
- package/esm/exports.js.map +1 -1
- package/esm/plugins/tooltip.js +5 -2
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/registry/build-in.js +4 -2
- package/esm/registry/build-in.js.map +1 -1
- package/esm/runtime/animation.js +12 -10
- package/esm/runtime/animation.js.map +1 -1
- package/esm/runtime/data.d.ts +1 -0
- package/esm/runtime/data.js +21 -13
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +1 -0
- package/esm/runtime/element.js +45 -18
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +2 -0
- package/esm/runtime/graph.js +44 -22
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.d.ts +1 -0
- package/esm/runtime/layout.js +5 -0
- package/esm/runtime/layout.js.map +1 -1
- package/esm/transforms/base-transform.d.ts +1 -0
- package/esm/transforms/base-transform.js +1 -0
- package/esm/transforms/base-transform.js.map +1 -1
- package/esm/transforms/collapse-expand-combo.js +3 -0
- package/esm/transforms/collapse-expand-combo.js.map +1 -1
- package/esm/transforms/collapse-expand-node.js +2 -0
- package/esm/transforms/collapse-expand-node.js.map +1 -1
- package/esm/transforms/index.d.ts +3 -0
- package/esm/transforms/index.js +1 -0
- package/esm/transforms/index.js.map +1 -1
- package/esm/transforms/position-radial-labels.d.ts +27 -0
- package/esm/transforms/position-radial-labels.js +50 -0
- package/esm/transforms/position-radial-labels.js.map +1 -0
- package/esm/types/element.d.ts +2 -1
- package/esm/utils/data.d.ts +14 -0
- package/esm/utils/data.js +39 -0
- package/esm/utils/data.js.map +1 -1
- package/esm/utils/diff.d.ts +2 -1
- package/esm/utils/diff.js +3 -2
- package/esm/utils/diff.js.map +1 -1
- package/esm/utils/point.d.ts +17 -5
- package/esm/utils/point.js +24 -8
- package/esm/utils/point.js.map +1 -1
- package/esm/utils/position.d.ts +8 -0
- package/esm/utils/position.js +11 -0
- package/esm/utils/position.js.map +1 -1
- package/esm/utils/relation.d.ts +6 -4
- package/esm/utils/relation.js +10 -8
- package/esm/utils/relation.js.map +1 -1
- package/esm/utils/vector.d.ts +8 -0
- package/esm/utils/vector.js +13 -0
- package/esm/utils/vector.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/drag-canvas.d.ts +9 -0
- package/lib/behaviors/drag-canvas.js +27 -2
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +0 -1
- package/lib/behaviors/drag-element.js +14 -7
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/hover-activate.d.ts +14 -1
- package/lib/behaviors/hover-activate.js +3 -2
- package/lib/behaviors/hover-activate.js.map +1 -1
- package/lib/behaviors/scroll-canvas.d.ts +9 -0
- package/lib/behaviors/scroll-canvas.js +31 -4
- package/lib/behaviors/scroll-canvas.js.map +1 -1
- package/lib/elements/combos/base-combo.js +5 -11
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/combos/circle.d.ts +1 -1
- package/lib/elements/combos/circle.js +2 -2
- package/lib/elements/combos/circle.js.map +1 -1
- package/lib/elements/edges/base-edge.js +18 -29
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/edges/cubic-radial.d.ts +24 -0
- package/lib/elements/edges/cubic-radial.js +56 -0
- package/lib/elements/edges/cubic-radial.js.map +1 -0
- package/lib/elements/edges/index.d.ts +2 -0
- package/lib/elements/edges/index.js +3 -1
- package/lib/elements/edges/index.js.map +1 -1
- package/lib/elements/effect.d.ts +7 -30
- package/lib/elements/effect.js +20 -50
- package/lib/elements/effect.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +2 -1
- package/lib/elements/nodes/base-node.js +24 -31
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/circle.d.ts +1 -1
- package/lib/elements/nodes/circle.js +2 -2
- package/lib/elements/nodes/circle.js.map +1 -1
- package/lib/elements/nodes/ellipse.d.ts +1 -1
- package/lib/elements/nodes/ellipse.js +2 -2
- package/lib/elements/nodes/ellipse.js.map +1 -1
- package/lib/elements/shapes/base-shape.d.ts +1 -1
- package/lib/elements/shapes/base-shape.js +1 -1
- package/lib/elements/shapes/polygon.d.ts +1 -1
- package/lib/elements/shapes/polygon.js +2 -2
- package/lib/elements/shapes/polygon.js.map +1 -1
- package/lib/exports.d.ts +6 -5
- package/lib/exports.js +12 -6
- package/lib/exports.js.map +1 -1
- package/lib/plugins/tooltip.js +5 -2
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/registry/build-in.js +2 -0
- package/lib/registry/build-in.js.map +1 -1
- package/lib/runtime/animation.js +12 -10
- package/lib/runtime/animation.js.map +1 -1
- package/lib/runtime/data.d.ts +1 -0
- package/lib/runtime/data.js +19 -11
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +1 -0
- package/lib/runtime/element.js +45 -18
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +2 -0
- package/lib/runtime/graph.js +44 -22
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.d.ts +1 -0
- package/lib/runtime/layout.js +5 -0
- package/lib/runtime/layout.js.map +1 -1
- package/lib/transforms/base-transform.d.ts +1 -0
- package/lib/transforms/base-transform.js +1 -0
- package/lib/transforms/base-transform.js.map +1 -1
- package/lib/transforms/collapse-expand-combo.js +3 -0
- package/lib/transforms/collapse-expand-combo.js.map +1 -1
- package/lib/transforms/collapse-expand-node.js +2 -0
- package/lib/transforms/collapse-expand-node.js.map +1 -1
- package/lib/transforms/index.d.ts +3 -0
- package/lib/transforms/index.js +3 -1
- package/lib/transforms/index.js.map +1 -1
- package/lib/transforms/position-radial-labels.d.ts +27 -0
- package/lib/transforms/position-radial-labels.js +54 -0
- package/lib/transforms/position-radial-labels.js.map +1 -0
- package/lib/types/element.d.ts +2 -1
- package/lib/utils/data.d.ts +14 -0
- package/lib/utils/data.js +40 -0
- package/lib/utils/data.js.map +1 -1
- package/lib/utils/diff.d.ts +2 -1
- package/lib/utils/diff.js +3 -2
- package/lib/utils/diff.js.map +1 -1
- package/lib/utils/point.d.ts +17 -5
- package/lib/utils/point.js +25 -8
- package/lib/utils/point.js.map +1 -1
- package/lib/utils/position.d.ts +8 -0
- package/lib/utils/position.js +12 -0
- package/lib/utils/position.js.map +1 -1
- package/lib/utils/relation.d.ts +6 -4
- package/lib/utils/relation.js +10 -8
- package/lib/utils/relation.js.map +1 -1
- package/lib/utils/vector.d.ts +8 -0
- package/lib/utils/vector.js +14 -0
- package/lib/utils/vector.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/src/behaviors/drag-canvas.ts +42 -3
- package/src/behaviors/drag-element.ts +17 -7
- package/src/behaviors/hover-activate.ts +17 -3
- package/src/behaviors/scroll-canvas.ts +45 -4
- package/src/elements/combos/base-combo.ts +5 -4
- package/src/elements/combos/circle.ts +2 -2
- package/src/elements/edges/base-edge.ts +14 -11
- package/src/elements/edges/cubic-radial.ts +77 -0
- package/src/elements/edges/index.ts +2 -0
- package/src/elements/effect.ts +20 -54
- package/src/elements/nodes/base-node.ts +24 -18
- package/src/elements/nodes/circle.ts +2 -2
- package/src/elements/nodes/ellipse.ts +2 -2
- package/src/elements/shapes/base-shape.ts +1 -1
- package/src/elements/shapes/polygon.ts +2 -2
- package/src/exports.ts +18 -7
- package/src/plugins/tooltip.ts +4 -2
- package/src/registry/build-in.ts +4 -0
- package/src/runtime/animation.ts +16 -11
- package/src/runtime/data.ts +20 -13
- package/src/runtime/element.ts +44 -18
- package/src/runtime/graph.ts +52 -22
- package/src/runtime/layout.ts +7 -0
- package/src/transforms/base-transform.ts +2 -0
- package/src/transforms/collapse-expand-combo.ts +2 -0
- package/src/transforms/collapse-expand-node.ts +3 -0
- package/src/transforms/index.ts +3 -0
- package/src/transforms/position-radial-labels.ts +76 -0
- package/src/types/element.ts +2 -1
- package/src/utils/data.ts +49 -0
- package/src/utils/diff.ts +8 -2
- package/src/utils/point.ts +25 -7
- package/src/utils/position.ts +12 -0
- package/src/utils/relation.ts +22 -9
- package/src/utils/vector.ts +13 -0
- package/src/version.ts +1 -1
|
@@ -35,6 +35,13 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
|
|
|
35
35
|
* @defaultValue `'both'`
|
|
36
36
|
*/
|
|
37
37
|
direction?: 'x' | 'y' | 'both';
|
|
38
|
+
/**
|
|
39
|
+
* <zh/> 可拖拽的视口范围,默认最多可拖拽一屏。可以分别设置上、右、下、左四个方向的范围,每个方向的范围在 [0, Infinity] 之间
|
|
40
|
+
*
|
|
41
|
+
* <en/> The draggable viewport range allows you to drag up to one screen by default. You can set the range for each direction (top, right, bottom, left) individually, with each direction's range between [0, Infinity]
|
|
42
|
+
* @defaultValue 1
|
|
43
|
+
*/
|
|
44
|
+
range?: number | number[];
|
|
38
45
|
/**
|
|
39
46
|
* <zh/> 触发拖拽的方式,默认使用指针按下拖拽
|
|
40
47
|
*
|
|
@@ -94,6 +101,8 @@ export declare class DragCanvas extends BaseBehavior<DragCanvasOptions> {
|
|
|
94
101
|
* @internal
|
|
95
102
|
*/
|
|
96
103
|
protected translate(offset: Vector2, animation?: ViewportAnimationEffectTiming): Promise<void>;
|
|
104
|
+
private clampByDirection;
|
|
105
|
+
private clampByRange;
|
|
97
106
|
private validate;
|
|
98
107
|
private unbindEvents;
|
|
99
108
|
destroy(): void;
|
|
@@ -120,7 +120,6 @@ export declare class DragElement extends BaseBehavior<DragElementOptions> {
|
|
|
120
120
|
private shadowOrigin;
|
|
121
121
|
private hiddenEdges;
|
|
122
122
|
private isDragging;
|
|
123
|
-
private get animation();
|
|
124
123
|
constructor(context: RuntimeContext, options: DragElementOptions);
|
|
125
124
|
/**
|
|
126
125
|
* <zh/> 更新元素拖拽配置
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RuntimeContext } from '../runtime/types';
|
|
2
|
-
import type { IPointerEvent, State } from '../types';
|
|
2
|
+
import type { EdgeDirection, IPointerEvent, State } from '../types';
|
|
3
3
|
import type { BaseBehaviorOptions } from './base-behavior';
|
|
4
4
|
import { BaseBehavior } from './base-behavior';
|
|
5
5
|
/**
|
|
@@ -33,6 +33,19 @@ export interface HoverActivateOptions extends BaseBehaviorOptions {
|
|
|
33
33
|
* @defaultValue 0
|
|
34
34
|
*/
|
|
35
35
|
degree?: number;
|
|
36
|
+
/**
|
|
37
|
+
* <zh/> 指定边的方向
|
|
38
|
+
* - `'both'`: 表示激活当前节点的所有关系
|
|
39
|
+
* - `'in'`: 表示激活当前节点的入边和入节点
|
|
40
|
+
* - `'out'`: 表示激活当前节点的出边和出节点
|
|
41
|
+
*
|
|
42
|
+
* <en/> Specify the direction of the edge
|
|
43
|
+
* - `'both'`: Activate all relationships of the current node
|
|
44
|
+
* - `'in'`: Activate the incoming edges and nodes of the current node
|
|
45
|
+
* - `'out'`: Activate the outgoing edges and nodes of the current node
|
|
46
|
+
* @defaultValue 'both'
|
|
47
|
+
*/
|
|
48
|
+
direction?: EdgeDirection;
|
|
36
49
|
/**
|
|
37
50
|
* <zh/> 激活元素的状态,默认为 `active`
|
|
38
51
|
*
|
|
@@ -39,6 +39,13 @@ export interface ScrollCanvasOptions extends BaseBehaviorOptions {
|
|
|
39
39
|
* - `'y'`: only allow vertical scrolling
|
|
40
40
|
*/
|
|
41
41
|
direction?: 'x' | 'y';
|
|
42
|
+
/**
|
|
43
|
+
* <zh/> 可滚动的视口范围,默认最多可滚动一屏。可以分别设置上、右、下、左四个方向的范围,每个方向的范围在 [0, Infinity] 之间
|
|
44
|
+
*
|
|
45
|
+
* <en/> The scrollable viewport range allows you to scroll up to one screen by default. You can set the range for each direction (top, right, bottom, left) individually, with each direction's range between [0, Infinity]
|
|
46
|
+
* @defaultValue 1
|
|
47
|
+
*/
|
|
48
|
+
range?: number | number[];
|
|
42
49
|
/**
|
|
43
50
|
* <zh/> 滚动灵敏度
|
|
44
51
|
*
|
|
@@ -81,6 +88,8 @@ export declare class ScrollCanvas extends BaseBehavior<ScrollCanvasOptions> {
|
|
|
81
88
|
get graphDom(): import("@antv/g").CanvasLike | null;
|
|
82
89
|
private onWheel;
|
|
83
90
|
private formatDisplacement;
|
|
91
|
+
private clampByDirection;
|
|
92
|
+
private clampByRange;
|
|
84
93
|
private scroll;
|
|
85
94
|
private validate;
|
|
86
95
|
/**
|
|
@@ -21,5 +21,5 @@ export declare class CircleCombo extends BaseCombo<CircleComboStyleProps> {
|
|
|
21
21
|
protected getKeyStyle(attributes: Required<CircleComboStyleProps>): GCircleStyleProps;
|
|
22
22
|
protected getCollapsedKeySize(attributes: Required<CircleComboStyleProps>): STDSize;
|
|
23
23
|
protected getExpandedKeySize(attributes: Required<CircleComboStyleProps>): STDSize;
|
|
24
|
-
getIntersectPoint(point: Point): Point;
|
|
24
|
+
getIntersectPoint(point: Point, useExtendedLine?: boolean): Point;
|
|
25
25
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DisplayObjectConfig } from '@antv/g';
|
|
2
|
+
import type { Point } from '../../types';
|
|
3
|
+
import type { CubicStyleProps } from './cubic';
|
|
4
|
+
import { Cubic } from './cubic';
|
|
5
|
+
/**
|
|
6
|
+
* <zh/> 径向贝塞尔曲线样式配置项
|
|
7
|
+
*
|
|
8
|
+
* <en/> Radial cubic style props
|
|
9
|
+
*/
|
|
10
|
+
export interface CubicRadialStyleProps extends CubicStyleProps {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* <zh/> 径向贝塞尔曲线
|
|
14
|
+
*
|
|
15
|
+
* <en/> Radial cubic edge
|
|
16
|
+
*/
|
|
17
|
+
export declare class CubicRadial extends Cubic {
|
|
18
|
+
static defaultStyleProps: Partial<CubicStyleProps>;
|
|
19
|
+
constructor(options: DisplayObjectConfig<CubicStyleProps>);
|
|
20
|
+
private get ref();
|
|
21
|
+
protected getEndpoints(attributes: Required<CubicStyleProps>): [Point, Point];
|
|
22
|
+
private toRadialCoordinate;
|
|
23
|
+
protected getControlPoints(sourcePoint: Point, targetPoint: Point, curvePosition: [number, number], curveOffset: [number, number]): [Point, Point];
|
|
24
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { BaseEdge } from './base-edge';
|
|
2
2
|
export { Cubic } from './cubic';
|
|
3
3
|
export { CubicHorizontal } from './cubic-horizontal';
|
|
4
|
+
export { CubicRadial } from './cubic-radial';
|
|
4
5
|
export { CubicVertical } from './cubic-vertical';
|
|
5
6
|
export { Line } from './line';
|
|
6
7
|
export { Polyline } from './polyline';
|
|
@@ -8,6 +9,7 @@ export { Quadratic } from './quadratic';
|
|
|
8
9
|
export type { BaseEdgeStyleProps } from './base-edge';
|
|
9
10
|
export type { CubicStyleProps } from './cubic';
|
|
10
11
|
export type { CubicHorizontalStyleProps } from './cubic-horizontal';
|
|
12
|
+
export type { CubicRadialStyleProps } from './cubic-radial';
|
|
11
13
|
export type { CubicVerticalStyleProps } from './cubic-vertical';
|
|
12
14
|
export type { LineStyleProps } from './line';
|
|
13
15
|
export type { PolylineStyleProps } from './polyline';
|
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
import type { Element } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* <zh/>
|
|
3
|
+
* <zh/> 判定给定样式是否与上一次的样式相同
|
|
4
4
|
*
|
|
5
|
-
* <en/>
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
* <zh/>
|
|
10
|
-
*
|
|
11
|
-
* 如果指定了 shapeKey, 则会直接获取该图形的 attributes 作为原始样式属性,通常在 getStyle 函数中获取了包围盒时使用。
|
|
12
|
-
*
|
|
13
|
-
* <en/> Only when getStyle is specified, the function will be called with the current attributes and the new attributes respectively. If they are the same, the function will not be executed.
|
|
14
|
-
*
|
|
15
|
-
* If shapeKey is specified, the attributes of the shape will be directly obtained as the original style attributes, which is usually used when the bounding box of the element is used in the getStyle function.
|
|
16
|
-
* @example
|
|
17
|
-
* <zh/> 仅当 value 发生变化时执行函数
|
|
18
|
-
*
|
|
19
|
-
* <en/> Execute the function only when value changes
|
|
20
|
-
*
|
|
21
|
-
* ```typescript
|
|
22
|
-
* class CustomNode extends BaseNode {
|
|
23
|
-
*
|
|
24
|
-
* @effect((self, attributes) => {
|
|
25
|
-
* const { value } = attributes;
|
|
26
|
-
* return { value }
|
|
27
|
-
* })
|
|
28
|
-
* drawCustomShape(attributes, container) {
|
|
29
|
-
* this.upsert('custom', 'circle', { ...attributes }, container);
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
5
|
+
* <en/> Determine whether the given style are the same as the previous ones
|
|
6
|
+
* @param target - <zh/> 目标元素 | <en/> Target element
|
|
7
|
+
* @param key - <zh/> 缓存 key | <en/> Cache key
|
|
8
|
+
* @param style - <zh/> 样式属性 | <en/> Style attribute
|
|
9
|
+
* @returns <zh/> 是否执行函数 | <en/> Whether to execute the function
|
|
33
10
|
*/
|
|
34
|
-
export declare function effect
|
|
11
|
+
export declare function effect<T extends false | Record<string, any>>(target: Element, key: string, style: T): boolean;
|
|
@@ -179,9 +179,10 @@ export declare abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeSt
|
|
|
179
179
|
/**
|
|
180
180
|
* Get the point on the outer contour of the node that is the intersection with a line starting in the center the ending in the point `p`.
|
|
181
181
|
* @param point - The point to intersect with the node.
|
|
182
|
+
* @param useExtendedLine - Whether to use the extended line.
|
|
182
183
|
* @returns The intersection point.
|
|
183
184
|
*/
|
|
184
|
-
getIntersectPoint(point: Point): Point;
|
|
185
|
+
getIntersectPoint(point: Point, useExtendedLine?: boolean): Point;
|
|
185
186
|
protected drawHaloShape(attributes: Required<S>, container: Group): void;
|
|
186
187
|
protected drawIconShape(attributes: Required<S>, container: Group): void;
|
|
187
188
|
protected drawBadgeShapes(attributes: Required<S>, container: Group): void;
|
|
@@ -22,5 +22,5 @@ export declare class Circle extends BaseNode {
|
|
|
22
22
|
protected drawKeyShape(attributes: Required<CircleStyleProps>, container: Group): GCircle | undefined;
|
|
23
23
|
protected getKeyStyle(attributes: Required<CircleStyleProps>): GCircleStyleProps;
|
|
24
24
|
protected getIconStyle(attributes: Required<CircleStyleProps>): false | IconStyleProps;
|
|
25
|
-
getIntersectPoint(point: Point): Point;
|
|
25
|
+
getIntersectPoint(point: Point, useExtendedLine?: boolean): Point;
|
|
26
26
|
}
|
|
@@ -22,5 +22,5 @@ export declare class Ellipse extends BaseNode {
|
|
|
22
22
|
protected drawKeyShape(attributes: Required<EllipseStyleProps>, container: Group): GEllipse | undefined;
|
|
23
23
|
protected getKeyStyle(attributes: Required<EllipseStyleProps>): GEllipseStyleProps;
|
|
24
24
|
protected getIconStyle(attributes: Required<EllipseStyleProps>): false | IconStyleProps;
|
|
25
|
-
getIntersectPoint(point: Point): Point;
|
|
25
|
+
getIntersectPoint(point: Point, useExtendedLine?: boolean): Point;
|
|
26
26
|
}
|
|
@@ -24,7 +24,7 @@ export declare abstract class BaseShape<StyleProps extends BaseShapeStyleProps>
|
|
|
24
24
|
* <en> create, update or remove shape
|
|
25
25
|
* @param className - <zh> 图形名称 | <en> shape name
|
|
26
26
|
* @param Ctor - <zh> 图形类型 | <en> shape type
|
|
27
|
-
* @param style - <zh>
|
|
27
|
+
* @param style - <zh> 图形样式。若要删除图形,传入 false | <en> shape style. Pass false to remove the shape
|
|
28
28
|
* @param container - <zh> 容器 | <en> container
|
|
29
29
|
* @param hooks - <zh> 钩子函数 | <en> hooks
|
|
30
30
|
* @returns <zh> 图形实例 | <en> shape instance
|
|
@@ -26,5 +26,5 @@ export declare abstract class Polygon<T extends PolygonStyleProps = PolygonStyle
|
|
|
26
26
|
protected drawKeyShape(attributes: Required<T>, container: Group): GPolygon | undefined;
|
|
27
27
|
protected getKeyStyle(attributes: Required<T>): GPolygonStyleProps;
|
|
28
28
|
protected abstract getPoints(attributes: Required<T>): Point[];
|
|
29
|
-
getIntersectPoint(point: Point): Point;
|
|
29
|
+
getIntersectPoint(point: Point, useExtendedLine?: boolean): Point;
|
|
30
30
|
}
|
package/dist/lib/exports.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
export { BaseBehavior, BrushSelect, ClickSelect, CollapseExpand, CreateEdge, DragCanvas, DragElement, DragElementForce, FixElementSize, FocusElement, HoverActivate, LassoSelect, OptimizeViewportTransform, ScrollCanvas, ZoomCanvas, } from './behaviors';
|
|
2
2
|
export { CanvasEvent, ComboEvent, CommonEvent, ContainerEvent, EdgeEvent, ExtensionCategory, GraphEvent, HistoryEvent, NodeEvent, } from './constants';
|
|
3
3
|
export { BaseCombo, CircleCombo, RectCombo } from './elements/combos';
|
|
4
|
-
export { BaseEdge, Cubic, CubicHorizontal, CubicVertical, Line, Polyline, Quadratic } from './elements/edges';
|
|
4
|
+
export { BaseEdge, Cubic, CubicHorizontal, CubicRadial, CubicVertical, Line, Polyline, Quadratic, } from './elements/edges';
|
|
5
5
|
export { effect } from './elements/effect';
|
|
6
6
|
export { BaseNode, Circle, Diamond, Donut, Ellipse, HTML, Hexagon, Image, Rect, Star, Triangle, } from './elements/nodes';
|
|
7
7
|
export { Badge, BaseShape, Icon, Label } from './elements/shapes';
|
|
8
|
-
export { AntVDagreLayout, BaseLayout, CircularLayout, ComboCombinedLayout, ConcentricLayout, D3ForceLayout, DagreLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout,
|
|
8
|
+
export { AntVDagreLayout, BaseLayout, CircularLayout, ComboCombinedLayout, compactBox as CompactBoxLayout, ConcentricLayout, D3ForceLayout, DagreLayout, dendrogram as DendrogramLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, indented as IndentedLayout, MDSLayout, mindmap as MindmapLayout, RadialLayout, RandomLayout, } from './layouts';
|
|
9
9
|
export { BasePlugin, BubbleSets, CameraSetting, Contextmenu, EdgeFilterLens, Fisheye, Fullscreen, GridLine, History, Hull, Legend, Minimap, Snapline, Timebar, Toolbar, Tooltip, Watermark, } from './plugins';
|
|
10
10
|
export { getExtension, getExtensions } from './registry/get';
|
|
11
11
|
export { register } from './registry/register';
|
|
12
12
|
export { Graph } from './runtime/graph';
|
|
13
|
-
export { BaseTransform } from './transforms';
|
|
13
|
+
export { BaseTransform, PositionRadialLabels, ProcessParallelEdges } from './transforms';
|
|
14
14
|
export { isCollapsed } from './utils/collapsibility';
|
|
15
15
|
export { idOf } from './utils/id';
|
|
16
16
|
export { invokeLayoutMethod } from './utils/layout';
|
|
17
|
+
export { positionOf } from './utils/position';
|
|
17
18
|
export { omitStyleProps, subStyleProps } from './utils/prefix';
|
|
18
19
|
export { Shortcut } from './utils/shortcut';
|
|
19
20
|
export { parseSize } from './utils/size';
|
|
@@ -26,7 +27,7 @@ export type { AnimationContext, AnimationEffectTiming, AnimationExecutor, Animat
|
|
|
26
27
|
export type { BaseBehaviorOptions, BrushSelectOptions, ClickSelectOptions, CollapseExpandOptions, CreateEdgeOptions, DragCanvasOptions, DragElementForceOptions, DragElementOptions, FixElementSizeOptions, FocusElementOptions, HoverActivateOptions, LassoSelectOptions, OptimizeViewportTransformOptions, ScrollCanvasOptions, ZoomCanvasOptions, } from './behaviors';
|
|
27
28
|
export type { FixShapeConfig } from './behaviors/fix-element-size';
|
|
28
29
|
export type { BaseComboStyleProps, CircleComboStyleProps, RectComboStyleProps } from './elements/combos';
|
|
29
|
-
export type { BaseEdgeStyleProps, CubicHorizontalStyleProps, CubicStyleProps, CubicVerticalStyleProps, LineStyleProps, PolylineStyleProps, QuadraticStyleProps, } from './elements/edges';
|
|
30
|
+
export type { BaseEdgeStyleProps, CubicHorizontalStyleProps, CubicRadialStyleProps, CubicStyleProps, CubicVerticalStyleProps, LineStyleProps, PolylineStyleProps, QuadraticStyleProps, } from './elements/edges';
|
|
30
31
|
export type { BaseNodeStyleProps, CircleStyleProps, DiamondStyleProps, DonutStyleProps, EllipseStyleProps, HTMLStyleProps, HexagonStyleProps, ImageStyleProps, RectStyleProps, StarStyleProps, TriangleStyleProps, } from './elements/nodes';
|
|
31
32
|
export type { BadgeStyleProps, BaseShapeStyleProps, IconStyleProps, LabelStyleProps, PolygonStyleProps, } from './elements/shapes';
|
|
32
33
|
export type { UpsertHooks } from './elements/shapes/base-shape';
|
|
@@ -41,7 +42,7 @@ export type { CustomBehaviorOption } from './spec/behavior';
|
|
|
41
42
|
export type { AnimationStage } from './spec/element/animation';
|
|
42
43
|
export type { LayoutOptions, STDLayoutOptions, SingleLayoutOptions } from './spec/layout';
|
|
43
44
|
export type { CustomPluginOption } from './spec/plugin';
|
|
44
|
-
export type { BaseTransformOptions } from './transforms';
|
|
45
|
+
export type { BaseTransformOptions, PositionRadialLabelsOptions, ProcessParallelEdgesOptions } from './transforms';
|
|
45
46
|
export type { DrawData } from './transforms/types';
|
|
46
47
|
export type { BaseElementStyleProps, CardinalPlacement, CollapsedMarkerStyleProps, Combo, CornerPlacement, DirectionalPlacement, Edge, EdgeArrowStyleProps, EdgeDirection, EdgeLabelStyleProps, Element, ElementDatum, ElementHooks, ElementMethods, ElementType, FitViewOptions, HierarchyKey, IAnimateEvent, ID, IDragEvent, IElementDragEvent, IElementEvent, IElementLifeCycleEvent, IEvent, IGraphLifeCycleEvent, IKeyboardEvent, IPointerEvent, IViewportEvent, IWheelEvent, LoopPlacement, LoopStyleProps, Node, NodeBadgeStyleProps, NodeLabelStyleProps, NodeLikeData, NodePortStyleProps, Padding, Placement, Point, PortStyleProps, Prefix, PrefixKey, RelativePlacement, Size, State, TransformOptions, TreeData, TriangleDirection, Vector2, Vector3, ViewportAnimationEffectTiming, } from './types';
|
|
47
48
|
export type { Command, CommandData } from './types/history';
|
|
@@ -68,6 +68,7 @@ export declare class DataController {
|
|
|
68
68
|
getEdgeDatum(id: ID): EdgeData;
|
|
69
69
|
getEdgeData(ids?: ID[]): EdgeData[];
|
|
70
70
|
getComboData(ids?: ID[]): ComboData[];
|
|
71
|
+
getRootsData(hierarchyKey?: HierarchyKey): NodeLikeData[];
|
|
71
72
|
getAncestorsData(id: ID, hierarchyKey: HierarchyKey): NodeLikeData[];
|
|
72
73
|
getDescendantsData(id: ID): NodeLikeData[];
|
|
73
74
|
getParentData(id: ID, hierarchyKey: HierarchyKey): NodeLikeData | undefined;
|
|
@@ -42,6 +42,7 @@ export declare class Graph extends EventEmitter {
|
|
|
42
42
|
* @apiCategory option
|
|
43
43
|
*/
|
|
44
44
|
setOptions(options: GraphOptions): void;
|
|
45
|
+
private _setOptions;
|
|
45
46
|
/**
|
|
46
47
|
* <zh/> 获取当前画布容器的尺寸
|
|
47
48
|
*
|
|
@@ -723,6 +724,7 @@ export declare class Graph extends EventEmitter {
|
|
|
723
724
|
*/
|
|
724
725
|
getElementDataByState(elementType: 'combo', state: State): ComboData[];
|
|
725
726
|
private initCanvas;
|
|
727
|
+
private updateCanvas;
|
|
726
728
|
private initRuntime;
|
|
727
729
|
private prepare;
|
|
728
730
|
/**
|
|
@@ -5,4 +5,5 @@ import type { DrawData } from './types';
|
|
|
5
5
|
export type BaseTransformOptions = CustomBehaviorOption;
|
|
6
6
|
export declare abstract class BaseTransform<T extends BaseTransformOptions = BaseTransformOptions> extends BaseExtension<T> {
|
|
7
7
|
beforeDraw(data: DrawData, context: DrawContext): DrawData;
|
|
8
|
+
afterLayout(): void;
|
|
8
9
|
}
|
|
@@ -3,6 +3,9 @@ export { BaseTransform } from './base-transform';
|
|
|
3
3
|
export { CollapseExpandCombo } from './collapse-expand-combo';
|
|
4
4
|
export { CollapseExpandNode } from './collapse-expand-node';
|
|
5
5
|
export { GetEdgeActualEnds } from './get-edge-actual-ends';
|
|
6
|
+
export { PositionRadialLabels } from './position-radial-labels';
|
|
6
7
|
export { ProcessParallelEdges } from './process-parallel-edges';
|
|
7
8
|
export { UpdateRelatedEdge } from './update-related-edge';
|
|
8
9
|
export type { BaseTransformOptions } from './base-transform';
|
|
10
|
+
export type { PositionRadialLabelsOptions } from './position-radial-labels';
|
|
11
|
+
export type { ProcessParallelEdgesOptions } from './process-parallel-edges';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
2
|
+
import type { BaseTransformOptions } from './base-transform';
|
|
3
|
+
import { BaseTransform } from './base-transform';
|
|
4
|
+
/**
|
|
5
|
+
* <zh/> 根据径向布局自动调整节点标签样式的配置项
|
|
6
|
+
*
|
|
7
|
+
* <en/> Options for automatically adjusting the style of node labels according to the radial layout
|
|
8
|
+
*/
|
|
9
|
+
export interface PositionRadialLabelsOptions extends BaseTransformOptions {
|
|
10
|
+
/**
|
|
11
|
+
* <zh/> 偏移量
|
|
12
|
+
*
|
|
13
|
+
* <en/> Offset
|
|
14
|
+
*/
|
|
15
|
+
offset?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* <zh/> 根据径向布局自动调整节点标签样式,包括位置和旋转角度
|
|
19
|
+
*
|
|
20
|
+
* <en/> Automatically adjust the style of node labels according to the radial layout, including position and rotation angle
|
|
21
|
+
*/
|
|
22
|
+
export declare class PositionRadialLabels extends BaseTransform<PositionRadialLabelsOptions> {
|
|
23
|
+
static defaultOptions: Partial<PositionRadialLabelsOptions>;
|
|
24
|
+
constructor(context: RuntimeContext, options: PositionRadialLabelsOptions);
|
|
25
|
+
private get ref();
|
|
26
|
+
afterLayout(): void;
|
|
27
|
+
}
|
|
@@ -26,13 +26,14 @@ export interface Node extends DisplayObject, ElementHooks, ElementMethods {
|
|
|
26
26
|
*
|
|
27
27
|
* <en/> Get the intersection point
|
|
28
28
|
* @param point - <zh/> 外部位置 | <en/> external position
|
|
29
|
+
* @param useExtendedLine - <zh/> 是否使用延长线 | <en/> whether to use the extended line
|
|
29
30
|
* @returns <zh/> 交点位置 | <en/> intersection point
|
|
30
31
|
* @remarks
|
|
31
32
|
* <zh/> 给定一个外部位置,返回当前节点与该位置的连边与节点的交点位置
|
|
32
33
|
*
|
|
33
34
|
* <en/> Given an external position, return the intersection point of the edge between the current node and the position and the node
|
|
34
35
|
*/
|
|
35
|
-
getIntersectPoint(point: Point): Point;
|
|
36
|
+
getIntersectPoint(point: Point, useExtendedLine?: boolean): Point;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* <zh/> 边类型
|
package/dist/lib/utils/data.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComboData, EdgeData, GraphData, NodeData } from '../spec';
|
|
2
|
+
import type { ElementDatum } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* <zh/> 合并两个 节点/边/Combo 的数据
|
|
4
5
|
*
|
|
@@ -32,3 +33,16 @@ export declare function cloneElementData<T extends NodeData | EdgeData | ComboDa
|
|
|
32
33
|
* @returns <zh/> 是否为空 | <en/> is empty
|
|
33
34
|
*/
|
|
34
35
|
export declare function isEmptyData(data: GraphData): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* <zh/> 判断两个元素数据是否相等
|
|
38
|
+
*
|
|
39
|
+
* <en/> Determine if two element data are equal
|
|
40
|
+
* @param original - <zh/> 原始数据 | <en/> original data
|
|
41
|
+
* @param modified - <zh/> 修改后的数据 | <en/> modified data
|
|
42
|
+
* @returns <zh/> 是否相等 | <en/> is equal
|
|
43
|
+
* @remarks
|
|
44
|
+
* <zh/> 相比于 isEqual,这个方法不会比较更下层的数据
|
|
45
|
+
*
|
|
46
|
+
* <en/> Compared to isEqual, this method does not compare data at a lower level
|
|
47
|
+
*/
|
|
48
|
+
export declare function isElementDataEqual(original?: Partial<ElementDatum>, modified?: Partial<ElementDatum>): boolean;
|
package/dist/lib/utils/diff.d.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* @param original - <zh/> 原始数组 | <en/> original array
|
|
6
6
|
* @param modified - <zh/> 修改后的数组 | <en/> modified array
|
|
7
7
|
* @param key - <zh/> 比较的 key | <en/> key to compare
|
|
8
|
+
* @param comparator - <zh/> 比较函数 | <en/> compare function
|
|
8
9
|
* @returns <zh/> 数组差异 | <en/> array diff
|
|
9
10
|
*/
|
|
10
|
-
export declare function arrayDiff<T>(original: T[], modified: T[], key: (d: T) => string | number): {
|
|
11
|
+
export declare function arrayDiff<T>(original: T[], modified: T[], key: (d: T) => string | number, comparator?: (a?: T, b?: T) => boolean): {
|
|
11
12
|
enter: T[];
|
|
12
13
|
exit: T[];
|
|
13
14
|
keep: T[];
|
|
@@ -88,6 +88,15 @@ export declare function isOrthogonal(p1: Point, p2: Point): boolean;
|
|
|
88
88
|
* @returns <zh/> 是否三点共线 | <en/> whether three points are collinear
|
|
89
89
|
*/
|
|
90
90
|
export declare function isCollinear(p1: Point, p2: Point, p3: Point): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* <zh/> 计算一个点相对于另一个点的中心对称点
|
|
93
|
+
*
|
|
94
|
+
* <en/> Calculate the center symmetric point of a point relative to another point
|
|
95
|
+
* @param p - <zh/> 要计算的点 | <en/> the point to calculate
|
|
96
|
+
* @param center - <zh/> 中心点 | <en/> the center point
|
|
97
|
+
* @returns <zh/> 中心对称点 | <en/> the center symmetric point
|
|
98
|
+
*/
|
|
99
|
+
export declare function getSymmetricPoint(p: Point, center: Point): Point;
|
|
91
100
|
/**
|
|
92
101
|
* <zh/> 获取从多边形中心到给定点的连线与多边形边缘的交点
|
|
93
102
|
*
|
|
@@ -96,9 +105,10 @@ export declare function isCollinear(p1: Point, p2: Point, p3: Point): boolean;
|
|
|
96
105
|
* @param center - <zh/> 多边形中心 | <en/> the center of the polygon
|
|
97
106
|
* @param points - <zh/> 多边形顶点 | <en/> the vertices of the polygon
|
|
98
107
|
* @param isRelativePos - <zh/> 顶点坐标是否相对中心点 | <en/> whether the vertex coordinates are relative to the center point
|
|
108
|
+
* @param useExtendedLine - <zh/> 是否使用延长线 | <en/> whether to use the extended line
|
|
99
109
|
* @returns <zh/> 交点与相交线段 | <en/> intersection and intersecting line segment
|
|
100
110
|
*/
|
|
101
|
-
export declare function getPolygonIntersectPoint(p: Point, center: Point, points: Point[], isRelativePos?: boolean): {
|
|
111
|
+
export declare function getPolygonIntersectPoint(p: Point, center: Point, points: Point[], isRelativePos?: boolean, useExtendedLine?: boolean): {
|
|
102
112
|
point: Point;
|
|
103
113
|
line?: LineSegment;
|
|
104
114
|
};
|
|
@@ -114,24 +124,26 @@ export declare function getPolygonIntersectPoint(p: Point, center: Point, points
|
|
|
114
124
|
*/
|
|
115
125
|
export declare function isPointInPolygon(point: Point, points: Point[], start?: number, end?: number): boolean;
|
|
116
126
|
/**
|
|
117
|
-
* <zh/>
|
|
127
|
+
* <zh/> 获取给定点到矩形中心的连线与矩形边缘的交点
|
|
118
128
|
*
|
|
119
129
|
* <en/> Gets the intersection point between the line from the center of a rectangle to a given point and the rectangle's edge
|
|
120
130
|
* @param p - <zh/> 从矩形中心到矩形边缘的连线的外部点 | <en/> The point outside the rectangle from which the line to the rectangle's center is drawn
|
|
121
131
|
* @param bbox - <zh/> 矩形包围盒 | <en/> the bounding box of the rectangle
|
|
132
|
+
* @param useExtendedLine - <zh/> 是否使用延长线 | <en/> whether to use the extended line
|
|
122
133
|
* @returns <zh/> 交点 | <en/> intersection
|
|
123
134
|
*/
|
|
124
|
-
export declare function getRectIntersectPoint(p: Point, bbox: AABB): Point;
|
|
135
|
+
export declare function getRectIntersectPoint(p: Point, bbox: AABB, useExtendedLine?: boolean): Point;
|
|
125
136
|
/**
|
|
126
|
-
* <zh/>
|
|
137
|
+
* <zh/> 获取给定点到椭圆中心的连线与椭圆边缘的交点
|
|
127
138
|
*
|
|
128
139
|
* <en/> Gets the intersection point between the line from the center of an ellipse to a given point and the ellipse's edge
|
|
129
140
|
* @param p - <zh/> 从椭圆中心到椭圆边缘的连线的外部点 | <en/> The point outside the ellipse from which the line to the ellipse's center is drawn
|
|
130
141
|
* The point outside the ellipse from which the line to the ellipse's center is drawn.
|
|
131
142
|
* @param bbox - <zh/> 椭圆包围盒 | <en/> the bounding box of the ellipse
|
|
143
|
+
* @param useExtendedLine - <zh/> 是否使用延长线 | <en/> whether to use the extended line
|
|
132
144
|
* @returns <zh/> 交点 | <en/> intersection
|
|
133
145
|
*/
|
|
134
|
-
export declare function getEllipseIntersectPoint(p: Point, bbox: AABB): Point;
|
|
146
|
+
export declare function getEllipseIntersectPoint(p: Point, bbox: AABB, useExtendedLine?: boolean): Point;
|
|
135
147
|
/**
|
|
136
148
|
* <zh/> 从两组点中找到距离最近的两个点
|
|
137
149
|
* @param group1 - <zh/> 第一组点 | <en/> the first group of points
|
|
@@ -8,6 +8,14 @@ import type { Anchor, NodeLikeData, Placement, Point, RelativePlacement } from '
|
|
|
8
8
|
* @returns - <zh/> 坐标 | <en/> position
|
|
9
9
|
*/
|
|
10
10
|
export declare function positionOf(datum: NodeLikeData): Point;
|
|
11
|
+
/**
|
|
12
|
+
* <zh/> 检查数据是否有位置坐标
|
|
13
|
+
*
|
|
14
|
+
* <en/> Check if the data has a position coordinate
|
|
15
|
+
* @param datum - <zh/> 节点/ combo 的数据 | <en/> data of node/combo
|
|
16
|
+
* @returns - <zh/> 是否有位置坐标 | <en/> Whether there is a position coordinate
|
|
17
|
+
*/
|
|
18
|
+
export declare function hasPosition(datum: NodeLikeData): boolean;
|
|
11
19
|
/**
|
|
12
20
|
* <zh/> 获取相对位置坐标
|
|
13
21
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Graph } from '../runtime/graph';
|
|
2
|
-
import type { ElementType, ID } from '../types';
|
|
2
|
+
import type { EdgeDirection, ElementType, ID } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* <zh/> 获取指定元素在 n 度关系内的所有元素的 ID
|
|
5
5
|
*
|
|
@@ -14,20 +14,22 @@ import type { ElementType, ID } from '../types';
|
|
|
14
14
|
* @param elementType - <zh/> 元素类型 | <en/> element type
|
|
15
15
|
* @param elementId - <zh/> 起始元素的 ID | <en/> start element ID
|
|
16
16
|
* @param degree - <zh/> 指定的度数 | <en/> the specified degree
|
|
17
|
+
* @param direction - <zh/> 边的方向 | <en/> edge direction
|
|
17
18
|
* @returns - <zh/> 返回节点和边的 ID 数组 | <en/> Returns an array of node and edge IDs
|
|
18
19
|
*/
|
|
19
|
-
export declare function getElementNthDegreeIds(graph: Graph, elementType: ElementType, elementId: ID, degree: number): ID[];
|
|
20
|
+
export declare function getElementNthDegreeIds(graph: Graph, elementType: ElementType, elementId: ID, degree: number, direction?: EdgeDirection): ID[];
|
|
20
21
|
/**
|
|
21
22
|
* <zh/> 获取指定节点在 n 度关系内的所有元素的 ID
|
|
22
23
|
*
|
|
23
24
|
* <en/> Get all elements IDs within n-degree relationship of the specified node
|
|
24
25
|
* @remarks
|
|
25
26
|
* <zh/> 节点的 0 度关系是节点本身,1 度关系是节点的直接相邻节点和边,以此类推
|
|
26
|
-
*
|
|
27
|
+
* @param direction
|
|
27
28
|
* <en/> 0-degree relationship of a node is the node itself; 1-degree relationship is the node's neighboring nodes and related edges, etc
|
|
28
29
|
* @param graph - <zh/> 图实例 | <en/> graph instance
|
|
29
30
|
* @param startNodeId - <zh/> 起始节点的 ID | <en/> The ID of the starting node
|
|
30
31
|
* @param degree - <zh/> 指定的度数 | <en/> The specified degree
|
|
32
|
+
* @param direction - <zh/> 边的方向 | <en/> The direction of the edge
|
|
31
33
|
* @returns - <zh/> 返回节点和边的 ID 数组 | <en/> Returns an array of node and edge IDs
|
|
32
34
|
*/
|
|
33
|
-
export declare function getNodeNthDegreeIds(graph: Graph, startNodeId: ID, degree: number): ID[];
|
|
35
|
+
export declare function getNodeNthDegreeIds(graph: Graph, startNodeId: ID, degree: number, direction?: EdgeDirection): ID[];
|
|
@@ -141,3 +141,11 @@ export declare function toVector2(a: Vector2 | Vector3): Vector2;
|
|
|
141
141
|
* @returns - <zh/> 三维向量 | <en/> Three-dimensional vector
|
|
142
142
|
*/
|
|
143
143
|
export declare function toVector3(a: Vector2 | Vector3): Vector3;
|
|
144
|
+
/**
|
|
145
|
+
* <zh/> 计算向量与 x 轴正方向的夹角(弧度制)
|
|
146
|
+
*
|
|
147
|
+
* <en/> The angle between the vector and the positive direction of the x-axis (radians)
|
|
148
|
+
* @param a - <zh/> 向量 | <en/> The vector
|
|
149
|
+
* @returns <zh/> 弧度值 | <en/> The angle in radians
|
|
150
|
+
*/
|
|
151
|
+
export declare function rad(a: Vector2 | Vector3): number;
|
package/dist/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.0.
|
|
1
|
+
export declare const version = "5.0.20";
|
|
@@ -35,6 +35,13 @@ export interface DragCanvasOptions extends BaseBehaviorOptions {
|
|
|
35
35
|
* @defaultValue `'both'`
|
|
36
36
|
*/
|
|
37
37
|
direction?: 'x' | 'y' | 'both';
|
|
38
|
+
/**
|
|
39
|
+
* <zh/> 可拖拽的视口范围,默认最多可拖拽一屏。可以分别设置上、右、下、左四个方向的范围,每个方向的范围在 [0, Infinity] 之间
|
|
40
|
+
*
|
|
41
|
+
* <en/> The draggable viewport range allows you to drag up to one screen by default. You can set the range for each direction (top, right, bottom, left) individually, with each direction's range between [0, Infinity]
|
|
42
|
+
* @defaultValue 1
|
|
43
|
+
*/
|
|
44
|
+
range?: number | number[];
|
|
38
45
|
/**
|
|
39
46
|
* <zh/> 触发拖拽的方式,默认使用指针按下拖拽
|
|
40
47
|
*
|
|
@@ -94,6 +101,8 @@ export declare class DragCanvas extends BaseBehavior<DragCanvasOptions> {
|
|
|
94
101
|
* @internal
|
|
95
102
|
*/
|
|
96
103
|
protected translate(offset: Vector2, animation?: ViewportAnimationEffectTiming): Promise<void>;
|
|
104
|
+
private clampByDirection;
|
|
105
|
+
private clampByRange;
|
|
97
106
|
private validate;
|
|
98
107
|
private unbindEvents;
|
|
99
108
|
destroy(): void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { debounce, isObject } from '@antv/util';
|
|
2
2
|
import { CommonEvent } from '../constants';
|
|
3
|
+
import { getExpandedBBox, getPointBBox, isPointInBBox } from '../utils/bbox';
|
|
4
|
+
import { parsePadding } from '../utils/padding';
|
|
3
5
|
import { Shortcut } from '../utils/shortcut';
|
|
4
|
-
import { multiply } from '../utils/vector';
|
|
6
|
+
import { multiply, subtract } from '../utils/vector';
|
|
5
7
|
import { BaseBehavior } from './base-behavior';
|
|
6
8
|
/**
|
|
7
9
|
* <zh/> 拖拽画布交互
|
|
@@ -17,6 +19,7 @@ export class DragCanvas extends BaseBehavior {
|
|
|
17
19
|
},
|
|
18
20
|
sensitivity: 10,
|
|
19
21
|
direction: 'both',
|
|
22
|
+
range: 1,
|
|
20
23
|
};
|
|
21
24
|
shortcut;
|
|
22
25
|
defaultCursor;
|
|
@@ -94,7 +97,11 @@ export class DragCanvas extends BaseBehavior {
|
|
|
94
97
|
* @internal
|
|
95
98
|
*/
|
|
96
99
|
async translate(offset, animation) {
|
|
97
|
-
|
|
100
|
+
offset = this.clampByDirection(offset);
|
|
101
|
+
offset = this.clampByRange(offset);
|
|
102
|
+
await this.context.graph.translateBy(offset, animation);
|
|
103
|
+
}
|
|
104
|
+
clampByDirection([dx, dy]) {
|
|
98
105
|
const { direction } = this.options;
|
|
99
106
|
if (direction === 'x') {
|
|
100
107
|
dy = 0;
|
|
@@ -102,7 +109,25 @@ export class DragCanvas extends BaseBehavior {
|
|
|
102
109
|
else if (direction === 'y') {
|
|
103
110
|
dx = 0;
|
|
104
111
|
}
|
|
105
|
-
|
|
112
|
+
return [dx, dy];
|
|
113
|
+
}
|
|
114
|
+
clampByRange([dx, dy]) {
|
|
115
|
+
const { viewport, canvas } = this.context;
|
|
116
|
+
const [canvasWidth, canvasHeight] = canvas.getSize();
|
|
117
|
+
const [top, right, bottom, left] = parsePadding(this.options.range);
|
|
118
|
+
const range = [canvasHeight * top, canvasWidth * right, canvasHeight * bottom, canvasWidth * left];
|
|
119
|
+
const draggableArea = getExpandedBBox(getPointBBox(viewport.getCanvasCenter()), range);
|
|
120
|
+
const nextViewportCenter = subtract(viewport.getViewportCenter(), [dx, dy, 0]);
|
|
121
|
+
if (!isPointInBBox(nextViewportCenter, draggableArea)) {
|
|
122
|
+
const { min: [minX, minY], max: [maxX, maxY], } = draggableArea;
|
|
123
|
+
if ((nextViewportCenter[0] < minX && dx > 0) || (nextViewportCenter[0] > maxX && dx < 0)) {
|
|
124
|
+
dx = 0;
|
|
125
|
+
}
|
|
126
|
+
if ((nextViewportCenter[1] < minY && dy > 0) || (nextViewportCenter[1] > maxY && dy < 0)) {
|
|
127
|
+
dy = 0;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return [dx, dy];
|
|
106
131
|
}
|
|
107
132
|
validate(event) {
|
|
108
133
|
if (this.destroyed)
|