@antv/layout 1.2.13 → 1.2.14-beta.0
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/85db61ddc757dae66e04.worker.js +2 -0
- package/dist/85db61ddc757dae66e04.worker.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/lib/{dagre → antv-dagre}/acyclic.d.ts +1 -1
- package/lib/antv-dagre/acyclic.js +65 -0
- package/lib/antv-dagre/acyclic.js.map +1 -0
- package/lib/antv-dagre/add-border-segments.js +41 -0
- package/lib/antv-dagre/add-border-segments.js.map +1 -0
- package/lib/{dagre → antv-dagre}/coordinate-system.d.ts +2 -1
- package/lib/antv-dagre/coordinate-system.js +69 -0
- package/lib/antv-dagre/coordinate-system.js.map +1 -0
- package/lib/{dagre → antv-dagre}/data/list.d.ts +1 -1
- package/lib/{dagre → antv-dagre}/data/list.js +23 -22
- package/lib/antv-dagre/data/list.js.map +1 -0
- package/lib/{dagre → antv-dagre}/greedy-fas.d.ts +2 -2
- package/lib/antv-dagre/greedy-fas.js +141 -0
- package/lib/antv-dagre/greedy-fas.js.map +1 -0
- package/lib/{dagre → antv-dagre}/layout.d.ts +2 -1
- package/lib/{dagre → antv-dagre}/layout.js +156 -154
- package/lib/antv-dagre/layout.js.map +1 -0
- package/lib/{dagre → antv-dagre}/nesting-graph.js +42 -39
- package/lib/antv-dagre/nesting-graph.js.map +1 -0
- package/lib/{dagre → antv-dagre}/normalize.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/normalize.js +29 -25
- package/lib/antv-dagre/normalize.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/add-subgraph-constraints.js +13 -9
- package/lib/antv-dagre/order/add-subgraph-constraints.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/barycenter.d.ts +2 -2
- package/lib/antv-dagre/order/barycenter.js +27 -0
- package/lib/antv-dagre/order/barycenter.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/build-layer-graph.js +23 -23
- package/lib/antv-dagre/order/build-layer-graph.js.map +1 -0
- package/lib/antv-dagre/order/cross-count.d.ts +3 -0
- package/lib/{dagre → antv-dagre}/order/cross-count.js +21 -17
- package/lib/antv-dagre/order/cross-count.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/index.d.ts +1 -1
- package/lib/antv-dagre/order/index.js +95 -0
- package/lib/antv-dagre/order/index.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/init-data-order.js +12 -9
- package/lib/antv-dagre/order/init-data-order.js.map +1 -0
- package/lib/antv-dagre/order/init-order.js +51 -0
- package/lib/antv-dagre/order/init-order.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/resolve-conflicts.d.ts +3 -3
- package/lib/{dagre → antv-dagre}/order/resolve-conflicts.js +35 -36
- package/lib/antv-dagre/order/resolve-conflicts.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/sort-subgraph.js +28 -23
- package/lib/antv-dagre/order/sort-subgraph.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/sort.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/order/sort.js +23 -19
- package/lib/antv-dagre/order/sort.js.map +1 -0
- package/lib/{dagre → antv-dagre}/parent-dummy-chains.js +32 -28
- package/lib/antv-dagre/parent-dummy-chains.js.map +1 -0
- package/lib/{dagre → antv-dagre}/position/bk.d.ts +5 -4
- package/lib/{dagre → antv-dagre}/position/bk.js +162 -148
- package/lib/antv-dagre/position/bk.js.map +1 -0
- package/lib/{dagre → antv-dagre}/position/index.d.ts +2 -1
- package/lib/antv-dagre/position/index.js +55 -0
- package/lib/antv-dagre/position/index.js.map +1 -0
- package/lib/{dagre → antv-dagre}/rank/feasible-tree.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/rank/feasible-tree.js +42 -38
- package/lib/antv-dagre/rank/feasible-tree.js.map +1 -0
- package/lib/antv-dagre/rank/index.d.ts +2 -0
- package/lib/{dagre → antv-dagre}/rank/index.js +17 -13
- package/lib/antv-dagre/rank/index.js.map +1 -0
- package/lib/{dagre → antv-dagre}/rank/network-simplex.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/rank/network-simplex.js +90 -81
- package/lib/antv-dagre/rank/network-simplex.js.map +1 -0
- package/lib/{dagre → antv-dagre}/rank/util.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/rank/util.js +37 -32
- package/lib/antv-dagre/rank/util.js.map +1 -0
- package/lib/antv-dagre/types.d.ts +2 -0
- package/lib/antv-dagre/types.js +3 -0
- package/lib/antv-dagre/types.js.map +1 -0
- package/lib/{dagre → antv-dagre}/util.d.ts +1 -1
- package/lib/antv-dagre/util.js +299 -0
- package/lib/antv-dagre/util.js.map +1 -0
- package/lib/antv-dagre.d.ts +50 -0
- package/lib/antv-dagre.js +542 -0
- package/lib/antv-dagre.js.map +1 -0
- package/lib/bundle-entry.d.ts +2 -18
- package/lib/bundle-entry.js +5 -18
- package/lib/bundle-entry.js.map +1 -1
- package/lib/bundle-supervisor.d.ts +4 -22
- package/lib/bundle-supervisor.js +59 -54
- package/lib/bundle-supervisor.js.map +1 -1
- package/lib/bundle-worker.d.ts +1 -1
- package/lib/bundle-worker.js +38 -35
- package/lib/bundle-worker.js.map +1 -1
- package/lib/circular.d.ts +1 -1
- package/lib/circular.js +133 -145
- package/lib/circular.js.map +1 -1
- package/lib/comboCombined.d.ts +1 -1
- package/lib/comboCombined.js +273 -299
- package/lib/comboCombined.js.map +1 -1
- package/lib/concentric.d.ts +1 -1
- package/lib/concentric.js +173 -179
- package/lib/concentric.js.map +1 -1
- package/lib/d3Force/forceInBox.js +80 -78
- package/lib/d3Force/forceInBox.js.map +1 -1
- package/lib/d3Force/index.d.ts +2 -2
- package/lib/d3Force/index.js +207 -229
- package/lib/d3Force/index.js.map +1 -1
- package/lib/dagre.d.ts +13 -24
- package/lib/dagre.js +61 -542
- package/lib/dagre.js.map +1 -1
- package/lib/exports.d.ts +17 -0
- package/lib/exports.js +20 -0
- package/lib/exports.js.map +1 -0
- package/lib/force/forceNBody.js +48 -47
- package/lib/force/forceNBody.js.map +1 -1
- package/lib/force/index.d.ts +1 -1
- package/lib/force/index.js +301 -324
- package/lib/force/index.js.map +1 -1
- package/lib/force/types.d.ts +5 -5
- package/lib/force/types.js +2 -1
- package/lib/forceAtlas2/body.d.ts +1 -1
- package/lib/forceAtlas2/body.js +32 -31
- package/lib/forceAtlas2/body.js.map +1 -1
- package/lib/forceAtlas2/index.d.ts +1 -1
- package/lib/forceAtlas2/index.js +219 -227
- package/lib/forceAtlas2/index.js.map +1 -1
- package/lib/forceAtlas2/quad.d.ts +2 -2
- package/lib/forceAtlas2/quad.js +43 -42
- package/lib/forceAtlas2/quad.js.map +1 -1
- package/lib/forceAtlas2/quadTree.js +19 -17
- package/lib/forceAtlas2/quadTree.js.map +1 -1
- package/lib/fruchterman.d.ts +1 -1
- package/lib/fruchterman.js +203 -219
- package/lib/fruchterman.js.map +1 -1
- package/lib/grid.d.ts +1 -1
- package/lib/grid.js +201 -207
- package/lib/grid.js.map +1 -1
- package/lib/index.d.ts +1 -15
- package/lib/index.js +5 -16
- package/lib/index.js.map +1 -1
- package/lib/mds.d.ts +1 -1
- package/lib/mds.js +73 -79
- package/lib/mds.js.map +1 -1
- package/lib/radial/index.d.ts +1 -1
- package/lib/radial/index.js +183 -186
- package/lib/radial/index.js.map +1 -1
- package/lib/radial/mds.d.ts +1 -1
- package/lib/radial/mds.js +20 -14
- package/lib/radial/mds.js.map +1 -1
- package/lib/radial/radial-nonoverlap-force.d.ts +2 -2
- package/lib/radial/radial-nonoverlap-force.js +40 -37
- package/lib/radial/radial-nonoverlap-force.js.map +1 -1
- package/lib/random.d.ts +1 -1
- package/lib/random.js +57 -66
- package/lib/random.js.map +1 -1
- package/lib/registry.d.ts +2 -2
- package/lib/registry.js +30 -25
- package/lib/registry.js.map +1 -1
- package/lib/supervisor.d.ts +2 -3
- package/lib/supervisor.js +63 -58
- package/lib/supervisor.js.map +1 -1
- package/lib/types.d.ts +20 -75
- package/lib/types.js +5 -1
- package/lib/types.js.map +1 -1
- package/lib/util/array.js +4 -1
- package/lib/util/array.js.map +1 -1
- package/lib/util/common.d.ts +1 -1
- package/lib/util/common.js +11 -8
- package/lib/util/common.js.map +1 -1
- package/lib/util/function.js +41 -37
- package/lib/util/function.js.map +1 -1
- package/lib/util/index.d.ts +0 -2
- package/lib/util/index.js +7 -6
- package/lib/util/index.js.map +1 -1
- package/lib/util/math.d.ts +1 -26
- package/lib/util/math.js +55 -154
- package/lib/util/math.js.map +1 -1
- package/lib/util/object.d.ts +1 -1
- package/lib/util/object.js +20 -15
- package/lib/util/object.js.map +1 -1
- package/lib/util/size.d.ts +3 -0
- package/lib/util/size.js +16 -0
- package/lib/util/size.js.map +1 -0
- package/lib/worker.js +36 -35
- package/lib/worker.js.map +1 -1
- package/package.json +10 -6
- package/dist/aa1bb0ccc06b11cf79c1.worker.js +0 -2
- package/dist/aa1bb0ccc06b11cf79c1.worker.js.map +0 -1
- package/lib/dagre/acyclic.js +0 -62
- package/lib/dagre/acyclic.js.map +0 -1
- package/lib/dagre/add-border-segments.js +0 -37
- package/lib/dagre/add-border-segments.js.map +0 -1
- package/lib/dagre/coordinate-system.js +0 -65
- package/lib/dagre/coordinate-system.js.map +0 -1
- package/lib/dagre/data/list.js.map +0 -1
- package/lib/dagre/greedy-fas.js +0 -147
- package/lib/dagre/greedy-fas.js.map +0 -1
- package/lib/dagre/layout.js.map +0 -1
- package/lib/dagre/nesting-graph.js.map +0 -1
- package/lib/dagre/normalize.js.map +0 -1
- package/lib/dagre/order/add-subgraph-constraints.js.map +0 -1
- package/lib/dagre/order/barycenter.js +0 -23
- package/lib/dagre/order/barycenter.js.map +0 -1
- package/lib/dagre/order/build-layer-graph.js.map +0 -1
- package/lib/dagre/order/cross-count.d.ts +0 -3
- package/lib/dagre/order/cross-count.js.map +0 -1
- package/lib/dagre/order/index.js +0 -91
- package/lib/dagre/order/index.js.map +0 -1
- package/lib/dagre/order/init-data-order.js.map +0 -1
- package/lib/dagre/order/init-order.js +0 -50
- package/lib/dagre/order/init-order.js.map +0 -1
- package/lib/dagre/order/resolve-conflicts.js.map +0 -1
- package/lib/dagre/order/sort-subgraph.js.map +0 -1
- package/lib/dagre/order/sort.js.map +0 -1
- package/lib/dagre/parent-dummy-chains.js.map +0 -1
- package/lib/dagre/position/bk.js.map +0 -1
- package/lib/dagre/position/index.js +0 -54
- package/lib/dagre/position/index.js.map +0 -1
- package/lib/dagre/rank/feasible-tree.js.map +0 -1
- package/lib/dagre/rank/index.d.ts +0 -2
- package/lib/dagre/rank/index.js.map +0 -1
- package/lib/dagre/rank/network-simplex.js.map +0 -1
- package/lib/dagre/rank/util.js.map +0 -1
- package/lib/dagre/util.js +0 -289
- package/lib/dagre/util.js.map +0 -1
- package/lib/util/gpu.d.ts +0 -45
- package/lib/util/gpu.js +0 -214
- package/lib/util/gpu.js.map +0 -1
- package/lib/util/number.d.ts +0 -1
- package/lib/util/number.js +0 -5
- package/lib/util/number.js.map +0 -1
- package/lib/util/string.d.ts +0 -1
- package/lib/util/string.js +0 -15
- package/lib/util/string.js.map +0 -1
- /package/lib/{dagre → antv-dagre}/add-border-segments.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/nesting-graph.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/add-subgraph-constraints.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/build-layer-graph.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/init-data-order.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/init-order.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/sort-subgraph.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/parent-dummy-chains.d.ts +0 -0
package/lib/comboCombined.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComboCombinedLayout = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const graphlib_1 = require("@antv/graphlib");
|
|
6
|
+
const util_1 = require("@antv/util");
|
|
7
|
+
const concentric_1 = require("./concentric");
|
|
8
|
+
const force_1 = require("./force");
|
|
9
|
+
const mds_1 = require("./mds");
|
|
10
|
+
const util_2 = require("./util");
|
|
11
|
+
const common_1 = require("./util/common");
|
|
12
|
+
const FORCE_LAYOUT_TYPE_MAP = {
|
|
10
13
|
gForce: true,
|
|
11
14
|
force2: true,
|
|
12
15
|
d3force: true,
|
|
@@ -15,7 +18,7 @@ var FORCE_LAYOUT_TYPE_MAP = {
|
|
|
15
18
|
force: true,
|
|
16
19
|
'graphin-force': true,
|
|
17
20
|
};
|
|
18
|
-
|
|
21
|
+
const DEFAULTS_LAYOUT_OPTIONS = {
|
|
19
22
|
center: [0, 0],
|
|
20
23
|
comboPadding: 10,
|
|
21
24
|
treeKey: 'combo',
|
|
@@ -35,232 +38,213 @@ var DEFAULTS_LAYOUT_OPTIONS = {
|
|
|
35
38
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
36
39
|
* await layout.assign(graph, { radius: 20 });
|
|
37
40
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (options === void 0) { options = {}; }
|
|
41
|
+
class ComboCombinedLayout {
|
|
42
|
+
constructor(options = {}) {
|
|
41
43
|
this.options = options;
|
|
42
44
|
this.id = 'comboCombined';
|
|
43
|
-
this.options =
|
|
45
|
+
this.options = Object.assign(Object.assign({}, DEFAULTS_LAYOUT_OPTIONS), options);
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
48
|
* Return the positions of nodes and edges(if needed).
|
|
47
49
|
*/
|
|
48
|
-
|
|
49
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
return
|
|
51
|
-
return [2 /*return*/, this.genericComboCombinedLayout(false, graph, options)];
|
|
52
|
-
});
|
|
50
|
+
execute(graph, options) {
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
return this.genericComboCombinedLayout(false, graph, options);
|
|
53
53
|
});
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
/**
|
|
56
56
|
* To directly assign the positions to the nodes.
|
|
57
57
|
*/
|
|
58
|
-
|
|
59
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
assign(graph, options) {
|
|
59
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
yield this.genericComboCombinedLayout(true, graph, options);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
genericComboCombinedLayout(assign, graph, options) {
|
|
64
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const mergedOptions = this.initVals(Object.assign(Object.assign({}, this.options), options));
|
|
66
|
+
const { center, treeKey, outerLayout: propsOuterLayout } = mergedOptions;
|
|
67
|
+
const nodes = graph
|
|
68
|
+
.getAllNodes()
|
|
69
|
+
.filter((node) => !node.data._isCombo);
|
|
70
|
+
const combos = graph
|
|
71
|
+
.getAllNodes()
|
|
72
|
+
.filter((node) => node.data._isCombo);
|
|
73
|
+
const edges = graph.getAllEdges();
|
|
74
|
+
const n = nodes === null || nodes === void 0 ? void 0 : nodes.length;
|
|
75
|
+
if (!n || n === 1) {
|
|
76
|
+
return (0, common_1.handleSingleNodeGraph)(graph, assign, center);
|
|
77
|
+
}
|
|
78
|
+
// output nodes
|
|
79
|
+
const layoutNodes = [];
|
|
80
|
+
const nodeMap = new Map();
|
|
81
|
+
nodes.forEach((node) => {
|
|
82
|
+
nodeMap.set(node.id, node);
|
|
83
|
+
});
|
|
84
|
+
const comboMap = new Map();
|
|
85
|
+
combos.forEach((combo) => {
|
|
86
|
+
comboMap.set(combo.id, combo);
|
|
87
|
+
});
|
|
88
|
+
// each one in comboNodes is a combo contains the size and child nodes
|
|
89
|
+
// comboNodes ncludes the node who has no parent combo
|
|
90
|
+
const comboNodes = new Map();
|
|
91
|
+
// the inner layouts, the result positions are stored in comboNodes and their child nodes
|
|
92
|
+
const innerGraphLayoutPromises = this.getInnerGraphs(graph, treeKey, nodeMap, comboMap, edges, mergedOptions, comboNodes);
|
|
93
|
+
yield Promise.all(innerGraphLayoutPromises);
|
|
94
|
+
const outerNodeIds = new Map();
|
|
95
|
+
const outerLayoutNodes = [];
|
|
96
|
+
const nodeAncestorIdMap = new Map();
|
|
97
|
+
let allHaveNoPosition = true;
|
|
98
|
+
graph.getRoots(treeKey).forEach((root) => {
|
|
99
|
+
const combo = comboNodes.get(root.id);
|
|
100
|
+
const cacheCombo = comboMap.get(root.id) || nodeMap.get(root.id);
|
|
101
|
+
const comboLayoutNode = {
|
|
102
|
+
id: root.id,
|
|
103
|
+
data: Object.assign(Object.assign({}, root.data), { x: combo.data.x || cacheCombo.data.x, y: combo.data.y || cacheCombo.data.y, fx: combo.data.fx || cacheCombo.data.fx, fy: combo.data.fy || cacheCombo.data.fy, mass: combo.data.mass || cacheCombo.data.mass, size: combo.data.size }),
|
|
104
|
+
};
|
|
105
|
+
outerLayoutNodes.push(comboLayoutNode);
|
|
106
|
+
outerNodeIds.set(root.id, true);
|
|
107
|
+
if (!isNaN(comboLayoutNode.data.x) &&
|
|
108
|
+
comboLayoutNode.data.x !== 0 &&
|
|
109
|
+
!isNaN(comboLayoutNode.data.y) &&
|
|
110
|
+
comboLayoutNode.data.y !== 0) {
|
|
111
|
+
allHaveNoPosition = false;
|
|
66
112
|
}
|
|
113
|
+
else {
|
|
114
|
+
comboLayoutNode.data.x = Math.random() * 100;
|
|
115
|
+
comboLayoutNode.data.y = Math.random() * 100;
|
|
116
|
+
}
|
|
117
|
+
(0, util_2.graphTreeDfs)(graph, [root], (child) => {
|
|
118
|
+
if (child.id !== root.id)
|
|
119
|
+
nodeAncestorIdMap.set(child.id, root.id);
|
|
120
|
+
}, 'TB', treeKey);
|
|
67
121
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
122
|
+
const outerLayoutEdges = [];
|
|
123
|
+
edges.forEach((edge) => {
|
|
124
|
+
const sourceAncestorId = nodeAncestorIdMap.get(edge.source) || edge.source;
|
|
125
|
+
const targetAncestorId = nodeAncestorIdMap.get(edge.target) || edge.target;
|
|
126
|
+
// create an edge for outer layout if both source and target's ancestor combo is in outer layout nodes
|
|
127
|
+
if (sourceAncestorId !== targetAncestorId &&
|
|
128
|
+
outerNodeIds.has(sourceAncestorId) &&
|
|
129
|
+
outerNodeIds.has(targetAncestorId)) {
|
|
130
|
+
outerLayoutEdges.push({
|
|
131
|
+
id: edge.id,
|
|
132
|
+
source: sourceAncestorId,
|
|
133
|
+
target: targetAncestorId,
|
|
134
|
+
data: {},
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
// 若有需要最外层的 combo 或节点,则对最外层执行力导向
|
|
139
|
+
let outerPositions;
|
|
140
|
+
if (outerLayoutNodes === null || outerLayoutNodes === void 0 ? void 0 : outerLayoutNodes.length) {
|
|
141
|
+
if (outerLayoutNodes.length === 1) {
|
|
142
|
+
outerLayoutNodes[0].data.x = center[0];
|
|
143
|
+
outerLayoutNodes[0].data.y = center[1];
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const outerLayoutGraph = new graphlib_1.Graph({
|
|
147
|
+
nodes: outerLayoutNodes,
|
|
148
|
+
edges: outerLayoutEdges,
|
|
149
|
+
});
|
|
150
|
+
const outerLayout = propsOuterLayout || new force_1.ForceLayout();
|
|
151
|
+
// preset the nodes if the outerLayout is a force family layout
|
|
152
|
+
if (allHaveNoPosition && FORCE_LAYOUT_TYPE_MAP[outerLayout.id]) {
|
|
153
|
+
const outerLayoutPreset = outerLayoutNodes.length < 100
|
|
154
|
+
? new mds_1.MDSLayout()
|
|
155
|
+
: new concentric_1.ConcentricLayout();
|
|
156
|
+
yield outerLayoutPreset.assign(outerLayoutGraph);
|
|
157
|
+
}
|
|
158
|
+
outerPositions = yield outerLayout.execute(outerLayoutGraph, Object.assign({ center, kg: 5, preventOverlap: true, animate: false }, (outerLayout.id === 'force'
|
|
159
|
+
? {
|
|
160
|
+
gravity: 1,
|
|
161
|
+
factor: 4,
|
|
162
|
+
linkDistance: (edge, source, target) => {
|
|
163
|
+
const sourceSize = Math.max(...source.data.size) || 32;
|
|
164
|
+
const targetSize = Math.max(...target.data.size) || 32;
|
|
165
|
+
return sourceSize / 2 + targetSize / 2 + 200;
|
|
166
|
+
},
|
|
88
167
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
outerLayoutNodes = [];
|
|
105
|
-
nodeAncestorIdMap = new Map();
|
|
106
|
-
allHaveNoPosition = true;
|
|
107
|
-
graph.getRoots(treeKey).forEach(function (root) {
|
|
108
|
-
var combo = comboNodes.get(root.id);
|
|
109
|
-
var cacheCombo = comboMap.get(root.id) || nodeMap.get(root.id);
|
|
110
|
-
var comboLayoutNode = {
|
|
111
|
-
id: root.id,
|
|
112
|
-
data: __assign(__assign({}, root.data), { x: combo.data.x || cacheCombo.data.x, y: combo.data.y || cacheCombo.data.y, fx: combo.data.fx || cacheCombo.data.fx, fy: combo.data.fy || cacheCombo.data.fy, mass: combo.data.mass || cacheCombo.data.mass, size: combo.data.size }),
|
|
113
|
-
};
|
|
114
|
-
outerLayoutNodes.push(comboLayoutNode);
|
|
115
|
-
outerNodeIds.set(root.id, true);
|
|
116
|
-
if (!isNaN(comboLayoutNode.data.x) &&
|
|
117
|
-
comboLayoutNode.data.x !== 0 &&
|
|
118
|
-
!isNaN(comboLayoutNode.data.y) &&
|
|
119
|
-
comboLayoutNode.data.y !== 0) {
|
|
120
|
-
allHaveNoPosition = false;
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
comboLayoutNode.data.x = Math.random() * 100;
|
|
124
|
-
comboLayoutNode.data.y = Math.random() * 100;
|
|
125
|
-
}
|
|
126
|
-
graphTreeDfs(graph, [root], function (child) {
|
|
127
|
-
if (child.id !== root.id)
|
|
128
|
-
nodeAncestorIdMap.set(child.id, root.id);
|
|
129
|
-
}, 'TB', treeKey);
|
|
130
|
-
});
|
|
131
|
-
outerLayoutEdges = [];
|
|
132
|
-
edges.forEach(function (edge) {
|
|
133
|
-
var sourceAncestorId = nodeAncestorIdMap.get(edge.source) || edge.source;
|
|
134
|
-
var targetAncestorId = nodeAncestorIdMap.get(edge.target) || edge.target;
|
|
135
|
-
// create an edge for outer layout if both source and target's ancestor combo is in outer layout nodes
|
|
136
|
-
if (sourceAncestorId !== targetAncestorId &&
|
|
137
|
-
outerNodeIds.has(sourceAncestorId) &&
|
|
138
|
-
outerNodeIds.has(targetAncestorId)) {
|
|
139
|
-
outerLayoutEdges.push({
|
|
140
|
-
id: edge.id,
|
|
141
|
-
source: sourceAncestorId,
|
|
142
|
-
target: targetAncestorId,
|
|
143
|
-
data: {},
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
if (!(outerLayoutNodes === null || outerLayoutNodes === void 0 ? void 0 : outerLayoutNodes.length)) return [3 /*break*/, 7];
|
|
148
|
-
if (!(outerLayoutNodes.length === 1)) return [3 /*break*/, 2];
|
|
149
|
-
outerLayoutNodes[0].data.x = center[0];
|
|
150
|
-
outerLayoutNodes[0].data.y = center[1];
|
|
151
|
-
return [3 /*break*/, 6];
|
|
152
|
-
case 2:
|
|
153
|
-
outerLayoutGraph = new GraphCore({
|
|
154
|
-
nodes: outerLayoutNodes,
|
|
155
|
-
edges: outerLayoutEdges,
|
|
156
|
-
});
|
|
157
|
-
outerLayout = propsOuterLayout || new ForceLayout();
|
|
158
|
-
if (!(allHaveNoPosition && FORCE_LAYOUT_TYPE_MAP[outerLayout.id])) return [3 /*break*/, 4];
|
|
159
|
-
outerLayoutPreset = outerLayoutNodes.length < 100
|
|
160
|
-
? new MDSLayout()
|
|
161
|
-
: new ConcentricLayout();
|
|
162
|
-
return [4 /*yield*/, outerLayoutPreset.assign(outerLayoutGraph)];
|
|
163
|
-
case 3:
|
|
164
|
-
_a.sent();
|
|
165
|
-
_a.label = 4;
|
|
166
|
-
case 4: return [4 /*yield*/, outerLayout.execute(outerLayoutGraph, __assign({ center: center, kg: 5, preventOverlap: true, animate: false }, (outerLayout.id === 'force'
|
|
167
|
-
? {
|
|
168
|
-
gravity: 1,
|
|
169
|
-
factor: 4,
|
|
170
|
-
linkDistance: function (edge, source, target) {
|
|
171
|
-
var sourceSize = Math.max.apply(Math, __spreadArray([], __read(source.data.size))) || 32;
|
|
172
|
-
var targetSize = Math.max.apply(Math, __spreadArray([], __read(target.data.size))) || 32;
|
|
173
|
-
return sourceSize / 2 + targetSize / 2 + 200;
|
|
174
|
-
},
|
|
175
|
-
}
|
|
176
|
-
: {})))];
|
|
177
|
-
case 5:
|
|
178
|
-
outerPositions = _a.sent();
|
|
179
|
-
_a.label = 6;
|
|
180
|
-
case 6:
|
|
181
|
-
// move the combos and their child nodes
|
|
182
|
-
comboNodes.forEach(function (comboNode) {
|
|
183
|
-
var _a;
|
|
184
|
-
var outerPosition = outerPositions.nodes.find(function (pos) { return pos.id === comboNode.id; });
|
|
185
|
-
if (outerPosition) {
|
|
186
|
-
// if it is one of the outer layout nodes, update the positions
|
|
187
|
-
var _b = outerPosition.data, x_1 = _b.x, y_1 = _b.y;
|
|
188
|
-
comboNode.data.visited = true;
|
|
189
|
-
comboNode.data.x = x_1;
|
|
190
|
-
comboNode.data.y = y_1;
|
|
191
|
-
layoutNodes.push({
|
|
192
|
-
id: comboNode.id,
|
|
193
|
-
data: { x: x_1, y: y_1 },
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
// move the child nodes
|
|
197
|
-
var _c = comboNode.data, x = _c.x, y = _c.y;
|
|
198
|
-
(_a = comboNode.data.nodes) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {
|
|
199
|
-
layoutNodes.push({
|
|
200
|
-
id: node.id,
|
|
201
|
-
data: { x: node.data.x + x, y: node.data.y + y },
|
|
202
|
-
});
|
|
203
|
-
});
|
|
168
|
+
: {})));
|
|
169
|
+
}
|
|
170
|
+
// move the combos and their child nodes
|
|
171
|
+
comboNodes.forEach((comboNode) => {
|
|
172
|
+
var _a;
|
|
173
|
+
const outerPosition = outerPositions.nodes.find((pos) => pos.id === comboNode.id);
|
|
174
|
+
if (outerPosition) {
|
|
175
|
+
// if it is one of the outer layout nodes, update the positions
|
|
176
|
+
const { x, y } = outerPosition.data;
|
|
177
|
+
comboNode.data.visited = true;
|
|
178
|
+
comboNode.data.x = x;
|
|
179
|
+
comboNode.data.y = y;
|
|
180
|
+
layoutNodes.push({
|
|
181
|
+
id: comboNode.id,
|
|
182
|
+
data: { x, y },
|
|
204
183
|
});
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
var layoutNode = layoutNodes.find(function (n) { return n.id === node.id; });
|
|
213
|
-
layoutNode.data.x += x || 0;
|
|
214
|
-
layoutNode.data.y += y || 0;
|
|
215
|
-
}
|
|
216
|
-
});
|
|
184
|
+
}
|
|
185
|
+
// move the child nodes
|
|
186
|
+
const { x, y } = comboNode.data;
|
|
187
|
+
(_a = comboNode.data.nodes) === null || _a === void 0 ? void 0 : _a.forEach((node) => {
|
|
188
|
+
layoutNodes.push({
|
|
189
|
+
id: node.id,
|
|
190
|
+
data: { x: node.data.x + x, y: node.data.y + y },
|
|
217
191
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
// move the nodes from top to bottom
|
|
195
|
+
comboNodes.forEach(({ data }) => {
|
|
196
|
+
const { x, y, visited, nodes } = data;
|
|
197
|
+
nodes === null || nodes === void 0 ? void 0 : nodes.forEach((node) => {
|
|
198
|
+
if (!visited) {
|
|
199
|
+
const layoutNode = layoutNodes.find((n) => n.id === node.id);
|
|
200
|
+
layoutNode.data.x += x || 0;
|
|
201
|
+
layoutNode.data.y += y || 0;
|
|
227
202
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (assign) {
|
|
207
|
+
layoutNodes.forEach((node) => {
|
|
208
|
+
graph.mergeNodeData(node.id, {
|
|
209
|
+
x: node.data.x,
|
|
210
|
+
y: node.data.y,
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const result = {
|
|
215
|
+
nodes: layoutNodes,
|
|
216
|
+
edges,
|
|
217
|
+
};
|
|
218
|
+
return result;
|
|
235
219
|
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
220
|
+
}
|
|
221
|
+
initVals(options) {
|
|
222
|
+
const formattedOptions = Object.assign({}, options);
|
|
223
|
+
const { nodeSize, spacing, comboPadding } = options;
|
|
224
|
+
let nodeSizeFunc;
|
|
225
|
+
let spacingFunc;
|
|
242
226
|
// nodeSpacing to function
|
|
243
|
-
if (isNumber(spacing)) {
|
|
244
|
-
spacingFunc =
|
|
227
|
+
if ((0, util_1.isNumber)(spacing)) {
|
|
228
|
+
spacingFunc = () => spacing;
|
|
245
229
|
}
|
|
246
|
-
else if (isFunction(spacing)) {
|
|
230
|
+
else if ((0, util_1.isFunction)(spacing)) {
|
|
247
231
|
spacingFunc = spacing;
|
|
248
232
|
}
|
|
249
233
|
else {
|
|
250
|
-
spacingFunc =
|
|
234
|
+
spacingFunc = () => 0;
|
|
251
235
|
}
|
|
252
236
|
formattedOptions.spacing = spacingFunc;
|
|
253
237
|
// nodeSize to function
|
|
254
238
|
if (!nodeSize) {
|
|
255
|
-
nodeSizeFunc =
|
|
256
|
-
|
|
239
|
+
nodeSizeFunc = (d) => {
|
|
240
|
+
const spacing = spacingFunc(d);
|
|
257
241
|
if (d.size) {
|
|
258
|
-
if (isArray(d.size)) {
|
|
259
|
-
|
|
242
|
+
if ((0, util_2.isArray)(d.size)) {
|
|
243
|
+
const res = d.size[0] > d.size[1] ? d.size[0] : d.size[1];
|
|
260
244
|
return (res + spacing) / 2;
|
|
261
245
|
}
|
|
262
|
-
if (isObject(d.size)) {
|
|
263
|
-
|
|
246
|
+
if ((0, util_1.isObject)(d.size)) {
|
|
247
|
+
const res = d.size.width > d.size.height ? d.size.width : d.size.height;
|
|
264
248
|
return (res + spacing) / 2;
|
|
265
249
|
}
|
|
266
250
|
return (d.size + spacing) / 2;
|
|
@@ -268,67 +252,66 @@ var ComboCombinedLayout = /** @class */ (function () {
|
|
|
268
252
|
return 32 + spacing / 2;
|
|
269
253
|
};
|
|
270
254
|
}
|
|
271
|
-
else if (isFunction(nodeSize)) {
|
|
272
|
-
nodeSizeFunc =
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (isArray(d.size)) {
|
|
276
|
-
|
|
255
|
+
else if ((0, util_1.isFunction)(nodeSize)) {
|
|
256
|
+
nodeSizeFunc = (d) => {
|
|
257
|
+
const size = nodeSize(d);
|
|
258
|
+
const spacing = spacingFunc(d);
|
|
259
|
+
if ((0, util_2.isArray)(d.size)) {
|
|
260
|
+
const res = d.size[0] > d.size[1] ? d.size[0] : d.size[1];
|
|
277
261
|
return (res + spacing) / 2;
|
|
278
262
|
}
|
|
279
263
|
return ((size || 32) + spacing) / 2;
|
|
280
264
|
};
|
|
281
265
|
}
|
|
282
|
-
else if (isArray(nodeSize)) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
nodeSizeFunc =
|
|
266
|
+
else if ((0, util_2.isArray)(nodeSize)) {
|
|
267
|
+
const larger = nodeSize[0] > nodeSize[1] ? nodeSize[0] : nodeSize[1];
|
|
268
|
+
const radius = larger / 2;
|
|
269
|
+
nodeSizeFunc = (d) => radius + spacingFunc(d) / 2;
|
|
286
270
|
}
|
|
287
271
|
else {
|
|
288
272
|
// number type
|
|
289
|
-
|
|
290
|
-
nodeSizeFunc =
|
|
273
|
+
const radius = nodeSize / 2;
|
|
274
|
+
nodeSizeFunc = (d) => radius + spacingFunc(d) / 2;
|
|
291
275
|
}
|
|
292
276
|
formattedOptions.nodeSize = nodeSizeFunc;
|
|
293
277
|
// comboPadding to function
|
|
294
|
-
|
|
295
|
-
if (isNumber(comboPadding)) {
|
|
296
|
-
comboPaddingFunc =
|
|
278
|
+
let comboPaddingFunc;
|
|
279
|
+
if ((0, util_1.isNumber)(comboPadding)) {
|
|
280
|
+
comboPaddingFunc = () => comboPadding;
|
|
297
281
|
}
|
|
298
|
-
else if (isArray(comboPadding)) {
|
|
299
|
-
comboPaddingFunc =
|
|
282
|
+
else if ((0, util_2.isArray)(comboPadding)) {
|
|
283
|
+
comboPaddingFunc = () => Math.max.apply(null, comboPadding);
|
|
300
284
|
}
|
|
301
|
-
else if (isFunction(comboPadding)) {
|
|
285
|
+
else if ((0, util_1.isFunction)(comboPadding)) {
|
|
302
286
|
comboPaddingFunc = comboPadding;
|
|
303
287
|
}
|
|
304
288
|
else {
|
|
305
289
|
// null type
|
|
306
|
-
comboPaddingFunc =
|
|
290
|
+
comboPaddingFunc = () => 0;
|
|
307
291
|
}
|
|
308
292
|
formattedOptions.comboPadding = comboPaddingFunc;
|
|
309
293
|
return formattedOptions;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
var innerLayoutOptions = {
|
|
294
|
+
}
|
|
295
|
+
getInnerGraphs(graph, treeKey, nodeMap, comboMap, edges, options, comboNodes) {
|
|
296
|
+
const { nodeSize, comboPadding, spacing, innerLayout } = options;
|
|
297
|
+
const innerGraphLayout = innerLayout || new concentric_1.ConcentricLayout({});
|
|
298
|
+
const innerLayoutOptions = {
|
|
316
299
|
center: [0, 0],
|
|
317
300
|
preventOverlap: true,
|
|
318
301
|
nodeSpacing: spacing,
|
|
319
302
|
};
|
|
320
|
-
|
|
321
|
-
|
|
303
|
+
const innerLayoutPromises = [];
|
|
304
|
+
const getSize = (node) => {
|
|
322
305
|
// @ts-ignore
|
|
323
|
-
|
|
324
|
-
if (isArray(padding))
|
|
325
|
-
padding = Math.max
|
|
306
|
+
let padding = (comboPadding === null || comboPadding === void 0 ? void 0 : comboPadding(node)) || 10;
|
|
307
|
+
if ((0, util_2.isArray)(padding))
|
|
308
|
+
padding = Math.max(...padding);
|
|
326
309
|
return {
|
|
327
310
|
size: padding ? [padding * 2, padding * 2] : [30, 30],
|
|
328
|
-
padding
|
|
311
|
+
padding,
|
|
329
312
|
};
|
|
330
313
|
};
|
|
331
|
-
graph.getRoots(treeKey).forEach(
|
|
314
|
+
graph.getRoots(treeKey).forEach((root) => {
|
|
332
315
|
// @ts-ignore
|
|
333
316
|
comboNodes.set(root.id, {
|
|
334
317
|
id: root.id,
|
|
@@ -337,105 +320,96 @@ var ComboCombinedLayout = /** @class */ (function () {
|
|
|
337
320
|
size: getSize(root).size,
|
|
338
321
|
},
|
|
339
322
|
});
|
|
340
|
-
|
|
323
|
+
let start = Promise.resolve();
|
|
341
324
|
// Regard the child nodes in one combo as a graph, and layout them from bottom to top
|
|
342
|
-
graphTreeDfs(graph, [root],
|
|
325
|
+
(0, util_2.graphTreeDfs)(graph, [root], (treeNode) => {
|
|
343
326
|
var _a;
|
|
344
327
|
if (!treeNode.data._isCombo)
|
|
345
328
|
return;
|
|
346
|
-
|
|
329
|
+
const { size: nsize, padding } = getSize(treeNode);
|
|
347
330
|
if (!((_a = graph.getChildren(treeNode.id, treeKey)) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
348
331
|
// empty combo
|
|
349
332
|
comboNodes.set(treeNode.id, {
|
|
350
333
|
id: treeNode.id,
|
|
351
|
-
data:
|
|
334
|
+
data: Object.assign(Object.assign({}, treeNode.data), { size: nsize }),
|
|
352
335
|
});
|
|
353
336
|
}
|
|
354
337
|
else {
|
|
355
338
|
// combo not empty
|
|
356
|
-
|
|
339
|
+
const comboNode = comboNodes.get(treeNode.id);
|
|
357
340
|
comboNodes.set(treeNode.id, {
|
|
358
341
|
id: treeNode.id,
|
|
359
|
-
data:
|
|
342
|
+
data: Object.assign({ nodes: [] }, comboNode === null || comboNode === void 0 ? void 0 : comboNode.data),
|
|
360
343
|
});
|
|
361
|
-
|
|
362
|
-
|
|
344
|
+
const innerLayoutNodeIds = new Map();
|
|
345
|
+
const innerLayoutNodes = graph
|
|
363
346
|
.getChildren(treeNode.id, treeKey)
|
|
364
|
-
.map(
|
|
347
|
+
.map((child) => {
|
|
365
348
|
if (child.data._isCombo) {
|
|
366
|
-
if (!comboNodes.has(child.id))
|
|
349
|
+
if (!comboNodes.has(child.id)) {
|
|
367
350
|
comboNodes.set(child.id, {
|
|
368
351
|
id: child.id,
|
|
369
|
-
data:
|
|
352
|
+
data: Object.assign({}, child.data),
|
|
370
353
|
});
|
|
371
|
-
|
|
354
|
+
}
|
|
355
|
+
innerLayoutNodeIds.set(child.id, true);
|
|
372
356
|
return comboNodes.get(child.id);
|
|
373
357
|
}
|
|
374
|
-
|
|
375
|
-
|
|
358
|
+
const oriNode = nodeMap.get(child.id) || comboMap.get(child.id);
|
|
359
|
+
innerLayoutNodeIds.set(child.id, true);
|
|
376
360
|
return {
|
|
377
361
|
id: child.id,
|
|
378
|
-
data:
|
|
362
|
+
data: Object.assign(Object.assign({}, oriNode.data), child.data),
|
|
379
363
|
};
|
|
380
364
|
});
|
|
381
|
-
|
|
382
|
-
nodes:
|
|
383
|
-
edges: edges.filter(
|
|
384
|
-
|
|
385
|
-
innerLayoutNodeIds_1.has(edge.target);
|
|
386
|
-
}),
|
|
365
|
+
const innerGraphData = {
|
|
366
|
+
nodes: innerLayoutNodes,
|
|
367
|
+
edges: edges.filter((edge) => innerLayoutNodeIds.has(edge.source) &&
|
|
368
|
+
innerLayoutNodeIds.has(edge.target)),
|
|
387
369
|
};
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
var _a
|
|
391
|
-
|
|
370
|
+
let minNodeSize = Infinity;
|
|
371
|
+
innerLayoutNodes.forEach((node) => {
|
|
372
|
+
var _a;
|
|
373
|
+
let { size } = node.data;
|
|
392
374
|
if (!size) {
|
|
393
375
|
size = ((_a = comboNodes.get(node.id)) === null || _a === void 0 ? void 0 : _a.data.size) ||
|
|
394
|
-
(
|
|
376
|
+
(nodeSize === null || nodeSize === void 0 ? void 0 : nodeSize(node)) || [30, 30];
|
|
395
377
|
}
|
|
396
|
-
if (isNumber(size))
|
|
378
|
+
if ((0, util_1.isNumber)(size))
|
|
397
379
|
size = [size, size];
|
|
398
|
-
|
|
399
|
-
if (
|
|
400
|
-
|
|
401
|
-
if (
|
|
402
|
-
|
|
380
|
+
const [size0, size1] = size;
|
|
381
|
+
if (minNodeSize > size0)
|
|
382
|
+
minNodeSize = size0;
|
|
383
|
+
if (minNodeSize > size1)
|
|
384
|
+
minNodeSize = size1;
|
|
403
385
|
node.data.size = size;
|
|
404
386
|
});
|
|
405
387
|
// innerGraphLayout.assign(innerGraphCore, innerLayoutOptions);
|
|
406
|
-
start = start.then(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
_a = getLayoutBBox(innerLayoutNodes_1), minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
|
|
416
|
-
center = { x: (maxX + minX) / 2, y: (maxY + minY) / 2 };
|
|
417
|
-
innerGraphData_1.nodes.forEach(function (node) {
|
|
418
|
-
node.data.x -= center.x;
|
|
419
|
-
node.data.y -= center.y;
|
|
420
|
-
});
|
|
421
|
-
size = [
|
|
422
|
-
Math.max(maxX - minX, minNodeSize_1) + padding * 2,
|
|
423
|
-
Math.max(maxY - minY, minNodeSize_1) + padding * 2,
|
|
424
|
-
];
|
|
425
|
-
comboNodes.get(treeNode.id).data.size = size;
|
|
426
|
-
comboNodes.get(treeNode.id).data.nodes = innerLayoutNodes_1;
|
|
427
|
-
return [2 /*return*/, innerLayout];
|
|
428
|
-
}
|
|
388
|
+
start = start.then(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
389
|
+
const innerGraphCore = new graphlib_1.Graph(innerGraphData);
|
|
390
|
+
const innerLayout = yield innerGraphLayout.assign(innerGraphCore, innerLayoutOptions);
|
|
391
|
+
const { minX, minY, maxX, maxY } = (0, util_2.getLayoutBBox)(innerLayoutNodes);
|
|
392
|
+
// move the innerGraph to [0, 0], for later controled by parent layout
|
|
393
|
+
const center = { x: (maxX + minX) / 2, y: (maxY + minY) / 2 };
|
|
394
|
+
innerGraphData.nodes.forEach((node) => {
|
|
395
|
+
node.data.x -= center.x;
|
|
396
|
+
node.data.y -= center.y;
|
|
429
397
|
});
|
|
430
|
-
|
|
398
|
+
const size = [
|
|
399
|
+
Math.max(maxX - minX, minNodeSize) + padding * 2,
|
|
400
|
+
Math.max(maxY - minY, minNodeSize) + padding * 2,
|
|
401
|
+
];
|
|
402
|
+
comboNodes.get(treeNode.id).data.size = size;
|
|
403
|
+
comboNodes.get(treeNode.id).data.nodes = innerLayoutNodes;
|
|
404
|
+
return innerLayout;
|
|
405
|
+
}));
|
|
431
406
|
}
|
|
432
407
|
return true;
|
|
433
408
|
}, 'BT', treeKey);
|
|
434
409
|
innerLayoutPromises.push(start);
|
|
435
410
|
});
|
|
436
411
|
return innerLayoutPromises;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
export { ComboCombinedLayout };
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
exports.ComboCombinedLayout = ComboCombinedLayout;
|
|
441
415
|
//# sourceMappingURL=comboCombined.js.map
|