@antv/g6 5.0.0-beta.25 → 5.0.0-beta.27
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/esm/constant/shape.d.ts +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.d.ts +6 -4
- package/esm/item/combo.js +10 -3
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +12 -4
- package/esm/item/edge.js +100 -17
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +18 -8
- package/esm/item/item.js +121 -62
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +10 -4
- package/esm/item/node.js +92 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +5 -1
- package/esm/runtime/controller/data.js +38 -1
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/index.d.ts +1 -1
- package/esm/runtime/controller/index.js +1 -1
- package/esm/runtime/controller/index.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +22 -11
- package/esm/runtime/controller/item.js +241 -96
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.d.ts +3 -0
- package/esm/runtime/controller/layout.js +178 -98
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.d.ts +3 -0
- package/esm/runtime/controller/plugin.js +66 -24
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/controller/viewport.js +9 -2
- package/esm/runtime/controller/viewport.js.map +1 -1
- package/esm/runtime/graph.d.ts +57 -26
- package/esm/runtime/graph.js +263 -139
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +9 -3
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +6 -3
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.js +8 -8
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +4 -0
- package/esm/stdlib/behavior/drag-node.js +121 -27
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.js +3 -3
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +3 -3
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/validateData.js +2 -2
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +2 -0
- package/esm/stdlib/index.js +3 -1
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +2 -11
- package/esm/stdlib/item/edge/base.js +12 -105
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +2 -20
- package/esm/stdlib/item/node/base.js +10 -150
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/esm/stdlib/plugin/fisheye/index.js +3 -2
- package/esm/stdlib/plugin/fisheye/index.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/hull/index.d.ts +1 -1
- package/esm/stdlib/plugin/index.d.ts +1 -0
- package/esm/stdlib/plugin/index.js +1 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/lodController/index.d.ts +73 -0
- package/esm/stdlib/plugin/lodController/index.js +556 -0
- package/esm/stdlib/plugin/lodController/index.js.map +1 -0
- package/esm/stdlib/plugin/menu/index.js +2 -1
- package/esm/stdlib/plugin/menu/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.js +12 -14
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/esm/stdlib/plugin/toolbar/index.js +27 -29
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/theme/dark.js +32 -35
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +27 -30
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/stdlib/themeSolver/spec.js +2 -2
- package/esm/stdlib/themeSolver/spec.js.map +1 -1
- package/esm/types/animate.d.ts +1 -1
- package/esm/types/combo.d.ts +2 -2
- package/esm/types/edge.d.ts +2 -2
- package/esm/types/graph.d.ts +62 -43
- package/esm/types/hook.d.ts +5 -0
- package/esm/types/item.d.ts +9 -15
- package/esm/types/layout.d.ts +7 -2
- package/esm/types/layout.js.map +1 -1
- package/esm/types/node.d.ts +3 -2
- package/esm/types/plugin.d.ts +1 -0
- package/esm/types/plugin.js +1 -0
- package/esm/types/plugin.js.map +1 -1
- package/esm/types/spec.d.ts +1 -0
- package/esm/types/theme.d.ts +7 -7
- package/esm/util/animate.d.ts +7 -2
- package/esm/util/animate.js +40 -23
- package/esm/util/animate.js.map +1 -1
- package/esm/util/bbox.d.ts +7 -1
- package/esm/util/bbox.js +16 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/data.d.ts +7 -1
- package/esm/util/data.js +17 -5
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.js +5 -5
- package/esm/util/dom.js.map +1 -1
- package/esm/util/item.d.ts +1 -1
- package/esm/util/item.js +8 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/mapper.js +1 -1
- package/esm/util/mapper.js.map +1 -1
- package/esm/util/path.d.ts +6 -1
- package/esm/util/path.js +72 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/polyline.d.ts +10 -0
- package/esm/util/polyline.js +22 -17
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/router.js +19 -18
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +1 -1
- package/esm/util/shape.js +28 -13
- package/esm/util/shape.js.map +1 -1
- package/esm/util/zoom.d.ts +5 -8
- package/esm/util/zoom.js +15 -20
- package/esm/util/zoom.js.map +1 -1
- package/lib/constant/shape.d.ts +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.d.ts +6 -4
- package/lib/item/combo.js +10 -3
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +12 -4
- package/lib/item/edge.js +99 -16
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +18 -8
- package/lib/item/item.js +119 -60
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +10 -4
- package/lib/item/node.js +92 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +5 -1
- package/lib/runtime/controller/data.js +38 -1
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/index.d.ts +1 -1
- package/lib/runtime/controller/index.js +1 -1
- package/lib/runtime/controller/index.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +22 -11
- package/lib/runtime/controller/item.js +238 -93
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.d.ts +3 -0
- package/lib/runtime/controller/layout.js +178 -98
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.d.ts +3 -0
- package/lib/runtime/controller/plugin.js +66 -24
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/controller/viewport.js +9 -2
- package/lib/runtime/controller/viewport.js.map +1 -1
- package/lib/runtime/graph.d.ts +57 -26
- package/lib/runtime/graph.js +263 -139
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +9 -3
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +6 -3
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.js +8 -8
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +4 -0
- package/lib/stdlib/behavior/drag-node.js +121 -27
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.js +3 -3
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +3 -3
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/validateData.js +2 -2
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +2 -0
- package/lib/stdlib/index.js +3 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +2 -11
- package/lib/stdlib/item/edge/base.js +12 -105
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +2 -20
- package/lib/stdlib/item/node/base.js +10 -150
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/lib/stdlib/plugin/fisheye/index.js +2 -1
- package/lib/stdlib/plugin/fisheye/index.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/hull/index.d.ts +1 -1
- package/lib/stdlib/plugin/index.d.ts +1 -0
- package/lib/stdlib/plugin/index.js +1 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/lodController/index.d.ts +73 -0
- package/lib/stdlib/plugin/lodController/index.js +560 -0
- package/lib/stdlib/plugin/lodController/index.js.map +1 -0
- package/lib/stdlib/plugin/menu/index.js +2 -1
- package/lib/stdlib/plugin/menu/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.js +12 -14
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/lib/stdlib/plugin/toolbar/index.js +27 -29
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/theme/dark.js +32 -35
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +27 -30
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/stdlib/themeSolver/spec.js +2 -2
- package/lib/stdlib/themeSolver/spec.js.map +1 -1
- package/lib/types/animate.d.ts +1 -1
- package/lib/types/combo.d.ts +2 -2
- package/lib/types/edge.d.ts +2 -2
- package/lib/types/graph.d.ts +62 -43
- package/lib/types/hook.d.ts +5 -0
- package/lib/types/item.d.ts +9 -15
- package/lib/types/layout.d.ts +7 -2
- package/lib/types/layout.js.map +1 -1
- package/lib/types/node.d.ts +3 -2
- package/lib/types/plugin.d.ts +1 -0
- package/lib/types/plugin.js +1 -0
- package/lib/types/plugin.js.map +1 -1
- package/lib/types/spec.d.ts +1 -0
- package/lib/types/theme.d.ts +7 -7
- package/lib/util/animate.d.ts +7 -2
- package/lib/util/animate.js +40 -23
- package/lib/util/animate.js.map +1 -1
- package/lib/util/bbox.d.ts +7 -1
- package/lib/util/bbox.js +18 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/data.d.ts +7 -1
- package/lib/util/data.js +19 -6
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.js +5 -5
- package/lib/util/dom.js.map +1 -1
- package/lib/util/item.d.ts +1 -1
- package/lib/util/item.js +8 -8
- package/lib/util/item.js.map +1 -1
- package/lib/util/mapper.js +1 -1
- package/lib/util/mapper.js.map +1 -1
- package/lib/util/path.d.ts +6 -1
- package/lib/util/path.js +72 -1
- package/lib/util/path.js.map +1 -1
- package/lib/util/polyline.d.ts +10 -0
- package/lib/util/polyline.js +25 -18
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/router.js +19 -18
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +1 -1
- package/lib/util/shape.js +27 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/zoom.d.ts +5 -8
- package/lib/util/zoom.js +17 -22
- package/lib/util/zoom.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/item/combo.ts +13 -5
- package/src/item/edge.ts +126 -17
- package/src/item/item.ts +140 -57
- package/src/item/node.ts +109 -12
- package/src/runtime/controller/data.ts +64 -3
- package/src/runtime/controller/index.ts +1 -1
- package/src/runtime/controller/item.ts +321 -135
- package/src/runtime/controller/layout.ts +254 -113
- package/src/runtime/controller/plugin.ts +86 -33
- package/src/runtime/controller/viewport.ts +8 -2
- package/src/runtime/graph.ts +383 -158
- package/src/stdlib/behavior/click-select.ts +8 -3
- package/src/stdlib/behavior/drag-canvas.ts +6 -3
- package/src/stdlib/behavior/drag-combo.ts +8 -8
- package/src/stdlib/behavior/drag-node.ts +165 -50
- package/src/stdlib/behavior/scroll-canvas.ts +3 -3
- package/src/stdlib/behavior/zoom-canvas.ts +3 -3
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/validateData.ts +2 -2
- package/src/stdlib/index.ts +3 -0
- package/src/stdlib/item/edge/base.ts +15 -139
- package/src/stdlib/item/node/base.ts +20 -215
- package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
- package/src/stdlib/plugin/fisheye/index.ts +3 -2
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/lodController/index.ts +602 -0
- package/src/stdlib/plugin/menu/index.ts +1 -1
- package/src/stdlib/plugin/minimap/index.ts +12 -14
- package/src/stdlib/plugin/toolbar/index.ts +29 -31
- package/src/stdlib/theme/dark.ts +32 -34
- package/src/stdlib/theme/light.ts +27 -29
- package/src/stdlib/themeSolver/spec.ts +2 -2
- package/src/types/animate.ts +1 -1
- package/src/types/combo.ts +2 -2
- package/src/types/edge.ts +2 -2
- package/src/types/graph.ts +65 -53
- package/src/types/hook.ts +5 -0
- package/src/types/item.ts +8 -14
- package/src/types/layout.ts +20 -15
- package/src/types/node.ts +3 -2
- package/src/types/plugin.ts +2 -0
- package/src/types/spec.ts +1 -0
- package/src/types/theme.ts +7 -7
- package/src/util/animate.ts +104 -75
- package/src/util/bbox.ts +26 -1
- package/src/util/data.ts +15 -6
- package/src/util/dom.ts +6 -6
- package/src/util/item.ts +15 -1
- package/src/util/mapper.ts +1 -1
- package/src/util/path.ts +72 -2
- package/src/util/polyline.ts +30 -23
- package/src/util/router.ts +21 -19
- package/src/util/shape.ts +27 -12
- package/src/util/zoom.ts +19 -25
- package/esm/runtime/controller/extension.d.ts +0 -9
- package/esm/runtime/controller/extension.js +0 -11
- package/esm/runtime/controller/extension.js.map +0 -1
- package/lib/runtime/controller/extension.d.ts +0 -9
- package/lib/runtime/controller/extension.js +0 -15
- package/lib/runtime/controller/extension.js.map +0 -1
- package/src/runtime/controller/extension.ts +0 -14
package/src/item/node.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Group } from '@antv/g';
|
|
2
|
-
import { clone } from '@antv/util';
|
|
2
|
+
import { clone, debounce, throttle } from '@antv/util';
|
|
3
3
|
import { Point } from '../types/common';
|
|
4
|
-
import { ComboDisplayModel, ComboModel, NodeModel } from '../types';
|
|
5
|
-
import { DisplayMapper, State,
|
|
4
|
+
import { ComboDisplayModel, ComboModel, IGraph, NodeModel } from '../types';
|
|
5
|
+
import { DisplayMapper, State, LodLevelRanges } from '../types/item';
|
|
6
6
|
import { NodeDisplayModel, NodeModelData } from '../types/node';
|
|
7
7
|
import { ComboStyleSet, NodeStyleSet } from '../types/theme';
|
|
8
8
|
import { updateShapes } from '../util/shape';
|
|
@@ -17,9 +17,11 @@ import { ComboModelData } from '../types/combo';
|
|
|
17
17
|
import Item from './item';
|
|
18
18
|
|
|
19
19
|
interface IProps {
|
|
20
|
+
graph: IGraph;
|
|
20
21
|
model: NodeModel | ComboModel;
|
|
21
22
|
renderExtensions: any;
|
|
22
23
|
containerGroup: Group;
|
|
24
|
+
labelContainerGroup?: Group; // TODO: optional?
|
|
23
25
|
mapper?: DisplayMapper;
|
|
24
26
|
stateMapper?: {
|
|
25
27
|
[stateName: string]: DisplayMapper;
|
|
@@ -27,7 +29,7 @@ interface IProps {
|
|
|
27
29
|
zoom?: number;
|
|
28
30
|
theme: {
|
|
29
31
|
styles: NodeStyleSet | ComboStyleSet;
|
|
30
|
-
|
|
32
|
+
lodLevels: LodLevelRanges;
|
|
31
33
|
};
|
|
32
34
|
device?: any; // for 3d shapes
|
|
33
35
|
onframe?: Function;
|
|
@@ -61,7 +63,14 @@ export default class Node extends Item {
|
|
|
61
63
|
animate = true,
|
|
62
64
|
onfinish: Function = () => {},
|
|
63
65
|
) {
|
|
64
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
group,
|
|
68
|
+
labelGroup,
|
|
69
|
+
renderExt,
|
|
70
|
+
shapeMap: prevShapeMap,
|
|
71
|
+
model,
|
|
72
|
+
graph,
|
|
73
|
+
} = this;
|
|
65
74
|
renderExt.mergeStyles(displayModel);
|
|
66
75
|
|
|
67
76
|
const firstRendering = !this.shapeMap?.keyShape;
|
|
@@ -71,9 +80,16 @@ export default class Node extends Item {
|
|
|
71
80
|
diffData,
|
|
72
81
|
diffState,
|
|
73
82
|
);
|
|
83
|
+
if (this.shapeMap.labelShape) {
|
|
84
|
+
this.shapeMap.labelShape.attributes.dataIsLabel = true;
|
|
85
|
+
}
|
|
86
|
+
if (this.shapeMap.labelBackgroundShape) {
|
|
87
|
+
this.shapeMap.labelBackgroundShape.attributes.dataIsLabelBackground =
|
|
88
|
+
true;
|
|
89
|
+
}
|
|
74
90
|
|
|
75
91
|
// add shapes to group, and update shapeMap
|
|
76
|
-
this.shapeMap = updateShapes(prevShapeMap, shapeMap, group);
|
|
92
|
+
this.shapeMap = updateShapes(prevShapeMap, shapeMap, group, labelGroup);
|
|
77
93
|
|
|
78
94
|
const { animates, disableAnimate, x = 0, y = 0, z = 0 } = displayModel.data;
|
|
79
95
|
if (firstRendering) {
|
|
@@ -81,6 +97,10 @@ export default class Node extends Item {
|
|
|
81
97
|
group.style.x = x;
|
|
82
98
|
group.style.y = y;
|
|
83
99
|
group.style.z = z;
|
|
100
|
+
const viewportPosition = graph.getViewportByCanvas({ x, y, z });
|
|
101
|
+
labelGroup.style.x = viewportPosition.x;
|
|
102
|
+
labelGroup.style.y = viewportPosition.y;
|
|
103
|
+
labelGroup.style.z = viewportPosition.z;
|
|
84
104
|
} else {
|
|
85
105
|
// terminate previous animations
|
|
86
106
|
this.stopAnimations();
|
|
@@ -105,13 +125,18 @@ export default class Node extends Item {
|
|
|
105
125
|
animatesExcludePosition, // animates
|
|
106
126
|
renderExt.mergedStyles, // targetStylesMap
|
|
107
127
|
this.shapeMap, // shapeMap
|
|
108
|
-
|
|
128
|
+
undefined,
|
|
129
|
+
[group, labelGroup],
|
|
109
130
|
firstRendering ? 'buildIn' : 'update',
|
|
110
|
-
this.changedStates,
|
|
131
|
+
diffState?.current.map((state) => state.name) || this.changedStates,
|
|
111
132
|
this.animateFrameListener,
|
|
112
133
|
(canceled) => onfinish(model.id, canceled),
|
|
113
134
|
);
|
|
114
135
|
}
|
|
136
|
+
this.labelGroup.children
|
|
137
|
+
.filter((element) => element.attributes.dataIsLabel)
|
|
138
|
+
.forEach((shape) => (shape.attributes.dataOriginPosition = ''));
|
|
139
|
+
this.updateLabelPosition(true);
|
|
115
140
|
}
|
|
116
141
|
|
|
117
142
|
/**
|
|
@@ -127,7 +152,7 @@ export default class Node extends Item {
|
|
|
127
152
|
animate?: boolean,
|
|
128
153
|
onfinish: Function = () => {},
|
|
129
154
|
) {
|
|
130
|
-
const { group } = this;
|
|
155
|
+
const { group, labelGroup, graph } = this;
|
|
131
156
|
const {
|
|
132
157
|
fx,
|
|
133
158
|
fy,
|
|
@@ -149,6 +174,10 @@ export default class Node extends Item {
|
|
|
149
174
|
isNaN(position.z as number)
|
|
150
175
|
)
|
|
151
176
|
return;
|
|
177
|
+
const viewportPosition = graph.getViewportByCanvas(position);
|
|
178
|
+
labelGroup.style.x = viewportPosition.x;
|
|
179
|
+
labelGroup.style.y = viewportPosition.y;
|
|
180
|
+
labelGroup.style.z = viewportPosition.z || 0;
|
|
152
181
|
if (animate && !disableAnimate && animates?.update) {
|
|
153
182
|
const groupAnimates = animates.update.filter(
|
|
154
183
|
({ shapeId, fields = [] }) =>
|
|
@@ -160,7 +189,8 @@ export default class Node extends Item {
|
|
|
160
189
|
{ update: groupAnimates },
|
|
161
190
|
{ group: position } as any, // targetStylesMap
|
|
162
191
|
this.shapeMap, // shapeMap
|
|
163
|
-
|
|
192
|
+
undefined,
|
|
193
|
+
[group],
|
|
164
194
|
'update',
|
|
165
195
|
[],
|
|
166
196
|
this.animateFrameListener,
|
|
@@ -175,12 +205,74 @@ export default class Node extends Item {
|
|
|
175
205
|
group.style.z = position.z;
|
|
176
206
|
onfinish(displayModel.id, !animate);
|
|
177
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Update label positions on label canvas by getting viewport position from transformed canvas position.
|
|
210
|
+
*/
|
|
211
|
+
public updateLabelPosition(ignoreVisibility?: boolean) {
|
|
212
|
+
if (!ignoreVisibility && this.labelGroup.style.visibility === 'hidden') {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const { graph, group, labelGroup, displayModel, shapeMap, renderExt } =
|
|
216
|
+
this;
|
|
217
|
+
|
|
218
|
+
let [x, y, z] = group.getPosition();
|
|
219
|
+
if (group.getAnimations().length) {
|
|
220
|
+
const { x: dataX, y: dataY, z: dataZ } = displayModel.data;
|
|
221
|
+
x = dataX as number;
|
|
222
|
+
y = dataY as number;
|
|
223
|
+
z = dataZ as number;
|
|
224
|
+
}
|
|
225
|
+
const zoom = graph.getZoom();
|
|
226
|
+
const { x: vx, y: vy, z: vz } = graph.getViewportByCanvas({ x, y, z });
|
|
227
|
+
if (labelGroup.style.x !== vx) {
|
|
228
|
+
labelGroup.style.x = vx;
|
|
229
|
+
}
|
|
230
|
+
if (labelGroup.style.y !== vy) {
|
|
231
|
+
labelGroup.style.y = vy;
|
|
232
|
+
}
|
|
233
|
+
if (labelGroup.style.z !== vz) {
|
|
234
|
+
labelGroup.style.z = vz;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
labelGroup.children.forEach((shape) => {
|
|
238
|
+
if (shape.attributes.dataIsLabelBackground) {
|
|
239
|
+
renderExt.drawLabelBackgroundShape(displayModel, shapeMap);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (shape.attributes.dataIsLabel) {
|
|
243
|
+
// this.throttleUpdateWordWidth(zoom, shape);
|
|
244
|
+
const { wordWrapWidth } = shape.style;
|
|
245
|
+
if (wordWrapWidth) {
|
|
246
|
+
if (!shape.attributes.dataOriginWordWrapWidth) {
|
|
247
|
+
shape.style.dataOriginWordWrapWidth = wordWrapWidth;
|
|
248
|
+
}
|
|
249
|
+
const originWordWrapWidth = shape.attributes.dataOriginWordWrapWidth;
|
|
250
|
+
shape.style.wordWrapWidth = originWordWrapWidth * zoom;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (!shape.attributes.dataOriginPosition) {
|
|
254
|
+
shape.attributes.dataOriginPosition = {
|
|
255
|
+
x: shape.style.x,
|
|
256
|
+
y: shape.style.y,
|
|
257
|
+
z: shape.style.z,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
const originPosition = shape.attributes.dataOriginPosition;
|
|
261
|
+
Object.keys(originPosition).forEach((field) => {
|
|
262
|
+
if (!isNaN(shape.style[field])) {
|
|
263
|
+
shape.style[field] = originPosition[field] * zoom;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
178
268
|
|
|
179
269
|
public clone(
|
|
180
270
|
containerGroup: Group,
|
|
271
|
+
labelContainerGroup: Group,
|
|
181
272
|
shapeIds?: string[],
|
|
182
273
|
disableAnimate?: boolean,
|
|
183
274
|
) {
|
|
275
|
+
// clone specific shapes but not the whole item
|
|
184
276
|
if (shapeIds?.length) {
|
|
185
277
|
const group = new Group();
|
|
186
278
|
shapeIds.forEach((shapeId) => {
|
|
@@ -199,19 +291,24 @@ export default class Node extends Item {
|
|
|
199
291
|
clonedModel.data.disableAnimate = disableAnimate;
|
|
200
292
|
const clonedNode = new Node({
|
|
201
293
|
model: clonedModel,
|
|
294
|
+
graph: this.graph,
|
|
202
295
|
renderExtensions: this.renderExtensions,
|
|
203
296
|
containerGroup,
|
|
297
|
+
labelContainerGroup,
|
|
204
298
|
mapper: this.mapper,
|
|
205
299
|
stateMapper: this.stateMapper,
|
|
206
300
|
zoom: this.zoom,
|
|
207
301
|
theme: {
|
|
208
302
|
styles: this.themeStyles,
|
|
209
|
-
|
|
303
|
+
lodLevels: this.lodLevels,
|
|
210
304
|
},
|
|
211
305
|
});
|
|
212
306
|
Object.keys(this.shapeMap).forEach((shapeId) => {
|
|
213
|
-
if (!this.shapeMap[shapeId].isVisible())
|
|
307
|
+
if (!this.shapeMap[shapeId].isVisible()) {
|
|
214
308
|
clonedNode.shapeMap[shapeId].hide();
|
|
309
|
+
} else {
|
|
310
|
+
clonedNode.shapeMap[shapeId]?.show();
|
|
311
|
+
}
|
|
215
312
|
});
|
|
216
313
|
return clonedNode;
|
|
217
314
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Graph as GraphLib, ID } from '@antv/graphlib';
|
|
2
2
|
import { clone, isArray, isEmpty, isObject } from '@antv/util';
|
|
3
|
+
import { AABB } from '@antv/g';
|
|
3
4
|
import { registery as registry } from '../../stdlib';
|
|
4
5
|
import {
|
|
5
6
|
ComboModel,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
InlineTreeDataConfig,
|
|
20
21
|
} from '../../types/data';
|
|
21
22
|
import {
|
|
23
|
+
EdgeDisplayModel,
|
|
22
24
|
EdgeModel,
|
|
23
25
|
EdgeModelData,
|
|
24
26
|
EdgeUserModel,
|
|
@@ -43,9 +45,12 @@ import {
|
|
|
43
45
|
validateComboStrucutre,
|
|
44
46
|
} from '../../util/data';
|
|
45
47
|
import { getExtension } from '../../util/extension';
|
|
46
|
-
import { convertToNumber } from '../../util/type';
|
|
47
48
|
import { isTreeLayout } from '../../util/layout';
|
|
48
49
|
import { hasTreeBehaviors } from '../../util/behavior';
|
|
50
|
+
import { EdgeCollisionChecker, QuadTree } from '../../util/polyline';
|
|
51
|
+
import Node from '../../item/node';
|
|
52
|
+
import Edge from '../../item/edge';
|
|
53
|
+
import Combo from '../../item/combo';
|
|
49
54
|
|
|
50
55
|
/**
|
|
51
56
|
* Manages the data transform extensions;
|
|
@@ -140,6 +145,60 @@ export class DataController {
|
|
|
140
145
|
) {
|
|
141
146
|
return this.graphCore.getRelatedEdges(nodeId, direction);
|
|
142
147
|
}
|
|
148
|
+
|
|
149
|
+
public findNearEdges(
|
|
150
|
+
nodeId: ID,
|
|
151
|
+
itemMap: Map<ID, Node | Edge | Combo>,
|
|
152
|
+
transientItem?: Node,
|
|
153
|
+
shouldBegin?: (edge: EdgeDisplayModel) => boolean,
|
|
154
|
+
): EdgeModel[] {
|
|
155
|
+
const edges = this.graphCore.getAllEdges();
|
|
156
|
+
|
|
157
|
+
const canvasBBox = this.graph.getRenderBBox(undefined) as AABB;
|
|
158
|
+
const quadTree = new QuadTree(canvasBBox, 4);
|
|
159
|
+
|
|
160
|
+
edges.forEach((edge) => {
|
|
161
|
+
// @ts-ignore
|
|
162
|
+
const edgeDisplayModel = itemMap.get(edge.id)
|
|
163
|
+
.displayModel as EdgeDisplayModel;
|
|
164
|
+
if (!shouldBegin(edgeDisplayModel)) return;
|
|
165
|
+
|
|
166
|
+
const {
|
|
167
|
+
data: { x: sourceX, y: sourceY },
|
|
168
|
+
} = this.graphCore.getNode(edge.source);
|
|
169
|
+
const {
|
|
170
|
+
data: { x: targetX, y: targetY },
|
|
171
|
+
} = this.graphCore.getNode(edge.target);
|
|
172
|
+
|
|
173
|
+
quadTree.insert({
|
|
174
|
+
id: edge.id,
|
|
175
|
+
p1: { x: sourceX, y: sourceY },
|
|
176
|
+
p2: { x: targetX, y: targetY },
|
|
177
|
+
bbox: this.graph.getRenderBBox(edge.id) as AABB,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
const nodeBBox = this.graph.getRenderBBox(nodeId) as AABB;
|
|
181
|
+
|
|
182
|
+
if (transientItem) {
|
|
183
|
+
// @ts-ignore
|
|
184
|
+
const nodeData = transientItem.displayModel.data;
|
|
185
|
+
if (nodeData) {
|
|
186
|
+
nodeBBox.update(
|
|
187
|
+
[nodeData.x as number, nodeData.y as number, 0],
|
|
188
|
+
nodeBBox.halfExtents,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const checker = new EdgeCollisionChecker(quadTree);
|
|
194
|
+
const collisions = checker.getCollidingEdges(nodeBBox);
|
|
195
|
+
const collidingEdges = collisions.map((collision) =>
|
|
196
|
+
this.graphCore.getEdge(collision.id),
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
return collidingEdges;
|
|
200
|
+
}
|
|
201
|
+
|
|
143
202
|
public findNeighborNodes(
|
|
144
203
|
nodeId: ID,
|
|
145
204
|
direction: 'in' | 'out' | 'both' = 'both',
|
|
@@ -177,7 +236,9 @@ export class DataController {
|
|
|
177
236
|
*/
|
|
178
237
|
private getExtensions() {
|
|
179
238
|
const { transforms = [] } = this.graph.getSpecification();
|
|
180
|
-
const requiredTransformers = [
|
|
239
|
+
const requiredTransformers = [
|
|
240
|
+
{ type: 'validate-data', activeLifecycle: 'all' },
|
|
241
|
+
];
|
|
181
242
|
return [...transforms, ...requiredTransformers]
|
|
182
243
|
.map((config) => ({
|
|
183
244
|
config,
|
|
@@ -403,6 +464,7 @@ export class DataController {
|
|
|
403
464
|
|
|
404
465
|
// update edge
|
|
405
466
|
edges.forEach((newModel) => {
|
|
467
|
+
if (!graphCore.hasEdge(newModel.id)) return;
|
|
406
468
|
const oldModel = graphCore.getEdge(newModel.id);
|
|
407
469
|
if (!oldModel) return;
|
|
408
470
|
const { id, source, target, data } = newModel;
|
|
@@ -720,7 +782,6 @@ export class DataController {
|
|
|
720
782
|
: activeLifecycle === 'all'
|
|
721
783
|
? AVAILABLE_DATA_LIFECYCLE
|
|
722
784
|
: [activeLifecycle];
|
|
723
|
-
|
|
724
785
|
return (activeLifecycle as string[]).includes(dataLifecycleMap[changeType]);
|
|
725
786
|
};
|
|
726
787
|
|