@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/item.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Group, DisplayObject, AABB, IAnimation } from '@antv/g';
|
|
2
|
-
import { clone, isFunction, isObject, throttle } from '@antv/util';
|
|
2
|
+
import { clone, isFunction, isObject, pick, throttle } from '@antv/util';
|
|
3
3
|
import { OTHER_SHAPES_FIELD_NAME, RESERVED_SHAPE_IDS } from '../constant';
|
|
4
4
|
import { EdgeShapeMap } from '../types/edge';
|
|
5
5
|
import {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ItemShapeStyles,
|
|
12
12
|
ITEM_TYPE,
|
|
13
13
|
State,
|
|
14
|
-
|
|
14
|
+
LodLevelRanges,
|
|
15
15
|
} from '../types/item';
|
|
16
16
|
import { NodeShapeMap } from '../types/node';
|
|
17
17
|
import { EdgeStyleSet, NodeStyleSet } from '../types/theme';
|
|
@@ -24,16 +24,19 @@ import {
|
|
|
24
24
|
} from '../util/shape';
|
|
25
25
|
import { isEncode } from '../util/type';
|
|
26
26
|
import { DEFAULT_MAPPER } from '../util/mapper';
|
|
27
|
+
import { cloneJSON } from '../util/data';
|
|
27
28
|
import {
|
|
28
29
|
getShapeAnimateBeginStyles,
|
|
29
30
|
animateShapes,
|
|
30
31
|
GROUP_ANIMATE_STYLES,
|
|
31
32
|
stopAnimate,
|
|
32
33
|
} from '../util/animate';
|
|
33
|
-
import { AnimateTiming, IAnimates } from '../types/animate';
|
|
34
|
-
import {
|
|
34
|
+
import { AnimateTiming, IAnimates, IStateAnimate } from '../types/animate';
|
|
35
|
+
import { formatLodLevels } from '../util/zoom';
|
|
36
|
+
import { IGraph } from '../types';
|
|
35
37
|
|
|
36
38
|
export default abstract class Item implements IItem {
|
|
39
|
+
public graph: IGraph;
|
|
37
40
|
public destroyed = false;
|
|
38
41
|
/** Inner model. */
|
|
39
42
|
public model: ItemModel;
|
|
@@ -47,6 +50,8 @@ export default abstract class Item implements IItem {
|
|
|
47
50
|
};
|
|
48
51
|
/** The graphic group for item drawing. */
|
|
49
52
|
public group: Group;
|
|
53
|
+
/** The graphic group for item'label drawing. */
|
|
54
|
+
public labelGroup: Group;
|
|
50
55
|
/** The keyShape of the item. */
|
|
51
56
|
public keyShape: DisplayObject;
|
|
52
57
|
/** render extension for this item. */
|
|
@@ -62,7 +67,9 @@ export default abstract class Item implements IItem {
|
|
|
62
67
|
public shapeMap: NodeShapeMap | EdgeShapeMap = {
|
|
63
68
|
keyShape: undefined,
|
|
64
69
|
};
|
|
65
|
-
public afterDrawShapeMap
|
|
70
|
+
public afterDrawShapeMap: {
|
|
71
|
+
[otherShapeId: string]: DisplayObject;
|
|
72
|
+
} = {};
|
|
66
73
|
/** Set to different value in implements. */
|
|
67
74
|
public type: ITEM_TYPE;
|
|
68
75
|
/** The flag of transient item. */
|
|
@@ -78,7 +85,7 @@ export default abstract class Item implements IItem {
|
|
|
78
85
|
[stateName: string]: ItemShapeStyles;
|
|
79
86
|
};
|
|
80
87
|
/** The zoom strategy to show and hide shapes according to their lod. */
|
|
81
|
-
public
|
|
88
|
+
public lodLevels: LodLevelRanges;
|
|
82
89
|
/** Last zoom ratio. */
|
|
83
90
|
public zoom: number;
|
|
84
91
|
/** Cache the chaging states which are not consomed by draw */
|
|
@@ -102,8 +109,10 @@ export default abstract class Item implements IItem {
|
|
|
102
109
|
/** Initiate the item. */
|
|
103
110
|
public init(props) {
|
|
104
111
|
const {
|
|
112
|
+
graph,
|
|
105
113
|
model,
|
|
106
114
|
containerGroup,
|
|
115
|
+
labelContainerGroup,
|
|
107
116
|
mapper,
|
|
108
117
|
stateMapper,
|
|
109
118
|
renderExtensions,
|
|
@@ -112,10 +121,15 @@ export default abstract class Item implements IItem {
|
|
|
112
121
|
type: itemType,
|
|
113
122
|
} = props;
|
|
114
123
|
this.type = itemType;
|
|
124
|
+
this.graph = graph;
|
|
115
125
|
this.group = new Group({ style: { zIndex: 0 } });
|
|
126
|
+
this.labelGroup = new Group({ style: { zIndex: 0 } });
|
|
116
127
|
this.group.setAttribute('data-item-type', this.type);
|
|
117
128
|
this.group.setAttribute('data-item-id', props.model.id);
|
|
129
|
+
this.labelGroup.setAttribute('data-item-type', this.type);
|
|
130
|
+
this.labelGroup.setAttribute('data-item-id', props.model.id);
|
|
118
131
|
containerGroup.appendChild(this.group);
|
|
132
|
+
labelContainerGroup.appendChild(this.labelGroup);
|
|
119
133
|
this.model = model;
|
|
120
134
|
this.mapper = mapper;
|
|
121
135
|
this.zoom = zoom;
|
|
@@ -124,14 +138,14 @@ export default abstract class Item implements IItem {
|
|
|
124
138
|
this.renderExtensions = renderExtensions;
|
|
125
139
|
const {
|
|
126
140
|
type = this.type === 'edge' ? 'line-edge' : `circle-${this.type}`,
|
|
127
|
-
|
|
141
|
+
lodLevels: modelLodLevels,
|
|
128
142
|
enableBalanceShape,
|
|
129
143
|
} = this.displayModel.data;
|
|
130
144
|
const RenderExtension = renderExtensions.find((ext) => ext.type === type);
|
|
131
145
|
this.themeStyles = theme.styles;
|
|
132
|
-
|
|
133
|
-
?
|
|
134
|
-
: theme.
|
|
146
|
+
this.lodLevels = modelLodLevels
|
|
147
|
+
? formatLodLevels(modelLodLevels)
|
|
148
|
+
: theme.lodLevels;
|
|
135
149
|
if (!RenderExtension) {
|
|
136
150
|
if (this.type === 'node') {
|
|
137
151
|
throw new Error(
|
|
@@ -149,7 +163,7 @@ export default abstract class Item implements IItem {
|
|
|
149
163
|
}
|
|
150
164
|
this.renderExt = new RenderExtension({
|
|
151
165
|
themeStyles: this.themeStyles?.default,
|
|
152
|
-
|
|
166
|
+
lodLevels: this.lodLevels,
|
|
153
167
|
enableBalanceShape,
|
|
154
168
|
device: this.device,
|
|
155
169
|
zoom: this.zoom,
|
|
@@ -173,10 +187,18 @@ export default abstract class Item implements IItem {
|
|
|
173
187
|
...this.shapeMap,
|
|
174
188
|
...this.afterDrawShapeMap,
|
|
175
189
|
}) || {};
|
|
190
|
+
if (this.afterDrawShapeMap.labelShape) {
|
|
191
|
+
this.afterDrawShapeMap.labelShape.attributes.dataIsLabel = true;
|
|
192
|
+
}
|
|
193
|
+
if (this.afterDrawShapeMap.labelBackgroundShape) {
|
|
194
|
+
this.afterDrawShapeMap.labelBackgroundShape.attributes.dataIsLabelBackground =
|
|
195
|
+
true;
|
|
196
|
+
}
|
|
176
197
|
const shapeMap = updateShapes(
|
|
177
198
|
this.afterDrawShapeMap,
|
|
178
199
|
afterDrawShapeMap,
|
|
179
200
|
this.group,
|
|
201
|
+
this.labelGroup,
|
|
180
202
|
false,
|
|
181
203
|
(id) => {
|
|
182
204
|
if (RESERVED_SHAPE_IDS.includes(id)) {
|
|
@@ -192,6 +214,7 @@ export default abstract class Item implements IItem {
|
|
|
192
214
|
...this.shapeMap,
|
|
193
215
|
...shapeMap,
|
|
194
216
|
};
|
|
217
|
+
this.changedStates = [];
|
|
195
218
|
}
|
|
196
219
|
|
|
197
220
|
/**
|
|
@@ -204,7 +227,7 @@ export default abstract class Item implements IItem {
|
|
|
204
227
|
isReplace?: boolean,
|
|
205
228
|
itemTheme?: {
|
|
206
229
|
styles: NodeStyleSet | EdgeStyleSet;
|
|
207
|
-
|
|
230
|
+
lodLevels: LodLevelRanges;
|
|
208
231
|
},
|
|
209
232
|
onlyMove?: boolean,
|
|
210
233
|
animate = true,
|
|
@@ -223,9 +246,9 @@ export default abstract class Item implements IItem {
|
|
|
223
246
|
);
|
|
224
247
|
this.displayModel = displayModel;
|
|
225
248
|
|
|
226
|
-
this.
|
|
227
|
-
?
|
|
228
|
-
: itemTheme?.
|
|
249
|
+
this.lodLevels = displayModel.data.lodLevels
|
|
250
|
+
? formatLodLevels(displayModel.data.lodLevels)
|
|
251
|
+
: itemTheme?.lodLevels || this.lodLevels;
|
|
229
252
|
|
|
230
253
|
if (onlyMove) {
|
|
231
254
|
this.updatePosition(displayModel, diffData, animate, onfinish);
|
|
@@ -242,13 +265,13 @@ export default abstract class Item implements IItem {
|
|
|
242
265
|
);
|
|
243
266
|
this.renderExt = new RenderExtension({
|
|
244
267
|
themeStyles: this.themeStyles.default,
|
|
245
|
-
|
|
268
|
+
lodLevels: this.lodLevels,
|
|
246
269
|
device: this.device,
|
|
247
270
|
zoom: this.zoom,
|
|
248
271
|
});
|
|
249
272
|
} else {
|
|
250
273
|
this.renderExt.themeStyles = this.themeStyles.default;
|
|
251
|
-
this.renderExt.
|
|
274
|
+
this.renderExt.lodLevels = this.lodLevels;
|
|
252
275
|
}
|
|
253
276
|
// 3. call element update fn from useLib
|
|
254
277
|
if (this.states?.length) {
|
|
@@ -324,7 +347,7 @@ export default abstract class Item implements IItem {
|
|
|
324
347
|
// === fields' values in mapper are final value or Encode ===
|
|
325
348
|
const dataChangedFields = isReplace
|
|
326
349
|
? undefined
|
|
327
|
-
: Object.keys(current).concat(Object.keys(otherFields)); // only fields in current data for partial updating
|
|
350
|
+
: Object.keys(current || {}).concat(Object.keys(otherFields)); // only fields in current data for partial updating
|
|
328
351
|
|
|
329
352
|
let typeChange = false;
|
|
330
353
|
const { data, ...otherProps } = innerModel;
|
|
@@ -366,6 +389,7 @@ export default abstract class Item implements IItem {
|
|
|
366
389
|
displayModelData[fieldName] || isObject(innerModel.data[fieldName])
|
|
367
390
|
? {
|
|
368
391
|
...(innerModel.data[fieldName] as object),
|
|
392
|
+
...(this.displayModel?.data[fieldName] as object),
|
|
369
393
|
}
|
|
370
394
|
: {};
|
|
371
395
|
updateShapeChange({
|
|
@@ -417,10 +441,23 @@ export default abstract class Item implements IItem {
|
|
|
417
441
|
}
|
|
418
442
|
|
|
419
443
|
/** Show the item. */
|
|
420
|
-
public show(animate = true) {
|
|
421
|
-
|
|
444
|
+
public show(animate = true, shapeIds = undefined) {
|
|
445
|
+
const shapeIdsToStop = shapeIds?.filter((id) => {
|
|
446
|
+
const shape = this.shapeMap[id];
|
|
447
|
+
return shape && shape.style.visibility === 'hidden';
|
|
448
|
+
});
|
|
449
|
+
if (shapeIds?.length && !shapeIdsToStop?.length) return;
|
|
450
|
+
if (!shapeIdsToStop || shapeIdsToStop.includes('labelShape')) {
|
|
451
|
+
this.labelGroup.style.visibility = 'visible';
|
|
452
|
+
}
|
|
453
|
+
Promise.all(this.stopAnimations(shapeIdsToStop)).finally(() => {
|
|
422
454
|
if (this.destroyed) return;
|
|
423
455
|
const { animates = {} } = this.displayModel.data;
|
|
456
|
+
const shapeIdsToShow =
|
|
457
|
+
shapeIdsToStop ||
|
|
458
|
+
Object.keys(this.shapeMap).filter(
|
|
459
|
+
(shapeId) => this.cacheHiddenByItem[shapeId],
|
|
460
|
+
);
|
|
424
461
|
if (animate && animates.show?.length) {
|
|
425
462
|
const showAnimateFieldsMap: any = {};
|
|
426
463
|
Object.values(animates.show).forEach((animate) => {
|
|
@@ -430,24 +467,26 @@ export default abstract class Item implements IItem {
|
|
|
430
467
|
).concat(animate.fields);
|
|
431
468
|
});
|
|
432
469
|
const targetStyleMap = {};
|
|
433
|
-
|
|
470
|
+
shapeIdsToShow.forEach((id) => {
|
|
434
471
|
const shape = this.shapeMap[id];
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
shape.show();
|
|
472
|
+
// set the animate fields to initial value
|
|
473
|
+
if (showAnimateFieldsMap[id]) {
|
|
474
|
+
targetStyleMap[id] = targetStyleMap[id] || {};
|
|
475
|
+
const beginStyle = getShapeAnimateBeginStyles(shape);
|
|
476
|
+
showAnimateFieldsMap[id].forEach((field) => {
|
|
477
|
+
if (beginStyle.hasOwnProperty(field)) {
|
|
478
|
+
targetStyleMap[id][field] = shape.style[field];
|
|
479
|
+
shape.style[field] = beginStyle[field];
|
|
480
|
+
}
|
|
481
|
+
});
|
|
448
482
|
}
|
|
483
|
+
shape.show();
|
|
484
|
+
delete this.cacheHiddenByItem[id];
|
|
449
485
|
});
|
|
450
|
-
if (
|
|
486
|
+
if (
|
|
487
|
+
showAnimateFieldsMap.group &&
|
|
488
|
+
this.shapeMap.keyShape.attributes.visibility === 'hidden'
|
|
489
|
+
) {
|
|
451
490
|
showAnimateFieldsMap.group.forEach((field) => {
|
|
452
491
|
const usingField = field === 'size' ? 'transform' : field;
|
|
453
492
|
if (GROUP_ANIMATE_STYLES[0].hasOwnProperty(usingField)) {
|
|
@@ -456,42 +495,58 @@ export default abstract class Item implements IItem {
|
|
|
456
495
|
}
|
|
457
496
|
});
|
|
458
497
|
}
|
|
459
|
-
|
|
460
498
|
if (Object.keys(targetStyleMap).length) {
|
|
461
499
|
this.animations = this.runWithAnimates(
|
|
462
500
|
animates,
|
|
463
501
|
'show',
|
|
464
502
|
targetStyleMap,
|
|
503
|
+
shapeIdsToShow,
|
|
465
504
|
);
|
|
466
505
|
}
|
|
467
506
|
} else {
|
|
468
|
-
|
|
507
|
+
shapeIdsToShow.forEach((id) => {
|
|
469
508
|
const shape = this.shapeMap[id];
|
|
470
|
-
|
|
509
|
+
shape.show();
|
|
510
|
+
delete this.cacheHiddenByItem[id];
|
|
471
511
|
});
|
|
472
512
|
}
|
|
473
513
|
|
|
474
514
|
this.visible = true;
|
|
475
515
|
this.cacheHiddenByItem = {};
|
|
516
|
+
// restore the states
|
|
517
|
+
if (this.states?.length) {
|
|
518
|
+
this.drawWithStates([]);
|
|
519
|
+
}
|
|
476
520
|
});
|
|
477
521
|
}
|
|
478
522
|
|
|
479
523
|
/** Hides the item. */
|
|
480
|
-
public hide(animate = true, keepKeyShape = false) {
|
|
524
|
+
public hide(animate = true, keepKeyShape = false, shapeIds = undefined) {
|
|
525
|
+
const shapeIdsToHide =
|
|
526
|
+
shapeIds?.filter((id) => {
|
|
527
|
+
const shape = this.shapeMap[id];
|
|
528
|
+
return (
|
|
529
|
+
shape &&
|
|
530
|
+
(shape.attributes.visibility !== 'hidden' ||
|
|
531
|
+
this.cacheNotHiddenByItem[id])
|
|
532
|
+
);
|
|
533
|
+
}) || Object.keys(this.shapeMap);
|
|
534
|
+
if (!shapeIdsToHide.length) return;
|
|
481
535
|
this.cacheNotHiddenByItem = {};
|
|
482
536
|
const func = () => {
|
|
483
|
-
|
|
537
|
+
shapeIdsToHide.forEach((id) => {
|
|
484
538
|
if (keepKeyShape && id === 'keyShape') return;
|
|
485
539
|
const shape = this.shapeMap[id];
|
|
486
|
-
if (!shape.
|
|
540
|
+
if (!shape || shape.attributes.visibility === 'hidden') {
|
|
487
541
|
this.cacheNotHiddenByItem[id] = true;
|
|
488
542
|
return;
|
|
489
543
|
}
|
|
490
544
|
shape.hide();
|
|
491
545
|
this.cacheHiddenByItem[id] = true;
|
|
546
|
+
if (!shapeIds) this.visible = false;
|
|
492
547
|
});
|
|
493
548
|
};
|
|
494
|
-
Promise.all(this.stopAnimations()).then(() => {
|
|
549
|
+
Promise.all(this.stopAnimations(shapeIdsToHide)).then(() => {
|
|
495
550
|
if (this.destroyed) return;
|
|
496
551
|
const { animates = {} } = this.displayModel.data;
|
|
497
552
|
if (animate && animates.hide?.length) {
|
|
@@ -499,13 +554,13 @@ export default abstract class Item implements IItem {
|
|
|
499
554
|
animates,
|
|
500
555
|
'hide',
|
|
501
556
|
undefined,
|
|
557
|
+
shapeIdsToHide,
|
|
502
558
|
func,
|
|
503
559
|
);
|
|
504
560
|
} else {
|
|
505
561
|
// 2. clear group and remove group
|
|
506
562
|
func();
|
|
507
563
|
}
|
|
508
|
-
this.visible = false;
|
|
509
564
|
});
|
|
510
565
|
}
|
|
511
566
|
|
|
@@ -540,7 +595,7 @@ export default abstract class Item implements IItem {
|
|
|
540
595
|
* @param value state value
|
|
541
596
|
*/
|
|
542
597
|
public setState(state: string, value: string | boolean) {
|
|
543
|
-
const previousStates =
|
|
598
|
+
const previousStates = cloneJSON(this.states);
|
|
544
599
|
const existState = this.states.find((item) => item.name === state);
|
|
545
600
|
if (value) {
|
|
546
601
|
if (existState) existState.value = value;
|
|
@@ -569,7 +624,7 @@ export default abstract class Item implements IItem {
|
|
|
569
624
|
*/
|
|
570
625
|
public clearStates(states?: string[]) {
|
|
571
626
|
// if states is not assigned, clear all the states on the item
|
|
572
|
-
const previousStates =
|
|
627
|
+
const previousStates = cloneJSON(this.states);
|
|
573
628
|
const newStates = [];
|
|
574
629
|
let changedStates = [];
|
|
575
630
|
if (states) {
|
|
@@ -618,11 +673,12 @@ export default abstract class Item implements IItem {
|
|
|
618
673
|
animates: IAnimates,
|
|
619
674
|
timing: AnimateTiming,
|
|
620
675
|
targetStyleMap: Object,
|
|
676
|
+
shapeIdsToShow: string[] | undefined,
|
|
621
677
|
callback: Function = () => {},
|
|
622
678
|
) {
|
|
623
679
|
let targetStyle = {};
|
|
624
680
|
if (!targetStyleMap) {
|
|
625
|
-
|
|
681
|
+
shapeIdsToShow?.forEach((shapeId) => {
|
|
626
682
|
targetStyle[shapeId] = getShapeAnimateBeginStyles(
|
|
627
683
|
this.shapeMap[shapeId],
|
|
628
684
|
);
|
|
@@ -634,7 +690,8 @@ export default abstract class Item implements IItem {
|
|
|
634
690
|
animates,
|
|
635
691
|
targetStyle, // targetStylesMap
|
|
636
692
|
this.shapeMap, // shapeMap
|
|
637
|
-
|
|
693
|
+
shapeIdsToShow,
|
|
694
|
+
[this.group, this.labelGroup],
|
|
638
695
|
timing,
|
|
639
696
|
[],
|
|
640
697
|
() => {},
|
|
@@ -707,13 +764,29 @@ export default abstract class Item implements IItem {
|
|
|
707
764
|
// merge the states' styles into drawing style
|
|
708
765
|
styles = mergeStyles([styles, mergedStateStyles]);
|
|
709
766
|
});
|
|
767
|
+
const mergedData = mergeStyles([displayModelData, styles]);
|
|
768
|
+
const { animates } = mergedData;
|
|
769
|
+
const displayUpdateAnimates = [];
|
|
770
|
+
const stateNames = this.states.map((state) => state.name);
|
|
771
|
+
animates?.update?.forEach((animateCfg) => {
|
|
772
|
+
const { states } = animateCfg as IStateAnimate;
|
|
773
|
+
if (states && isArrayOverlap(states, stateNames)) {
|
|
774
|
+
displayUpdateAnimates.push(animateCfg);
|
|
775
|
+
}
|
|
776
|
+
});
|
|
710
777
|
|
|
711
778
|
// apply the merged styles
|
|
712
779
|
this.draw(
|
|
713
780
|
// displayModel
|
|
714
781
|
{
|
|
715
782
|
...this.displayModel,
|
|
716
|
-
data:
|
|
783
|
+
data: {
|
|
784
|
+
...mergedData,
|
|
785
|
+
animates: {
|
|
786
|
+
...animates,
|
|
787
|
+
update: displayUpdateAnimates,
|
|
788
|
+
},
|
|
789
|
+
},
|
|
717
790
|
} as ItemDisplayModel,
|
|
718
791
|
// diffData
|
|
719
792
|
undefined,
|
|
@@ -780,15 +853,18 @@ export default abstract class Item implements IItem {
|
|
|
780
853
|
/**
|
|
781
854
|
* Stop all the animations on the item.
|
|
782
855
|
*/
|
|
783
|
-
public stopAnimations() {
|
|
856
|
+
public stopAnimations(shapeIds?: string[]) {
|
|
784
857
|
const promises = [];
|
|
785
858
|
if (this.animations?.length) {
|
|
786
|
-
|
|
787
|
-
const animate = this.animations
|
|
788
|
-
if (animate.
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
859
|
+
for (let i = 0; i < this.animations.length; i++) {
|
|
860
|
+
const animate = this.animations[i];
|
|
861
|
+
if (!shapeIds?.length || shapeIds.includes(animate.effect.target.id)) {
|
|
862
|
+
this.animations.pop();
|
|
863
|
+
if (animate.playState !== 'running') break;
|
|
864
|
+
promises.push(stopAnimate(animate));
|
|
865
|
+
// @ts-ignore
|
|
866
|
+
animate.onManualCancel?.();
|
|
867
|
+
}
|
|
792
868
|
}
|
|
793
869
|
}
|
|
794
870
|
if (this.groupAnimations?.length) {
|
|
@@ -827,10 +903,16 @@ export default abstract class Item implements IItem {
|
|
|
827
903
|
this.renderExt.onZoom(this.shapeMap, zoom, this.cacheHiddenByItem);
|
|
828
904
|
}
|
|
829
905
|
|
|
906
|
+
/**
|
|
907
|
+
* Update label positions on label canvas by getting viewport position from transformed canvas position.
|
|
908
|
+
*/
|
|
909
|
+
public updateLabelPosition(ignoreVisibility: boolean = false) {}
|
|
910
|
+
|
|
830
911
|
/** Destroy the item. */
|
|
831
912
|
public destroy() {
|
|
832
913
|
const func = () => {
|
|
833
914
|
this.group.destroy();
|
|
915
|
+
this.labelGroup.destroy();
|
|
834
916
|
this.model = null;
|
|
835
917
|
this.displayModel = null;
|
|
836
918
|
this.destroyed = true;
|
|
@@ -843,6 +925,7 @@ export default abstract class Item implements IItem {
|
|
|
843
925
|
animates,
|
|
844
926
|
'buildOut',
|
|
845
927
|
undefined,
|
|
928
|
+
undefined,
|
|
846
929
|
func,
|
|
847
930
|
);
|
|
848
931
|
} else {
|
|
@@ -917,12 +1000,12 @@ const updateShapeChange = ({
|
|
|
917
1000
|
});
|
|
918
1001
|
Object.keys(mapper).forEach((shapeAttrName) => {
|
|
919
1002
|
if (innerModelValue?.hasOwnProperty(shapeAttrName)) return;
|
|
920
|
-
const { value: mappedValue } = updateChange({
|
|
1003
|
+
const { value: mappedValue, changed } = updateChange({
|
|
921
1004
|
innerModel,
|
|
922
1005
|
mapper,
|
|
923
1006
|
fieldName: shapeAttrName,
|
|
924
1007
|
dataChangedFields,
|
|
925
1008
|
});
|
|
926
|
-
shapeConfig[shapeAttrName] = mappedValue;
|
|
1009
|
+
if (changed) shapeConfig[shapeAttrName] = mappedValue;
|
|
927
1010
|
});
|
|
928
1011
|
};
|