@antv/g6 5.0.0-alpha.8 → 5.0.0-alpha.9
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 +6 -19
- package/esm/index.d.ts +26 -6
- package/esm/item/combo.d.ts +72 -2
- package/esm/item/combo.js +122 -2
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +3 -3
- package/esm/item/edge.js +4 -5
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +4 -4
- package/esm/item/item.js +38 -9
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +20 -16
- package/esm/item/node.js +14 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +12 -4
- package/esm/runtime/controller/data.js +354 -62
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/interaction.js +16 -4
- package/esm/runtime/controller/interaction.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +11 -2
- package/esm/runtime/controller/item.js +344 -52
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.js +19 -5
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/graph.d.ts +54 -17
- package/esm/runtime/graph.js +165 -34
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/click-select.d.ts +3 -0
- package/esm/stdlib/behavior/click-select.js +13 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/collapse-expand-combo.d.ts +29 -0
- package/esm/stdlib/behavior/collapse-expand-combo.js +35 -0
- package/esm/stdlib/behavior/collapse-expand-combo.js.map +1 -0
- package/esm/stdlib/behavior/drag-combo.d.ts +99 -0
- package/esm/stdlib/behavior/drag-combo.js +341 -0
- package/esm/stdlib/behavior/drag-combo.js.map +1 -0
- package/esm/stdlib/behavior/drag-node.d.ts +14 -10
- package/esm/stdlib/behavior/drag-node.js +134 -37
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/hover-activate.d.ts +3 -1
- package/esm/stdlib/behavior/hover-activate.js +3 -1
- package/esm/stdlib/behavior/hover-activate.js.map +1 -1
- package/esm/stdlib/behavior/orbit-canvas-3d.js +1 -1
- package/esm/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/track-canvas-3d.js +1 -1
- package/esm/stdlib/behavior/track-canvas-3d.js.map +1 -1
- package/esm/stdlib/index.d.ts +25 -3
- package/esm/stdlib/index.js +25 -3
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/combo/circle.d.ts +29 -0
- package/esm/stdlib/item/combo/circle.js +56 -0
- package/esm/stdlib/item/combo/circle.js.map +1 -0
- package/esm/stdlib/item/edge/base.d.ts +2 -2
- package/esm/stdlib/item/edge/base.js +3 -0
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-horizon.d.ts +37 -0
- package/esm/stdlib/item/edge/cubic-horizon.js +71 -0
- package/esm/stdlib/item/edge/cubic-horizon.js.map +1 -0
- package/esm/stdlib/item/edge/cubic-vertical.d.ts +37 -0
- package/esm/stdlib/item/edge/cubic-vertical.js +71 -0
- package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -0
- package/esm/stdlib/item/edge/cubic.d.ts +60 -0
- package/esm/stdlib/item/edge/cubic.js +99 -0
- package/esm/stdlib/item/edge/cubic.js.map +1 -0
- package/esm/stdlib/item/edge/index.d.ts +1 -0
- package/esm/stdlib/item/edge/index.js +1 -0
- package/esm/stdlib/item/edge/index.js.map +1 -1
- package/esm/stdlib/item/edge/line.d.ts +1 -1
- package/esm/stdlib/item/edge/quadratic.d.ts +41 -0
- package/esm/stdlib/item/edge/quadratic.js +66 -0
- package/esm/stdlib/item/edge/quadratic.js.map +1 -0
- package/esm/stdlib/item/node/base.d.ts +38 -37
- package/esm/stdlib/item/node/base.js +4 -4
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/index.d.ts +1 -0
- package/esm/stdlib/item/node/index.js +1 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/item/node/rect.d.ts +31 -0
- package/esm/stdlib/item/node/rect.js +59 -0
- package/esm/stdlib/item/node/rect.js.map +1 -0
- package/esm/stdlib/plugin/fisheye/index.d.ts +102 -0
- package/esm/stdlib/plugin/fisheye/index.js +487 -0
- package/esm/stdlib/plugin/fisheye/index.js.map +1 -0
- package/esm/stdlib/plugin/menu/index.d.ts +42 -0
- package/esm/stdlib/plugin/menu/index.js +236 -0
- package/esm/stdlib/plugin/menu/index.js.map +1 -0
- package/esm/stdlib/plugin/tooltip/index.d.ts +75 -0
- package/esm/stdlib/plugin/tooltip/index.js +377 -0
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -0
- package/esm/stdlib/theme/dark.js +4 -0
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +54 -9
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/types/combo.d.ts +52 -3
- package/esm/types/data.d.ts +4 -4
- package/esm/types/edge.d.ts +2 -3
- package/esm/types/event.d.ts +9 -1
- package/esm/types/event.js +8 -8
- package/esm/types/event.js.map +1 -1
- package/esm/types/graph.d.ts +49 -13
- package/esm/types/hook.d.ts +8 -1
- package/esm/types/item.d.ts +4 -4
- package/esm/types/node.d.ts +4 -5
- package/esm/types/theme.d.ts +1 -1
- package/esm/util/animate.js.map +1 -1
- package/esm/util/canvas.js +8 -0
- package/esm/util/canvas.js.map +1 -1
- package/esm/util/data.d.ts +65 -0
- package/esm/util/data.js +150 -0
- package/esm/util/data.js.map +1 -0
- package/esm/util/event.d.ts +8 -0
- package/esm/util/event.js +16 -0
- package/esm/util/event.js.map +1 -1
- package/esm/util/item.d.ts +2 -1
- package/esm/util/item.js +36 -13
- package/esm/util/item.js.map +1 -1
- package/esm/util/shape.d.ts +39 -4
- package/esm/util/shape.js +101 -1
- package/esm/util/shape.js.map +1 -1
- package/esm/util/zoom.d.ts +2 -2
- package/lib/index.d.ts +26 -6
- package/lib/item/combo.d.ts +72 -2
- package/lib/item/combo.js +122 -2
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +3 -3
- package/lib/item/edge.js +4 -5
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +4 -4
- package/lib/item/item.js +37 -8
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +20 -16
- package/lib/item/node.js +14 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +12 -4
- package/lib/runtime/controller/data.js +353 -61
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/interaction.js +15 -3
- package/lib/runtime/controller/interaction.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +11 -2
- package/lib/runtime/controller/item.js +342 -50
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.js +19 -5
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/graph.d.ts +54 -17
- package/lib/runtime/graph.js +165 -34
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/click-select.d.ts +3 -0
- package/lib/stdlib/behavior/click-select.js +13 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/collapse-expand-combo.d.ts +29 -0
- package/lib/stdlib/behavior/collapse-expand-combo.js +38 -0
- package/lib/stdlib/behavior/collapse-expand-combo.js.map +1 -0
- package/lib/stdlib/behavior/drag-combo.d.ts +99 -0
- package/lib/stdlib/behavior/drag-combo.js +344 -0
- package/lib/stdlib/behavior/drag-combo.js.map +1 -0
- package/lib/stdlib/behavior/drag-node.d.ts +14 -10
- package/lib/stdlib/behavior/drag-node.js +134 -37
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/hover-activate.d.ts +3 -1
- package/lib/stdlib/behavior/hover-activate.js +3 -2
- package/lib/stdlib/behavior/hover-activate.js.map +1 -1
- package/lib/stdlib/behavior/orbit-canvas-3d.js +1 -1
- package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/track-canvas-3d.js +1 -1
- package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -1
- package/lib/stdlib/index.d.ts +25 -3
- package/lib/stdlib/index.js +25 -3
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/combo/circle.d.ts +29 -0
- package/lib/stdlib/item/combo/circle.js +60 -0
- package/lib/stdlib/item/combo/circle.js.map +1 -0
- package/lib/stdlib/item/edge/base.d.ts +2 -2
- package/lib/stdlib/item/edge/base.js +3 -0
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-horizon.d.ts +37 -0
- package/lib/stdlib/item/edge/cubic-horizon.js +75 -0
- package/lib/stdlib/item/edge/cubic-horizon.js.map +1 -0
- package/lib/stdlib/item/edge/cubic-vertical.d.ts +37 -0
- package/lib/stdlib/item/edge/cubic-vertical.js +75 -0
- package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -0
- package/lib/stdlib/item/edge/cubic.d.ts +60 -0
- package/lib/stdlib/item/edge/cubic.js +103 -0
- package/lib/stdlib/item/edge/cubic.js.map +1 -0
- package/lib/stdlib/item/edge/index.d.ts +1 -0
- package/lib/stdlib/item/edge/index.js +1 -0
- package/lib/stdlib/item/edge/index.js.map +1 -1
- package/lib/stdlib/item/edge/line.d.ts +1 -1
- package/lib/stdlib/item/edge/quadratic.d.ts +41 -0
- package/lib/stdlib/item/edge/quadratic.js +70 -0
- package/lib/stdlib/item/edge/quadratic.js.map +1 -0
- package/lib/stdlib/item/node/base.d.ts +38 -37
- package/lib/stdlib/item/node/base.js +4 -4
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/index.d.ts +1 -0
- package/lib/stdlib/item/node/index.js +1 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/item/node/rect.d.ts +31 -0
- package/lib/stdlib/item/node/rect.js +63 -0
- package/lib/stdlib/item/node/rect.js.map +1 -0
- package/lib/stdlib/plugin/fisheye/index.d.ts +102 -0
- package/lib/stdlib/plugin/fisheye/index.js +490 -0
- package/lib/stdlib/plugin/fisheye/index.js.map +1 -0
- package/lib/stdlib/plugin/menu/index.d.ts +42 -0
- package/lib/stdlib/plugin/menu/index.js +242 -0
- package/lib/stdlib/plugin/menu/index.js.map +1 -0
- package/lib/stdlib/plugin/tooltip/index.d.ts +75 -0
- package/lib/stdlib/plugin/tooltip/index.js +383 -0
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -0
- package/lib/stdlib/theme/dark.js +4 -0
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +54 -9
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/types/combo.d.ts +52 -3
- package/lib/types/data.d.ts +4 -4
- package/lib/types/edge.d.ts +2 -3
- package/lib/types/event.d.ts +9 -1
- package/lib/types/event.js +10 -10
- package/lib/types/event.js.map +1 -1
- package/lib/types/graph.d.ts +49 -13
- package/lib/types/hook.d.ts +8 -1
- package/lib/types/item.d.ts +4 -4
- package/lib/types/item.js +1 -1
- package/lib/types/item.js.map +1 -1
- package/lib/types/node.d.ts +4 -5
- package/lib/types/theme.d.ts +1 -1
- package/lib/util/animate.js.map +1 -1
- package/lib/util/canvas.js +8 -0
- package/lib/util/canvas.js.map +1 -1
- package/lib/util/data.d.ts +65 -0
- package/lib/util/data.js +161 -0
- package/lib/util/data.js.map +1 -0
- package/lib/util/event.d.ts +8 -0
- package/lib/util/event.js +18 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/item.d.ts +2 -1
- package/lib/util/item.js +36 -13
- package/lib/util/item.js.map +1 -1
- package/lib/util/shape.d.ts +39 -4
- package/lib/util/shape.js +105 -2
- package/lib/util/shape.js.map +1 -1
- package/lib/util/zoom.d.ts +2 -2
- package/package.json +13 -13
- package/src/item/combo.ts +220 -2
- package/src/item/edge.ts +7 -8
- package/src/item/item.ts +58 -15
- package/src/item/node.ts +47 -24
- package/src/runtime/controller/data.ts +390 -68
- package/src/runtime/controller/interaction.ts +23 -3
- package/src/runtime/controller/item.ts +444 -64
- package/src/runtime/controller/layout.ts +24 -5
- package/src/runtime/graph.ts +225 -38
- package/src/stdlib/behavior/click-select.ts +15 -2
- package/src/stdlib/behavior/collapse-expand-combo.ts +59 -0
- package/src/stdlib/behavior/drag-combo.ts +533 -0
- package/src/stdlib/behavior/drag-node.ts +195 -62
- package/src/stdlib/behavior/hover-activate.ts +4 -5
- package/src/stdlib/behavior/orbit-canvas-3d.ts +1 -1
- package/src/stdlib/behavior/track-canvas-3d.ts +1 -1
- package/src/stdlib/index.ts +25 -3
- package/src/stdlib/item/combo/circle.ts +113 -0
- package/src/stdlib/item/edge/base.ts +5 -2
- package/src/stdlib/item/edge/cubic-horizon.ts +114 -0
- package/src/stdlib/item/edge/cubic-vertical.ts +116 -0
- package/src/stdlib/item/edge/cubic.ts +198 -0
- package/src/stdlib/item/edge/index.ts +1 -0
- package/src/stdlib/item/edge/quadratic.ts +136 -0
- package/src/stdlib/item/node/base.ts +79 -41
- package/src/stdlib/item/node/index.ts +1 -0
- package/src/stdlib/item/node/rect.ts +124 -0
- package/src/stdlib/plugin/fisheye/index.ts +578 -0
- package/src/stdlib/plugin/menu/index.ts +260 -0
- package/src/stdlib/plugin/tooltip/index.ts +424 -0
- package/src/stdlib/theme/dark.ts +4 -0
- package/src/stdlib/theme/light.ts +77 -9
- package/src/types/combo.ts +61 -3
- package/src/types/data.ts +6 -4
- package/src/types/edge.ts +2 -2
- package/src/types/event.ts +8 -8
- package/src/types/graph.ts +73 -16
- package/src/types/hook.ts +8 -1
- package/src/types/item.ts +10 -9
- package/src/types/node.ts +4 -4
- package/src/types/theme.ts +1 -1
- package/src/util/animate.ts +2 -3
- package/src/util/canvas.ts +10 -0
- package/src/util/data.ts +178 -0
- package/src/util/event.ts +29 -0
- package/src/util/item.ts +75 -12
- package/src/util/shape.ts +142 -5
- package/src/util/zoom.ts +2 -2
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { Group } from '@antv/g';
|
|
2
|
-
import { debounce, isArray, isObject, throttle } from '@antv/util';
|
|
2
|
+
import { debounce, isArray, isObject, throttle, uniq, uniqueId, } from '@antv/util';
|
|
3
|
+
import { DirectionalLight, AmbientLight } from '@antv/g-plugin-3d';
|
|
3
4
|
import registry from '../../stdlib';
|
|
4
5
|
import Node from '../../item/node';
|
|
5
6
|
import Edge from '../../item/edge';
|
|
6
|
-
import
|
|
7
|
+
import Combo from '../../item/combo';
|
|
8
|
+
import { getCombinedBoundsByData, upsertShape } from '../../util/shape';
|
|
7
9
|
import { getExtension } from '../../util/extension';
|
|
8
10
|
import { upsertTransientItem } from '../../util/item';
|
|
9
|
-
import { DirectionalLight, AmbientLight } from '@antv/g-plugin-3d';
|
|
10
11
|
import { formatLodStrategy } from '../../util/zoom';
|
|
12
|
+
import { deconstructData, graphComboTreeDfs, graphCoreTreeDfs, traverseAncestors, traverseAncestorsAndSucceeds, traverseGraphAncestors, } from '../../util/data';
|
|
11
13
|
/**
|
|
12
14
|
* Manages and stores the node / edge / combo items.
|
|
13
15
|
*/
|
|
14
16
|
export class ItemController {
|
|
17
|
+
// private comboTreeView: GraphView<any, any>;
|
|
15
18
|
constructor(graph) {
|
|
16
19
|
this.nodeExtensions = [];
|
|
17
20
|
this.edgeExtensions = [];
|
|
@@ -20,9 +23,9 @@ export class ItemController {
|
|
|
20
23
|
* Node / edge / combo items map
|
|
21
24
|
*/
|
|
22
25
|
this.itemMap = {};
|
|
23
|
-
// TODO: combo? not a independent group
|
|
24
26
|
this.nodeDataTypeSet = new Set();
|
|
25
27
|
this.edgeDataTypeSet = new Set();
|
|
28
|
+
this.comboDataTypeSet = new Set();
|
|
26
29
|
// The G shapes or groups on transient map drawn by this controller
|
|
27
30
|
this.transientObjectMap = {};
|
|
28
31
|
this.transientItemMap = {};
|
|
@@ -78,6 +81,7 @@ export class ItemController {
|
|
|
78
81
|
this.graph.hooks.itemchange.tap(this.onChange.bind(this));
|
|
79
82
|
this.graph.hooks.itemstatechange.tap(this.onItemStateChange.bind(this));
|
|
80
83
|
this.graph.hooks.itemvisibilitychange.tap(this.onItemVisibilityChange.bind(this));
|
|
84
|
+
this.graph.hooks.itemzindexchange.tap(this.onItemZIndexChange.bind(this));
|
|
81
85
|
this.graph.hooks.transientupdate.tap(this.onTransientUpdate.bind(this));
|
|
82
86
|
this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this));
|
|
83
87
|
this.graph.hooks.themechange.tap(this.onThemeChange.bind(this));
|
|
@@ -113,16 +117,21 @@ export class ItemController {
|
|
|
113
117
|
const { graph } = this;
|
|
114
118
|
// 0. clear groups on canvas, and create new groups
|
|
115
119
|
graph.canvas.removeChildren();
|
|
120
|
+
const comboGroup = new Group({ id: 'combo-group' });
|
|
116
121
|
const edgeGroup = new Group({ id: 'edge-group' });
|
|
117
122
|
const nodeGroup = new Group({ id: 'node-group' });
|
|
123
|
+
graph.canvas.appendChild(comboGroup);
|
|
118
124
|
graph.canvas.appendChild(edgeGroup);
|
|
119
125
|
graph.canvas.appendChild(nodeGroup);
|
|
120
126
|
this.nodeGroup = nodeGroup;
|
|
121
127
|
this.edgeGroup = edgeGroup;
|
|
128
|
+
this.comboGroup = comboGroup;
|
|
122
129
|
// Also create transient groups on transient canvas.
|
|
123
130
|
transientCanvas.removeChildren();
|
|
131
|
+
this.transientComboGroup = new Group({ id: 'combo-group' });
|
|
124
132
|
this.transientEdgeGroup = new Group({ id: 'edge-group' });
|
|
125
133
|
this.transientNodeGroup = new Group({ id: 'node-group' });
|
|
134
|
+
transientCanvas.appendChild(this.transientComboGroup);
|
|
126
135
|
transientCanvas.appendChild(this.transientEdgeGroup);
|
|
127
136
|
transientCanvas.appendChild(this.transientNodeGroup);
|
|
128
137
|
// 1. create lights for webgl 3d rendering
|
|
@@ -146,19 +155,27 @@ export class ItemController {
|
|
|
146
155
|
graph.canvas.getCamera().setPerspective(0.1, 50000, 45, width / height);
|
|
147
156
|
}
|
|
148
157
|
// 2. create node / edge / combo items, classes from ../../item, and element drawing and updating fns from node/edge/comboExtensions
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this.
|
|
154
|
-
|
|
158
|
+
const { nodes, edges, combos } = deconstructData({
|
|
159
|
+
nodes: graphCore.getAllNodes(),
|
|
160
|
+
edges: graphCore.getAllEdges(),
|
|
161
|
+
});
|
|
162
|
+
this.renderNodes(nodes, theme.node);
|
|
163
|
+
this.renderCombos(combos, theme.combo, graphCore);
|
|
164
|
+
this.renderEdges(edges, theme.edge);
|
|
165
|
+
this.sortByComboTree(graphCore);
|
|
166
|
+
if (graphCore.hasTreeStructure('combo')) {
|
|
167
|
+
graphCoreTreeDfs(graphCore, graphCore.getRoots('combo'), (child) => {
|
|
168
|
+
if (child.data.collapsed)
|
|
169
|
+
this.collapseCombo(graphCore, child);
|
|
170
|
+
}, 'BT');
|
|
171
|
+
}
|
|
155
172
|
}
|
|
156
173
|
/**
|
|
157
174
|
* Listener of runtime's itemchange lifecycle hook.
|
|
158
175
|
* @param param
|
|
159
176
|
*/
|
|
160
177
|
onChange(param) {
|
|
161
|
-
const { changes, graphCore, theme = {},
|
|
178
|
+
const { changes, graphCore, action, upsertAncestors = true, theme = {}, } = param;
|
|
162
179
|
const groupedChanges = {
|
|
163
180
|
NodeRemoved: [],
|
|
164
181
|
EdgeRemoved: [],
|
|
@@ -167,6 +184,7 @@ export class ItemController {
|
|
|
167
184
|
NodeDataUpdated: [],
|
|
168
185
|
EdgeUpdated: [],
|
|
169
186
|
EdgeDataUpdated: [],
|
|
187
|
+
TreeStructureChanged: [],
|
|
170
188
|
};
|
|
171
189
|
changes.forEach((change) => {
|
|
172
190
|
const { type: changeType } = change;
|
|
@@ -183,38 +201,57 @@ export class ItemController {
|
|
|
183
201
|
delete itemMap[id];
|
|
184
202
|
}
|
|
185
203
|
});
|
|
186
|
-
const { node: nodeTheme = {}, edge: edgeTheme = {} } = theme;
|
|
204
|
+
const { node: nodeTheme = {}, edge: edgeTheme = {}, combo: comboTheme = {}, } = theme;
|
|
187
205
|
// === 3. add nodes ===
|
|
188
206
|
if (groupedChanges.NodeAdded.length) {
|
|
189
|
-
|
|
207
|
+
const newNodes = [];
|
|
208
|
+
const newCombos = [];
|
|
209
|
+
groupedChanges.NodeAdded.map((change) => change.value).forEach((model) => {
|
|
210
|
+
if (model.data._isCombo)
|
|
211
|
+
newCombos.push(model);
|
|
212
|
+
else
|
|
213
|
+
newNodes.push(model);
|
|
214
|
+
});
|
|
215
|
+
if (newNodes.length) {
|
|
216
|
+
this.renderNodes(newNodes, nodeTheme);
|
|
217
|
+
}
|
|
218
|
+
if (newCombos.length) {
|
|
219
|
+
this.renderCombos(newCombos, comboTheme, graphCore);
|
|
220
|
+
}
|
|
190
221
|
}
|
|
191
222
|
// === 4. add edges ===
|
|
192
223
|
if (groupedChanges.EdgeAdded.length) {
|
|
193
224
|
this.renderEdges(groupedChanges.EdgeAdded.map((change) => change.value), edgeTheme);
|
|
194
225
|
}
|
|
195
226
|
// === 5. update nodes's data ===
|
|
196
|
-
// merge changes for each node
|
|
227
|
+
// merge changes for each node or combo
|
|
197
228
|
if (groupedChanges.NodeDataUpdated.length) {
|
|
198
|
-
const
|
|
229
|
+
const nodeComboUpdate = {};
|
|
199
230
|
groupedChanges.NodeDataUpdated.forEach((change) => {
|
|
200
231
|
const { id, propertyName, newValue, oldValue } = change;
|
|
201
|
-
|
|
232
|
+
nodeComboUpdate[id] = nodeComboUpdate[id] || {
|
|
233
|
+
previous: {},
|
|
234
|
+
current: {},
|
|
235
|
+
};
|
|
202
236
|
if (!propertyName) {
|
|
203
|
-
|
|
237
|
+
nodeComboUpdate[id] = {
|
|
204
238
|
isReplace: true,
|
|
205
239
|
previous: oldValue,
|
|
206
240
|
current: newValue,
|
|
207
241
|
};
|
|
208
242
|
}
|
|
209
243
|
else {
|
|
210
|
-
|
|
211
|
-
|
|
244
|
+
nodeComboUpdate[id].previous[propertyName] = oldValue;
|
|
245
|
+
nodeComboUpdate[id].current[propertyName] = newValue;
|
|
212
246
|
}
|
|
213
247
|
});
|
|
214
248
|
const { dataTypeField: nodeDataTypeField } = nodeTheme;
|
|
215
249
|
const edgeToUpdate = {};
|
|
216
|
-
const
|
|
217
|
-
|
|
250
|
+
const comboToUpdate = {};
|
|
251
|
+
const updateRelates = throttle((edgeMap) => {
|
|
252
|
+
Object.keys(comboToUpdate)
|
|
253
|
+
.concat(Object.keys(edgeMap || edgeToUpdate))
|
|
254
|
+
.forEach((id) => {
|
|
218
255
|
const item = itemMap[id];
|
|
219
256
|
if (item && !item.destroyed)
|
|
220
257
|
item.forceUpdate();
|
|
@@ -223,42 +260,86 @@ export class ItemController {
|
|
|
223
260
|
leading: true,
|
|
224
261
|
trailing: true,
|
|
225
262
|
});
|
|
226
|
-
Object.keys(
|
|
227
|
-
|
|
263
|
+
Object.keys(nodeComboUpdate).forEach((id) => {
|
|
264
|
+
if (!graphCore.hasNode(id))
|
|
265
|
+
return;
|
|
266
|
+
const { isReplace, previous, current } = nodeComboUpdate[id];
|
|
267
|
+
const onlyMove = action === 'updatePosition';
|
|
268
|
+
const item = itemMap[id];
|
|
269
|
+
const type = item.getType();
|
|
270
|
+
if (onlyMove && type === 'node' && isNaN(current.x) && isNaN(current.y))
|
|
271
|
+
return;
|
|
228
272
|
// update the theme if the dataType value is changed
|
|
229
273
|
let itemTheme;
|
|
230
274
|
if (nodeDataTypeField &&
|
|
231
275
|
previous[nodeDataTypeField] !== current[nodeDataTypeField]) {
|
|
232
276
|
itemTheme = getItemTheme(this.nodeDataTypeSet, nodeDataTypeField, current[nodeDataTypeField], nodeTheme);
|
|
233
277
|
}
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
try {
|
|
237
|
-
innerModel = graphCore.getNode(id);
|
|
238
|
-
}
|
|
239
|
-
catch (e) {
|
|
240
|
-
innerModel = graphCore.getNode(Number(id));
|
|
241
|
-
}
|
|
242
|
-
let relatedEdgeInnerModels;
|
|
243
|
-
try {
|
|
244
|
-
relatedEdgeInnerModels = graphCore.getRelatedEdges(id);
|
|
245
|
-
}
|
|
246
|
-
catch (e) {
|
|
247
|
-
relatedEdgeInnerModels = graphCore.getRelatedEdges(Number(id));
|
|
248
|
-
}
|
|
278
|
+
const innerModel = graphCore.getNode(id);
|
|
279
|
+
const relatedEdgeInnerModels = graphCore.getRelatedEdges(id);
|
|
249
280
|
const nodeRelatedToUpdate = {};
|
|
250
281
|
relatedEdgeInnerModels.forEach((edge) => {
|
|
251
282
|
edgeToUpdate[edge.id] = edge;
|
|
252
283
|
nodeRelatedToUpdate[edge.id] = edge;
|
|
253
284
|
});
|
|
254
|
-
|
|
255
|
-
|
|
285
|
+
const previousParentId = item.displayModel.data.parentId;
|
|
286
|
+
item.onframe = () => {
|
|
287
|
+
updateRelates(nodeRelatedToUpdate);
|
|
288
|
+
};
|
|
289
|
+
item.update(innerModel, { previous, current }, isReplace, itemTheme, onlyMove,
|
|
256
290
|
// call after updating finished
|
|
257
291
|
() => {
|
|
258
|
-
|
|
292
|
+
item.onframe();
|
|
293
|
+
item.onframe = undefined;
|
|
259
294
|
});
|
|
295
|
+
if (graphCore.hasTreeStructure('combo')) {
|
|
296
|
+
if (type === 'combo' && current.collapsed !== previous.collapsed) {
|
|
297
|
+
if (current.collapsed) {
|
|
298
|
+
this.collapseCombo(graphCore, innerModel);
|
|
299
|
+
}
|
|
300
|
+
else if (current.collapsed === false) {
|
|
301
|
+
this.expandCombo(graphCore, innerModel);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// update the current parent combo tree
|
|
305
|
+
// if the node has previous parent, related previous parent combo should be updated to
|
|
306
|
+
if (upsertAncestors) {
|
|
307
|
+
const begins = [innerModel];
|
|
308
|
+
if (previousParentId &&
|
|
309
|
+
previousParentId !== current.parentId &&
|
|
310
|
+
graphCore.hasNode(previousParentId)) {
|
|
311
|
+
begins.push(graphCore.getNode(previousParentId));
|
|
312
|
+
}
|
|
313
|
+
// ancestors and suceeds combos should be updated
|
|
314
|
+
traverseAncestorsAndSucceeds(this.graph, graphCore, begins, (treeItem) => {
|
|
315
|
+
if (treeItem.data._isCombo && treeItem.id !== innerModel.id)
|
|
316
|
+
comboToUpdate[treeItem.id] = treeItem;
|
|
317
|
+
const relatedEdges = graphCore.getRelatedEdges(treeItem.id);
|
|
318
|
+
relatedEdges.forEach((edge) => {
|
|
319
|
+
edgeToUpdate[edge.id] = edge;
|
|
320
|
+
nodeRelatedToUpdate[edge.id] = edge;
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
else if (type === 'combo') {
|
|
325
|
+
// only the succeed combos should be updated
|
|
326
|
+
graphComboTreeDfs(this.graph, [innerModel], (child) => {
|
|
327
|
+
const relatedEdges = graphCore.getRelatedEdges(child.id);
|
|
328
|
+
relatedEdges.forEach((edge) => {
|
|
329
|
+
edgeToUpdate[edge.id] = edge;
|
|
330
|
+
nodeRelatedToUpdate[edge.id] = edge;
|
|
331
|
+
});
|
|
332
|
+
if (child.data._isCombo && child.id !== innerModel.id)
|
|
333
|
+
comboToUpdate[child.id] = child;
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const parentItem = this.itemMap[current.parentId];
|
|
338
|
+
if (current.parentId && (parentItem === null || parentItem === void 0 ? void 0 : parentItem.model.data.collapsed)) {
|
|
339
|
+
this.graph.hideItem(innerModel.id);
|
|
340
|
+
}
|
|
260
341
|
});
|
|
261
|
-
|
|
342
|
+
updateRelates();
|
|
262
343
|
}
|
|
263
344
|
// === 6. update edges' data ===
|
|
264
345
|
if (groupedChanges.EdgeDataUpdated.length) {
|
|
@@ -309,6 +390,10 @@ export class ItemController {
|
|
|
309
390
|
item.updateEnd('target', this.itemMap[target]);
|
|
310
391
|
});
|
|
311
392
|
}
|
|
393
|
+
// === 8. combo tree structure change, resort the shapes ===
|
|
394
|
+
if (groupedChanges.TreeStructureChanged.length) {
|
|
395
|
+
this.sortByComboTree(graphCore);
|
|
396
|
+
}
|
|
312
397
|
}
|
|
313
398
|
/**
|
|
314
399
|
* The listener for item state changing.
|
|
@@ -337,30 +422,90 @@ export class ItemController {
|
|
|
337
422
|
});
|
|
338
423
|
}
|
|
339
424
|
onItemVisibilityChange(param) {
|
|
340
|
-
const { ids, value, animate = true } = param;
|
|
425
|
+
const { ids, value, graphCore, animate = true } = param;
|
|
341
426
|
ids.forEach((id) => {
|
|
342
427
|
const item = this.itemMap[id];
|
|
343
428
|
if (!item) {
|
|
344
429
|
console.warn(`Fail to set visibility for item ${id}, which is not exist.`);
|
|
345
430
|
return;
|
|
346
431
|
}
|
|
432
|
+
const type = item.getType();
|
|
347
433
|
if (value) {
|
|
348
|
-
|
|
434
|
+
if (type === 'edge') {
|
|
435
|
+
item.show(animate);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
let anccestorCollapsed = false;
|
|
439
|
+
traverseAncestors(graphCore, [item.model], (model) => {
|
|
440
|
+
if (model.data.collapsed)
|
|
441
|
+
anccestorCollapsed = true;
|
|
442
|
+
return anccestorCollapsed;
|
|
443
|
+
});
|
|
444
|
+
if (anccestorCollapsed)
|
|
445
|
+
return;
|
|
446
|
+
const relatedEdges = graphCore.getRelatedEdges(id);
|
|
447
|
+
item.show(animate);
|
|
448
|
+
relatedEdges.forEach(({ id: edgeId, source, target }) => {
|
|
449
|
+
var _a;
|
|
450
|
+
if (this.getItemVisible(source) && this.getItemVisible(target))
|
|
451
|
+
(_a = this.itemMap[edgeId]) === null || _a === void 0 ? void 0 : _a.show();
|
|
452
|
+
});
|
|
453
|
+
}
|
|
349
454
|
}
|
|
350
455
|
else {
|
|
351
456
|
item.hide(animate);
|
|
457
|
+
if (type !== 'edge') {
|
|
458
|
+
const relatedEdges = graphCore.getRelatedEdges(id);
|
|
459
|
+
relatedEdges.forEach(({ id: edgeId }) => {
|
|
460
|
+
var _a;
|
|
461
|
+
(_a = this.itemMap[edgeId]) === null || _a === void 0 ? void 0 : _a.hide();
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
onItemZIndexChange(params) {
|
|
468
|
+
const { ids = [], action } = params;
|
|
469
|
+
ids.forEach((id) => {
|
|
470
|
+
const item = this.itemMap[id];
|
|
471
|
+
if (item) {
|
|
472
|
+
if (action === 'front') {
|
|
473
|
+
graphComboTreeDfs(this.graph, [item.model], (model) => {
|
|
474
|
+
if (model.data._isCombo) {
|
|
475
|
+
const subCombo = this.itemMap[model.id];
|
|
476
|
+
subCombo && subCombo.toFront();
|
|
477
|
+
}
|
|
478
|
+
}, 'TB');
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
item.toBack();
|
|
482
|
+
traverseGraphAncestors(this.graph, [item.model], (model) => {
|
|
483
|
+
var _a;
|
|
484
|
+
(_a = this.itemMap[model.id]) === null || _a === void 0 ? void 0 : _a.toBack();
|
|
485
|
+
});
|
|
486
|
+
}
|
|
352
487
|
}
|
|
353
488
|
});
|
|
354
489
|
}
|
|
355
490
|
onTransientUpdate(param) {
|
|
356
491
|
const { transientObjectMap } = this;
|
|
357
|
-
const { type, id, config = {}, canvas } = param;
|
|
358
|
-
const { style = {}, data = {}, capture, action, onlyDrawKeyShape, } = config;
|
|
492
|
+
const { type, id, config = {}, canvas, graphCore } = param;
|
|
493
|
+
const { style = {}, data = {}, capture, action, onlyDrawKeyShape, upsertAncestors, } = config;
|
|
359
494
|
const isItemType = type === 'node' || type === 'edge' || type === 'combo';
|
|
360
495
|
// Removing
|
|
361
496
|
if (action === 'remove') {
|
|
362
497
|
if (isItemType) {
|
|
363
498
|
const transientItem = this.transientItemMap[id];
|
|
499
|
+
if (type === 'combo') {
|
|
500
|
+
// remove children from bottom to top
|
|
501
|
+
graphCoreTreeDfs(graphCore, [graphCore.getNode(id)], (child) => {
|
|
502
|
+
const transientChild = this.transientItemMap[child.id];
|
|
503
|
+
if (transientChild && !transientChild.destroyed) {
|
|
504
|
+
transientChild.destroy();
|
|
505
|
+
}
|
|
506
|
+
delete this.transientItemMap[child.id];
|
|
507
|
+
}, 'BT');
|
|
508
|
+
}
|
|
364
509
|
if (transientItem && !transientItem.destroyed) {
|
|
365
510
|
transientItem.destroy();
|
|
366
511
|
}
|
|
@@ -369,9 +514,8 @@ export class ItemController {
|
|
|
369
514
|
}
|
|
370
515
|
else {
|
|
371
516
|
const preObj = transientObjectMap[id];
|
|
372
|
-
if (preObj && !preObj.destroyed)
|
|
517
|
+
if (preObj && !preObj.destroyed)
|
|
373
518
|
preObj.destroy();
|
|
374
|
-
}
|
|
375
519
|
delete transientObjectMap[id];
|
|
376
520
|
return;
|
|
377
521
|
}
|
|
@@ -383,10 +527,10 @@ export class ItemController {
|
|
|
383
527
|
console.warn(`Fail to draw transient item of ${id}, which is not exist.`);
|
|
384
528
|
return;
|
|
385
529
|
}
|
|
386
|
-
const transientItem = upsertTransientItem(item, this.transientNodeGroup, this.transientEdgeGroup, this.transientItemMap, onlyDrawKeyShape);
|
|
530
|
+
const transientItem = upsertTransientItem(item, this.transientNodeGroup, this.transientEdgeGroup, this.transientComboGroup, this.transientItemMap, this.itemMap, graphCore, onlyDrawKeyShape, upsertAncestors);
|
|
387
531
|
if (onlyDrawKeyShape) {
|
|
388
532
|
// only update node positions to cloned node container(group)
|
|
389
|
-
if (type === 'node' &&
|
|
533
|
+
if ((type === 'node' || type === 'combo') &&
|
|
390
534
|
data.hasOwnProperty('x') &&
|
|
391
535
|
data.hasOwnProperty('y')) {
|
|
392
536
|
const { x, y } = data;
|
|
@@ -396,6 +540,33 @@ export class ItemController {
|
|
|
396
540
|
}
|
|
397
541
|
else {
|
|
398
542
|
const transItem = transientItem;
|
|
543
|
+
const positionChanged = data.hasOwnProperty('x') && data.hasOwnProperty('y');
|
|
544
|
+
if (type === 'combo' && positionChanged) {
|
|
545
|
+
const { x, y } = data;
|
|
546
|
+
const { x: ox = x, y: oy = y } = transItem.displayModel.data;
|
|
547
|
+
const dx = x - ox;
|
|
548
|
+
const dy = y - oy;
|
|
549
|
+
// move combo = move children nodes from bottom to top
|
|
550
|
+
graphCoreTreeDfs(graphCore, [transItem.model], (node) => {
|
|
551
|
+
const transChild = this.transientItemMap[node.id];
|
|
552
|
+
if (!transChild)
|
|
553
|
+
return;
|
|
554
|
+
const { x: childX, y: childY } = transChild.model
|
|
555
|
+
.data;
|
|
556
|
+
transChild === null || transChild === void 0 ? void 0 : transChild.update(Object.assign(Object.assign({}, transChild.model), { data: Object.assign(Object.assign({}, transChild.model.data), { x: childX + dx, y: childY + dy }) }));
|
|
557
|
+
}, 'BT');
|
|
558
|
+
}
|
|
559
|
+
if (type !== 'edge' && positionChanged) {
|
|
560
|
+
// force update ancestor combos in the sametime
|
|
561
|
+
let currentAncestor = graphCore.getParent(transItem.model.id, 'combo');
|
|
562
|
+
while (currentAncestor) {
|
|
563
|
+
const ancestorItem = this.transientItemMap[currentAncestor.id];
|
|
564
|
+
if (ancestorItem)
|
|
565
|
+
ancestorItem.forceUpdate();
|
|
566
|
+
currentAncestor = graphCore.getParent(currentAncestor.id, 'combo');
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
// Update the target combo's posiiton and other props
|
|
399
570
|
transItem.update(Object.assign(Object.assign({}, transItem.model), { data: Object.assign(Object.assign({}, transItem.model.data), data) }));
|
|
400
571
|
}
|
|
401
572
|
return;
|
|
@@ -436,6 +607,39 @@ export class ItemController {
|
|
|
436
607
|
});
|
|
437
608
|
});
|
|
438
609
|
}
|
|
610
|
+
renderCombos(models, comboTheme = {}, graphCore) {
|
|
611
|
+
const { comboExtensions, comboGroup, comboDataTypeSet, graph, itemMap } = this;
|
|
612
|
+
const { dataTypeField } = comboTheme;
|
|
613
|
+
const zoom = graph.getZoom();
|
|
614
|
+
models.forEach((combo) => {
|
|
615
|
+
// get the base styles from theme
|
|
616
|
+
let dataType;
|
|
617
|
+
if (dataTypeField)
|
|
618
|
+
dataType = combo.data[dataTypeField];
|
|
619
|
+
const itemTheme = getItemTheme(comboDataTypeSet, dataTypeField, dataType, comboTheme);
|
|
620
|
+
itemMap[combo.id] = new Combo({
|
|
621
|
+
model: combo,
|
|
622
|
+
getCombinedBounds: () => {
|
|
623
|
+
// calculate the position of the combo according to its children
|
|
624
|
+
const childModels = graphCore.getChildren(combo.id, 'combo');
|
|
625
|
+
return getCombinedBoundsByData(graph, childModels);
|
|
626
|
+
},
|
|
627
|
+
getChildren: () => {
|
|
628
|
+
const childModels = graphCore.getChildren(combo.id, 'combo');
|
|
629
|
+
return childModels.map(({ id }) => itemMap[id]);
|
|
630
|
+
},
|
|
631
|
+
renderExtensions: comboExtensions,
|
|
632
|
+
containerGroup: comboGroup,
|
|
633
|
+
mapper: this.comboMapper,
|
|
634
|
+
stateMapper: this.comboStateMapper,
|
|
635
|
+
zoom,
|
|
636
|
+
theme: itemTheme,
|
|
637
|
+
device: graph.rendererType === 'webgl-3d'
|
|
638
|
+
? graph.canvas.context.deviceRendererPlugin.getDevice()
|
|
639
|
+
: undefined,
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
}
|
|
439
643
|
/**
|
|
440
644
|
* Create edges with inner data to canvas.
|
|
441
645
|
* @param models edges' inner datas
|
|
@@ -506,12 +710,14 @@ export class ItemController {
|
|
|
506
710
|
getItemById(id) {
|
|
507
711
|
return this.itemMap[id];
|
|
508
712
|
}
|
|
509
|
-
getItemBBox(id, isKeyShape = false) {
|
|
510
|
-
const item = this.itemMap[id];
|
|
713
|
+
getItemBBox(id, isKeyShape = false, isTransient = false) {
|
|
714
|
+
const item = isTransient ? this.transientItemMap[id] : this.itemMap[id];
|
|
511
715
|
if (!item) {
|
|
512
716
|
console.warn(`Fail to get item bbox, the item with id ${id} does not exist.`);
|
|
513
717
|
return false;
|
|
514
718
|
}
|
|
719
|
+
if (item instanceof Group)
|
|
720
|
+
return item.getRenderBounds();
|
|
515
721
|
return isKeyShape ? item.getKeyBBox() : item.getBBox();
|
|
516
722
|
}
|
|
517
723
|
getItemVisible(id) {
|
|
@@ -522,6 +728,92 @@ export class ItemController {
|
|
|
522
728
|
}
|
|
523
729
|
return item.isVisible();
|
|
524
730
|
}
|
|
731
|
+
sortByComboTree(graphCore) {
|
|
732
|
+
if (!graphCore.hasTreeStructure('combo'))
|
|
733
|
+
return;
|
|
734
|
+
graphCoreTreeDfs(graphCore, graphCore.getRoots('combo'), (node) => {
|
|
735
|
+
const nodeItem = this.itemMap[node.id];
|
|
736
|
+
if (node.data._isCombo && nodeItem) {
|
|
737
|
+
nodeItem.toFront();
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
collapseCombo(graphCore, comboModel) {
|
|
742
|
+
let relatedEdges = [];
|
|
743
|
+
const succeedIds = [];
|
|
744
|
+
// hide the succeeds
|
|
745
|
+
graphComboTreeDfs(this.graph, [comboModel], (child) => {
|
|
746
|
+
if (child.id !== comboModel.id)
|
|
747
|
+
this.graph.hideItem(child.id);
|
|
748
|
+
relatedEdges = relatedEdges.concat(graphCore.getRelatedEdges(child.id));
|
|
749
|
+
succeedIds.push(child.id);
|
|
750
|
+
});
|
|
751
|
+
const virtualEdges = [];
|
|
752
|
+
const groupedEdges = new Map();
|
|
753
|
+
uniq(relatedEdges).forEach((edge) => {
|
|
754
|
+
const { source: s, target: t, data } = edge;
|
|
755
|
+
if (data._virtual)
|
|
756
|
+
return;
|
|
757
|
+
const sourceIsSucceed = succeedIds.includes(s);
|
|
758
|
+
const targetIsSucceed = succeedIds.includes(t);
|
|
759
|
+
// do not add virtual edge if the source and target are both the succeed
|
|
760
|
+
if (sourceIsSucceed && targetIsSucceed)
|
|
761
|
+
return;
|
|
762
|
+
const source = sourceIsSucceed ? comboModel.id : s;
|
|
763
|
+
const target = targetIsSucceed ? comboModel.id : t;
|
|
764
|
+
const key = `${source}_${target}`;
|
|
765
|
+
const group = groupedEdges.get(key) || { edges: [], source, target };
|
|
766
|
+
group.edges.push(edge);
|
|
767
|
+
groupedEdges.set(key, group);
|
|
768
|
+
});
|
|
769
|
+
// each item in groupedEdges is a virtual edge
|
|
770
|
+
groupedEdges.forEach((group) => {
|
|
771
|
+
const { source, target, edges } = group;
|
|
772
|
+
virtualEdges.push({
|
|
773
|
+
id: `virtual-${uniqueId()}`,
|
|
774
|
+
source,
|
|
775
|
+
target,
|
|
776
|
+
data: {
|
|
777
|
+
_virtual: true,
|
|
778
|
+
keyShape: {
|
|
779
|
+
lineWidth: edges.length,
|
|
780
|
+
},
|
|
781
|
+
},
|
|
782
|
+
});
|
|
783
|
+
});
|
|
784
|
+
this.graph.addData('edge', virtualEdges);
|
|
785
|
+
}
|
|
786
|
+
expandCombo(graphCore, comboModel) {
|
|
787
|
+
let isAncestorCollapsed = false;
|
|
788
|
+
traverseAncestors(graphCore, [comboModel], (anccestor) => {
|
|
789
|
+
if (anccestor.data.collapsed) {
|
|
790
|
+
isAncestorCollapsed = true;
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
793
|
+
return false;
|
|
794
|
+
});
|
|
795
|
+
if (isAncestorCollapsed)
|
|
796
|
+
return;
|
|
797
|
+
const relatedVirtualEdgeIds = [];
|
|
798
|
+
// show the succeeds
|
|
799
|
+
graphComboTreeDfs(this.graph, [comboModel], (child) => {
|
|
800
|
+
graphCore.getRelatedEdges(child.id).forEach((edge) => {
|
|
801
|
+
if (edge.data._virtual)
|
|
802
|
+
relatedVirtualEdgeIds.push(edge.id);
|
|
803
|
+
});
|
|
804
|
+
if (child.id !== comboModel.id) {
|
|
805
|
+
if (!graphCore.getNode(child.data.parentId).data.collapsed) {
|
|
806
|
+
this.graph.showItem(child.id);
|
|
807
|
+
}
|
|
808
|
+
// re-add collapsed succeeds' virtual edges by calling collapseCombo
|
|
809
|
+
if (child.data._isCombo && child.data.collapsed) {
|
|
810
|
+
this.collapseCombo(graphCore, child);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
// remove related virtual edges
|
|
815
|
+
this.graph.removeData('edge', uniq(relatedVirtualEdgeIds));
|
|
816
|
+
}
|
|
525
817
|
}
|
|
526
818
|
const getItemTheme = (dataTypeSet, dataTypeField, dataType, itemTheme) => {
|
|
527
819
|
const { styles: themeStyles, lodStrategy } = itemTheme;
|