@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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { DisplayObjectConfig } from '@antv/g';
|
|
2
|
+
import type { NodeData } from '../../spec';
|
|
3
|
+
import type { Point } from '../../types';
|
|
4
|
+
import { positionOf } from '../../utils/position';
|
|
5
|
+
import { mergeOptions } from '../../utils/style';
|
|
6
|
+
import { distance, rad, subtract } from '../../utils/vector';
|
|
7
|
+
import type { CubicStyleProps } from './cubic';
|
|
8
|
+
import { Cubic } from './cubic';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* <zh/> 径向贝塞尔曲线样式配置项
|
|
12
|
+
*
|
|
13
|
+
* <en/> Radial cubic style props
|
|
14
|
+
*/
|
|
15
|
+
export interface CubicRadialStyleProps extends CubicStyleProps {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* <zh/> 径向贝塞尔曲线
|
|
19
|
+
*
|
|
20
|
+
* <en/> Radial cubic edge
|
|
21
|
+
*/
|
|
22
|
+
export class CubicRadial extends Cubic {
|
|
23
|
+
static defaultStyleProps: Partial<CubicStyleProps> = {
|
|
24
|
+
curvePosition: 0.5,
|
|
25
|
+
curveOffset: 20,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
constructor(options: DisplayObjectConfig<CubicStyleProps>) {
|
|
29
|
+
super(mergeOptions({ style: CubicRadial.defaultStyleProps }, options));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private get ref(): NodeData {
|
|
33
|
+
return this.context.model.getRootsData()[0];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected getEndpoints(attributes: Required<CubicStyleProps>): [Point, Point] {
|
|
37
|
+
if (this.sourceNode.id === this.ref.id) {
|
|
38
|
+
return super.getEndpoints(attributes);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const refPoint = positionOf(this.ref);
|
|
42
|
+
const sourcePoint = this.sourceNode.getIntersectPoint(refPoint, true);
|
|
43
|
+
const targetPoint = this.targetNode.getIntersectPoint(refPoint);
|
|
44
|
+
|
|
45
|
+
return [sourcePoint, targetPoint];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private toRadialCoordinate(p: Point) {
|
|
49
|
+
const refPoint = positionOf(this.ref);
|
|
50
|
+
const r = distance(p, refPoint);
|
|
51
|
+
const radian = rad(subtract(p, refPoint));
|
|
52
|
+
return [r, radian];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected getControlPoints(
|
|
56
|
+
sourcePoint: Point,
|
|
57
|
+
targetPoint: Point,
|
|
58
|
+
curvePosition: [number, number],
|
|
59
|
+
curveOffset: [number, number],
|
|
60
|
+
): [Point, Point] {
|
|
61
|
+
const [r1, rad1] = this.toRadialCoordinate(sourcePoint);
|
|
62
|
+
const [r2] = this.toRadialCoordinate(targetPoint);
|
|
63
|
+
|
|
64
|
+
const rDist = r2 - r1;
|
|
65
|
+
|
|
66
|
+
return [
|
|
67
|
+
[
|
|
68
|
+
sourcePoint[0] + (rDist * curvePosition[0] + curveOffset[0]) * Math.cos(rad1),
|
|
69
|
+
sourcePoint[1] + (rDist * curvePosition[0] + curveOffset[0]) * Math.sin(rad1),
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
targetPoint[0] - (rDist * curvePosition[1] - curveOffset[0]) * Math.cos(rad1),
|
|
73
|
+
targetPoint[1] - (rDist * curvePosition[1] - curveOffset[0]) * Math.sin(rad1),
|
|
74
|
+
],
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -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';
|
|
@@ -9,6 +10,7 @@ export { Quadratic } from './quadratic';
|
|
|
9
10
|
export type { BaseEdgeStyleProps } from './base-edge';
|
|
10
11
|
export type { CubicStyleProps } from './cubic';
|
|
11
12
|
export type { CubicHorizontalStyleProps } from './cubic-horizontal';
|
|
13
|
+
export type { CubicRadialStyleProps } from './cubic-radial';
|
|
12
14
|
export type { CubicVerticalStyleProps } from './cubic-vertical';
|
|
13
15
|
export type { LineStyleProps } from './line';
|
|
14
16
|
export type { PolylineStyleProps } from './polyline';
|
package/src/elements/effect.ts
CHANGED
|
@@ -1,61 +1,27 @@
|
|
|
1
1
|
import type { Element } from '../types';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const EFFECT_WEAKMAP = new WeakMap<Element, Record<string, any>>();
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* <zh/>
|
|
6
|
-
*
|
|
7
|
-
* <en/> Optimize the number of method executions, and only execute the function when the style attributes change
|
|
8
|
-
* @param styler - <zh/> 获取样式属性函数 | <en/> Get style attribute function
|
|
9
|
-
* @returns <zh/> 装饰器 | <en/> Decorator
|
|
10
|
-
* @remarks
|
|
11
|
-
* <zh/> 仅指定 getStyle 的情况下,会分别使用当前的 attributes 和 新的 attributes 调用函数,若两者相同,则不执行函数。
|
|
12
|
-
*
|
|
13
|
-
* 如果指定了 shapeKey, 则会直接获取该图形的 attributes 作为原始样式属性,通常在 getStyle 函数中获取了包围盒时使用。
|
|
14
|
-
*
|
|
15
|
-
* <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.
|
|
16
|
-
*
|
|
17
|
-
* 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.
|
|
18
|
-
* @example
|
|
19
|
-
* <zh/> 仅当 value 发生变化时执行函数
|
|
20
|
-
*
|
|
21
|
-
* <en/> Execute the function only when value changes
|
|
6
|
+
* <zh/> 判定给定样式是否与上一次的样式相同
|
|
22
7
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* return { value }
|
|
29
|
-
* })
|
|
30
|
-
* drawCustomShape(attributes, container) {
|
|
31
|
-
* this.upsert('custom', 'circle', { ...attributes }, container);
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
8
|
+
* <en/> Determine whether the given style are the same as the previous ones
|
|
9
|
+
* @param target - <zh/> 目标元素 | <en/> Target element
|
|
10
|
+
* @param key - <zh/> 缓存 key | <en/> Cache key
|
|
11
|
+
* @param style - <zh/> 样式属性 | <en/> Style attribute
|
|
12
|
+
* @returns <zh/> 是否执行函数 | <en/> Whether to execute the function
|
|
35
13
|
*/
|
|
36
|
-
export function effect
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const styleKey = `${propertyKey}_style`;
|
|
49
|
-
const original = getCachedStyle(this, styleKey);
|
|
50
|
-
const modified = styler(this, attr);
|
|
51
|
-
setCacheStyle(this, styleKey, modified);
|
|
52
|
-
|
|
53
|
-
if (isStyleEqual(original, modified)) return null;
|
|
54
|
-
|
|
55
|
-
return fn.call(this, attr, ...rest);
|
|
56
|
-
};
|
|
57
|
-
return descriptor;
|
|
58
|
-
};
|
|
14
|
+
export function effect<T extends false | Record<string, any>>(target: Element, key: string, style: T): boolean {
|
|
15
|
+
if (!EFFECT_WEAKMAP.has(target)) EFFECT_WEAKMAP.set(target, {});
|
|
16
|
+
const cache = EFFECT_WEAKMAP.get(target)!;
|
|
17
|
+
if (!cache[key]) {
|
|
18
|
+
cache[key] = style;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const original = cache[key];
|
|
22
|
+
if (isStyleEqual(original, style)) return false;
|
|
23
|
+
cache[key] = style;
|
|
24
|
+
return true;
|
|
59
25
|
}
|
|
60
26
|
|
|
61
27
|
/**
|
|
@@ -71,7 +37,7 @@ export function effect(styler: (self: any, attributes: Record<string, unknown>)
|
|
|
71
37
|
*
|
|
72
38
|
* <en/> Perform a second-level shallow comparison to compare complex shape attributes such as badges and ports
|
|
73
39
|
*/
|
|
74
|
-
const isStyleEqual = (a: Record<string, unknown>, b: Record<string, unknown>, depth = 2): boolean => {
|
|
40
|
+
const isStyleEqual = (a: false | Record<string, unknown>, b: false | Record<string, unknown>, depth = 2): boolean => {
|
|
75
41
|
if (typeof a !== 'object' || typeof b !== 'object') return a === b;
|
|
76
42
|
|
|
77
43
|
const keys1 = Object.keys(a);
|
|
@@ -354,56 +354,62 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
354
354
|
/**
|
|
355
355
|
* 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`.
|
|
356
356
|
* @param point - The point to intersect with the node.
|
|
357
|
+
* @param useExtendedLine - Whether to use the extended line.
|
|
357
358
|
* @returns The intersection point.
|
|
358
359
|
*/
|
|
359
|
-
public getIntersectPoint(point: Point): Point {
|
|
360
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
360
361
|
const keyShapeBounds = this.getShape('key').getBounds();
|
|
361
|
-
return getRectIntersectPoint(point, keyShapeBounds);
|
|
362
|
+
return getRectIntersectPoint(point, keyShapeBounds, useExtendedLine);
|
|
362
363
|
}
|
|
363
364
|
|
|
364
|
-
@effect((self, attributes) => self.getHaloStyle(attributes))
|
|
365
365
|
protected drawHaloShape(attributes: Required<S>, container: Group): void {
|
|
366
|
+
const style = this.getHaloStyle(attributes);
|
|
367
|
+
if (!effect(this, 'halo', style)) return;
|
|
368
|
+
|
|
366
369
|
const keyShape = this.getShape('key');
|
|
367
|
-
this.upsert(
|
|
368
|
-
'halo',
|
|
369
|
-
keyShape.constructor as new (...args: unknown[]) => DisplayObject,
|
|
370
|
-
this.getHaloStyle(attributes),
|
|
371
|
-
container,
|
|
372
|
-
);
|
|
370
|
+
this.upsert('halo', keyShape.constructor as new (...args: unknown[]) => DisplayObject, style, container);
|
|
373
371
|
}
|
|
374
372
|
|
|
375
|
-
@effect((self, attributes) => self.getIconStyle(attributes))
|
|
376
373
|
protected drawIconShape(attributes: Required<S>, container: Group): void {
|
|
377
|
-
|
|
374
|
+
const style = this.getIconStyle(attributes);
|
|
375
|
+
if (!effect(this, 'icon', style)) return;
|
|
376
|
+
|
|
377
|
+
this.upsert('icon', Icon, style, container);
|
|
378
378
|
connectImage(this);
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
-
@effect((self, attributes) => self.getBadgesStyle(attributes))
|
|
382
381
|
protected drawBadgeShapes(attributes: Required<S>, container: Group): void {
|
|
383
382
|
const badgesStyle = this.getBadgesStyle(attributes);
|
|
384
383
|
Object.keys(badgesStyle).forEach((key) => {
|
|
385
|
-
|
|
384
|
+
const style = badgesStyle[key];
|
|
385
|
+
if (!effect(this, `badge-${key}`, style)) return;
|
|
386
|
+
|
|
387
|
+
this.upsert(`badge-${key}`, Badge, style, container);
|
|
386
388
|
});
|
|
387
389
|
}
|
|
388
390
|
|
|
389
|
-
@effect((self, attributes) => self.getPortsStyle(attributes))
|
|
390
391
|
protected drawPortShapes(attributes: Required<S>, container: Group): void {
|
|
391
392
|
const portsStyle = this.getPortsStyle(attributes);
|
|
392
393
|
|
|
393
394
|
Object.keys(portsStyle).forEach((key) => {
|
|
394
|
-
|
|
395
|
+
const style = portsStyle[key] as CircleStyleProps;
|
|
396
|
+
const shapeKey = `port-${key}`;
|
|
397
|
+
if (!effect(this, shapeKey, style)) return;
|
|
398
|
+
|
|
399
|
+
this.upsert(shapeKey, GCircle, style, container);
|
|
395
400
|
});
|
|
396
401
|
}
|
|
397
402
|
|
|
398
|
-
@effect((self, attributes) => self.getLabelStyle(attributes))
|
|
399
403
|
protected drawLabelShape(attributes: Required<S>, container: Group): void {
|
|
400
|
-
|
|
404
|
+
const style = this.getLabelStyle(attributes);
|
|
405
|
+
if (!effect(this, 'label', style)) return;
|
|
406
|
+
|
|
407
|
+
this.upsert('label', Label, style, container);
|
|
401
408
|
}
|
|
402
409
|
|
|
403
410
|
protected abstract drawKeyShape(attributes: Required<S>, container: Group): DisplayObject | undefined;
|
|
404
411
|
|
|
405
412
|
// 用于装饰抽象方法 / Used to decorate abstract methods
|
|
406
|
-
@effect((self, attributes) => self.getKeyStyle(attributes))
|
|
407
413
|
private _drawKeyShape(attributes: Required<S>, container: Group) {
|
|
408
414
|
return this.drawKeyShape(attributes, container);
|
|
409
415
|
}
|
|
@@ -45,8 +45,8 @@ export class Circle extends BaseNode {
|
|
|
45
45
|
return style ? ({ width: size, height: size, ...style } as IconStyleProps) : false;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
public getIntersectPoint(point: Point): Point {
|
|
48
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
49
49
|
const keyShapeBounds = this.getShape('key').getBounds();
|
|
50
|
-
return getEllipseIntersectPoint(point, keyShapeBounds);
|
|
50
|
+
return getEllipseIntersectPoint(point, keyShapeBounds, useExtendedLine);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -51,8 +51,8 @@ export class Ellipse extends BaseNode {
|
|
|
51
51
|
return style ? ({ width: size, height: size, ...style } as IconStyleProps) : false;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
public getIntersectPoint(point: Point): Point {
|
|
54
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
55
55
|
const keyShapeBounds = this.getShape('key').getBounds();
|
|
56
|
-
return getEllipseIntersectPoint(point, keyShapeBounds);
|
|
56
|
+
return getEllipseIntersectPoint(point, keyShapeBounds, useExtendedLine);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -47,7 +47,7 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
|
|
|
47
47
|
* <en> create, update or remove shape
|
|
48
48
|
* @param className - <zh> 图形名称 | <en> shape name
|
|
49
49
|
* @param Ctor - <zh> 图形类型 | <en> shape type
|
|
50
|
-
* @param style - <zh>
|
|
50
|
+
* @param style - <zh> 图形样式。若要删除图形,传入 false | <en> shape style. Pass false to remove the shape
|
|
51
51
|
* @param container - <zh> 容器 | <en> container
|
|
52
52
|
* @param hooks - <zh> 钩子函数 | <en> hooks
|
|
53
53
|
* @returns <zh> 图形实例 | <en> shape instance
|
|
@@ -43,9 +43,9 @@ export abstract class Polygon<T extends PolygonStyleProps = PolygonStyleProps> e
|
|
|
43
43
|
|
|
44
44
|
protected abstract getPoints(attributes: Required<T>): Point[];
|
|
45
45
|
|
|
46
|
-
public getIntersectPoint(point: Point): Point {
|
|
46
|
+
public getIntersectPoint(point: Point, useExtendedLine = false): Point {
|
|
47
47
|
const { points } = this.getShape<GPolygon>('key').attributes;
|
|
48
48
|
const center: Point = [+(this.attributes?.x || 0), +(this.attributes?.y || 0)];
|
|
49
|
-
return getPolygonIntersectPoint(point, center, points
|
|
49
|
+
return getPolygonIntersectPoint(point, center, points!, true, useExtendedLine).point;
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/exports.ts
CHANGED
|
@@ -27,7 +27,16 @@ export {
|
|
|
27
27
|
NodeEvent,
|
|
28
28
|
} from './constants';
|
|
29
29
|
export { BaseCombo, CircleCombo, RectCombo } from './elements/combos';
|
|
30
|
-
export {
|
|
30
|
+
export {
|
|
31
|
+
BaseEdge,
|
|
32
|
+
Cubic,
|
|
33
|
+
CubicHorizontal,
|
|
34
|
+
CubicRadial,
|
|
35
|
+
CubicVertical,
|
|
36
|
+
Line,
|
|
37
|
+
Polyline,
|
|
38
|
+
Quadratic,
|
|
39
|
+
} from './elements/edges';
|
|
31
40
|
export { effect } from './elements/effect';
|
|
32
41
|
export {
|
|
33
42
|
BaseNode,
|
|
@@ -48,20 +57,20 @@ export {
|
|
|
48
57
|
BaseLayout,
|
|
49
58
|
CircularLayout,
|
|
50
59
|
ComboCombinedLayout,
|
|
60
|
+
compactBox as CompactBoxLayout,
|
|
51
61
|
ConcentricLayout,
|
|
52
62
|
D3ForceLayout,
|
|
53
63
|
DagreLayout,
|
|
64
|
+
dendrogram as DendrogramLayout,
|
|
54
65
|
ForceAtlas2Layout,
|
|
55
66
|
ForceLayout,
|
|
56
67
|
FruchtermanLayout,
|
|
57
68
|
GridLayout,
|
|
69
|
+
indented as IndentedLayout,
|
|
58
70
|
MDSLayout,
|
|
71
|
+
mindmap as MindmapLayout,
|
|
59
72
|
RadialLayout,
|
|
60
73
|
RandomLayout,
|
|
61
|
-
compactBox,
|
|
62
|
-
dendrogram,
|
|
63
|
-
indented,
|
|
64
|
-
mindmap,
|
|
65
74
|
} from './layouts';
|
|
66
75
|
export {
|
|
67
76
|
BasePlugin,
|
|
@@ -85,10 +94,11 @@ export {
|
|
|
85
94
|
export { getExtension, getExtensions } from './registry/get';
|
|
86
95
|
export { register } from './registry/register';
|
|
87
96
|
export { Graph } from './runtime/graph';
|
|
88
|
-
export { BaseTransform } from './transforms';
|
|
97
|
+
export { BaseTransform, PositionRadialLabels, ProcessParallelEdges } from './transforms';
|
|
89
98
|
export { isCollapsed } from './utils/collapsibility';
|
|
90
99
|
export { idOf } from './utils/id';
|
|
91
100
|
export { invokeLayoutMethod } from './utils/layout';
|
|
101
|
+
export { positionOf } from './utils/position';
|
|
92
102
|
export { omitStyleProps, subStyleProps } from './utils/prefix';
|
|
93
103
|
export { Shortcut } from './utils/shortcut';
|
|
94
104
|
export { parseSize } from './utils/size';
|
|
@@ -136,6 +146,7 @@ export type { BaseComboStyleProps, CircleComboStyleProps, RectComboStyleProps }
|
|
|
136
146
|
export type {
|
|
137
147
|
BaseEdgeStyleProps,
|
|
138
148
|
CubicHorizontalStyleProps,
|
|
149
|
+
CubicRadialStyleProps,
|
|
139
150
|
CubicStyleProps,
|
|
140
151
|
CubicVerticalStyleProps,
|
|
141
152
|
LineStyleProps,
|
|
@@ -206,7 +217,7 @@ export type { CustomBehaviorOption } from './spec/behavior';
|
|
|
206
217
|
export type { AnimationStage } from './spec/element/animation';
|
|
207
218
|
export type { LayoutOptions, STDLayoutOptions, SingleLayoutOptions } from './spec/layout';
|
|
208
219
|
export type { CustomPluginOption } from './spec/plugin';
|
|
209
|
-
export type { BaseTransformOptions } from './transforms';
|
|
220
|
+
export type { BaseTransformOptions, PositionRadialLabelsOptions, ProcessParallelEdgesOptions } from './transforms';
|
|
210
221
|
export type { DrawData } from './transforms/types';
|
|
211
222
|
export type {
|
|
212
223
|
BaseElementStyleProps,
|
package/src/plugins/tooltip.ts
CHANGED
|
@@ -151,8 +151,8 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
|
|
|
151
151
|
} = event;
|
|
152
152
|
// click the same item twice, tooltip will be hidden
|
|
153
153
|
if (this.currentTarget === id) {
|
|
154
|
-
this.currentTarget = null;
|
|
155
154
|
this.hide(event);
|
|
155
|
+
this.currentTarget = null;
|
|
156
156
|
} else {
|
|
157
157
|
this.currentTarget = id;
|
|
158
158
|
this.show(event);
|
|
@@ -294,7 +294,9 @@ export class Tooltip extends BasePlugin<TooltipOptions> {
|
|
|
294
294
|
this.tooltipElement?.hide();
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
if (!this.tooltipElement
|
|
297
|
+
if (!this.tooltipElement) return;
|
|
298
|
+
// No target node: tooltip has been hidden. No need for duplicated call.
|
|
299
|
+
if (!this.currentTarget) return;
|
|
298
300
|
const {
|
|
299
301
|
client: { x, y },
|
|
300
302
|
} = event;
|
package/src/registry/build-in.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
CircleCombo,
|
|
33
33
|
Cubic,
|
|
34
34
|
CubicHorizontal,
|
|
35
|
+
CubicRadial,
|
|
35
36
|
CubicVertical,
|
|
36
37
|
Diamond,
|
|
37
38
|
Donut,
|
|
@@ -92,6 +93,7 @@ import {
|
|
|
92
93
|
CollapseExpandCombo,
|
|
93
94
|
CollapseExpandNode,
|
|
94
95
|
GetEdgeActualEnds,
|
|
96
|
+
PositionRadialLabels,
|
|
95
97
|
ProcessParallelEdges,
|
|
96
98
|
UpdateRelatedEdge,
|
|
97
99
|
} from '../transforms';
|
|
@@ -138,6 +140,7 @@ const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
|
|
|
138
140
|
polyline: Polyline,
|
|
139
141
|
quadratic: Quadratic,
|
|
140
142
|
'cubic-horizontal': CubicHorizontal,
|
|
143
|
+
'cubic-radial': CubicRadial,
|
|
141
144
|
'cubic-vertical': CubicVertical,
|
|
142
145
|
},
|
|
143
146
|
layout: {
|
|
@@ -207,6 +210,7 @@ const BUILT_IN_EXTENSIONS: ExtensionRegistry = {
|
|
|
207
210
|
'collapse-expand-node': CollapseExpandNode,
|
|
208
211
|
'process-parallel-edges': ProcessParallelEdges,
|
|
209
212
|
'get-edge-actual-ends': GetEdgeActualEnds,
|
|
213
|
+
'position-radial-labels': PositionRadialLabels,
|
|
210
214
|
},
|
|
211
215
|
shape: {
|
|
212
216
|
circle: GCircle,
|
package/src/runtime/animation.ts
CHANGED
|
@@ -79,12 +79,14 @@ export class Animation {
|
|
|
79
79
|
* @param options - <zh/> 扩展选项 | <en/> Extend options
|
|
80
80
|
* @returns <zh/> 始态样式与终态样式 | <en/> Initial style and final style
|
|
81
81
|
*/
|
|
82
|
-
public inferStyle(
|
|
82
|
+
public inferStyle(
|
|
83
|
+
context: AnimationContext,
|
|
84
|
+
options?: ExtendOptions,
|
|
85
|
+
): [Record<string, unknown>, Record<string, unknown>] {
|
|
83
86
|
const { element, elementType, stage, originalStyle, modifiedStyle } = context;
|
|
84
87
|
|
|
85
|
-
const fromStyle = {
|
|
86
|
-
const toStyle = {
|
|
87
|
-
const getCacheOpacity = () => getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity');
|
|
88
|
+
const fromStyle: Record<string, unknown> = {};
|
|
89
|
+
const toStyle: Record<string, unknown> = {};
|
|
88
90
|
|
|
89
91
|
if (stage === 'enter') {
|
|
90
92
|
Object.assign(fromStyle, { opacity: 0 });
|
|
@@ -92,9 +94,9 @@ export class Animation {
|
|
|
92
94
|
Object.assign(toStyle, { opacity: 0 });
|
|
93
95
|
} else if (stage === 'show') {
|
|
94
96
|
Object.assign(fromStyle, { opacity: 0 });
|
|
95
|
-
Object.assign(toStyle, { opacity:
|
|
97
|
+
Object.assign(toStyle, { opacity: getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity') });
|
|
96
98
|
} else if (stage === 'hide') {
|
|
97
|
-
Object.assign(fromStyle, { opacity:
|
|
99
|
+
Object.assign(fromStyle, { opacity: getCachedStyle(element, 'opacity') ?? inferDefaultValue('opacity') });
|
|
98
100
|
Object.assign(toStyle, { opacity: 0 });
|
|
99
101
|
} else if (stage === 'collapse') {
|
|
100
102
|
const { collapse } = options || {};
|
|
@@ -109,10 +111,10 @@ export class Animation {
|
|
|
109
111
|
} else if (elementType === 'combo') {
|
|
110
112
|
if (element.id === target || descendants.includes(element.id)) {
|
|
111
113
|
const [x, y] = position;
|
|
112
|
-
Object.assign(toStyle, { x, y, childrenNode:
|
|
114
|
+
Object.assign(toStyle, { x, y, childrenNode: originalStyle.childrenNode });
|
|
113
115
|
}
|
|
114
116
|
} else if (elementType === 'edge') {
|
|
115
|
-
Object.assign(toStyle, { sourceNode:
|
|
117
|
+
Object.assign(toStyle, { sourceNode: modifiedStyle.sourceNode, targetNode: modifiedStyle.targetNode });
|
|
116
118
|
}
|
|
117
119
|
} else if (stage === 'expand') {
|
|
118
120
|
const { expand } = options || {};
|
|
@@ -129,16 +131,19 @@ export class Animation {
|
|
|
129
131
|
// Set the child elements of the expanded combo
|
|
130
132
|
if (element.id === target || descendants.includes(element.id)) {
|
|
131
133
|
const [x, y, z] = position;
|
|
132
|
-
Object.assign(fromStyle, { x, y, z, childrenNode:
|
|
134
|
+
Object.assign(fromStyle, { x, y, z, childrenNode: modifiedStyle.childrenNode });
|
|
133
135
|
}
|
|
134
136
|
} else if (elementType === 'edge') {
|
|
135
137
|
// 设置展开后的边的起点和终点
|
|
136
138
|
// Set the starting point and end point of the edge after expansion
|
|
137
|
-
Object.assign(fromStyle, { sourceNode:
|
|
139
|
+
Object.assign(fromStyle, { sourceNode: modifiedStyle.sourceNode, targetNode: modifiedStyle.targetNode });
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
|
|
141
|
-
return [
|
|
143
|
+
return [
|
|
144
|
+
Object.keys(fromStyle).length > 0 ? Object.assign({}, originalStyle, fromStyle) : originalStyle,
|
|
145
|
+
Object.keys(toStyle).length > 0 ? Object.assign({}, modifiedStyle, toStyle) : modifiedStyle,
|
|
146
|
+
];
|
|
142
147
|
}
|
|
143
148
|
|
|
144
149
|
public stop() {
|
package/src/runtime/data.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Graph as GraphLib } from '@antv/graphlib';
|
|
2
|
-
import {
|
|
2
|
+
import { isUndefined, uniq } from '@antv/util';
|
|
3
3
|
import { COMBO_KEY, ChangeType, TREE_KEY } from '../constants';
|
|
4
4
|
import type { ComboData, EdgeData, GraphData, NodeData } from '../spec';
|
|
5
5
|
import type {
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
} from '../types';
|
|
21
21
|
import type { EdgeDirection } from '../types/edge';
|
|
22
22
|
import type { ElementType } from '../types/element';
|
|
23
|
-
import { cloneElementData, mergeElementsData } from '../utils/data';
|
|
23
|
+
import { cloneElementData, isElementDataEqual, mergeElementsData } from '../utils/data';
|
|
24
24
|
import { arrayDiff } from '../utils/diff';
|
|
25
25
|
import { toG6Data, toGraphlibData } from '../utils/graphlib';
|
|
26
26
|
import { idOf, parentIdOf } from '../utils/id';
|
|
@@ -166,6 +166,10 @@ export class DataController {
|
|
|
166
166
|
}, [] as ComboData[]);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
public getRootsData(hierarchyKey: HierarchyKey = TREE_KEY) {
|
|
170
|
+
return this.model.getRoots(hierarchyKey).map(toG6Data);
|
|
171
|
+
}
|
|
172
|
+
|
|
169
173
|
public getAncestorsData(id: ID, hierarchyKey: HierarchyKey): NodeLikeData[] {
|
|
170
174
|
const { model } = this;
|
|
171
175
|
if (!model.hasNode(id) || !model.hasTreeStructure(hierarchyKey)) return [];
|
|
@@ -292,9 +296,9 @@ export class DataController {
|
|
|
292
296
|
const { nodes: modifiedNodes = [], edges: modifiedEdges = [], combos: modifiedCombos = [] } = data;
|
|
293
297
|
const { nodes: originalNodes, edges: originalEdges, combos: originalCombos } = this.getData();
|
|
294
298
|
|
|
295
|
-
const nodeDiff = arrayDiff(originalNodes, modifiedNodes, (node) => idOf(node));
|
|
296
|
-
const edgeDiff = arrayDiff(originalEdges, modifiedEdges, (edge) => idOf(edge));
|
|
297
|
-
const comboDiff = arrayDiff(originalCombos, modifiedCombos, (combo) => idOf(combo));
|
|
299
|
+
const nodeDiff = arrayDiff(originalNodes, modifiedNodes, (node) => idOf(node), isElementDataEqual);
|
|
300
|
+
const edgeDiff = arrayDiff(originalEdges, modifiedEdges, (edge) => idOf(edge), isElementDataEqual);
|
|
301
|
+
const comboDiff = arrayDiff(originalCombos, modifiedCombos, (combo) => idOf(combo), isElementDataEqual);
|
|
298
302
|
|
|
299
303
|
this.batch(() => {
|
|
300
304
|
this.addData({
|
|
@@ -381,13 +385,16 @@ export class DataController {
|
|
|
381
385
|
|
|
382
386
|
data.forEach((datum) => {
|
|
383
387
|
const id = idOf(datum);
|
|
388
|
+
const parent = parentIdOf(datum);
|
|
384
389
|
|
|
385
|
-
|
|
386
|
-
|
|
390
|
+
if (parent) {
|
|
391
|
+
if (!model.hasTreeStructure(COMBO_KEY)) model.attachTreeStructure(COMBO_KEY);
|
|
392
|
+
this.setParent(id, parentIdOf(datum), COMBO_KEY);
|
|
393
|
+
}
|
|
387
394
|
|
|
388
|
-
const children = (datum as NodeData).children;
|
|
389
|
-
if (children
|
|
390
|
-
model.attachTreeStructure(TREE_KEY);
|
|
395
|
+
const children = (datum as NodeData).children || [];
|
|
396
|
+
if (children.length) {
|
|
397
|
+
if (!model.hasTreeStructure(TREE_KEY)) model.attachTreeStructure(TREE_KEY);
|
|
391
398
|
const _children = children.filter((child) => model.hasNode(child));
|
|
392
399
|
_children.forEach((child) => this.setParent(child, id, TREE_KEY));
|
|
393
400
|
if (_children.length !== children.length) {
|
|
@@ -430,7 +437,7 @@ export class DataController {
|
|
|
430
437
|
nodes.forEach((modifiedNode) => {
|
|
431
438
|
const id = idOf(modifiedNode);
|
|
432
439
|
const originalNode = toG6Data(model.getNode(id));
|
|
433
|
-
if (
|
|
440
|
+
if (isElementDataEqual(originalNode, modifiedNode)) return;
|
|
434
441
|
|
|
435
442
|
const value = mergeElementsData(originalNode, modifiedNode);
|
|
436
443
|
this.pushChange({ value, original: originalNode, type: ChangeType.NodeUpdated });
|
|
@@ -476,7 +483,7 @@ export class DataController {
|
|
|
476
483
|
edges.forEach((modifiedEdge) => {
|
|
477
484
|
const id = idOf(modifiedEdge);
|
|
478
485
|
const originalEdge = toG6Data(model.getEdge(id));
|
|
479
|
-
if (
|
|
486
|
+
if (isElementDataEqual(originalEdge, modifiedEdge)) return;
|
|
480
487
|
|
|
481
488
|
if (modifiedEdge.source && originalEdge.source !== modifiedEdge.source) {
|
|
482
489
|
model.updateEdgeSource(id, modifiedEdge.source);
|
|
@@ -499,7 +506,7 @@ export class DataController {
|
|
|
499
506
|
combos.forEach((modifiedCombo) => {
|
|
500
507
|
const id = idOf(modifiedCombo);
|
|
501
508
|
const originalCombo = toG6Data(model.getNode(id)) as ComboData;
|
|
502
|
-
if (
|
|
509
|
+
if (isElementDataEqual(originalCombo, modifiedCombo)) return;
|
|
503
510
|
|
|
504
511
|
const value = mergeElementsData(originalCombo, modifiedCombo);
|
|
505
512
|
this.pushChange({ value, original: originalCombo, type: ChangeType.ComboUpdated });
|