@neo4j-nvl/layout-workers 0.3.5-f46f9cc3 → 0.3.6-ade05d13
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.
|
@@ -70,14 +70,6 @@ const createGraph = (pixelRatio) => {
|
|
|
70
70
|
g.graph().ranksep = 75 * pixelRatio;
|
|
71
71
|
return g;
|
|
72
72
|
};
|
|
73
|
-
const findParent = (id, layoutGraph) => {
|
|
74
|
-
// predecessors uses inEdges, successors uses outEdges
|
|
75
|
-
let pId = findParentForEdges(id, layoutGraph.predecessors(id), layoutGraph);
|
|
76
|
-
if (pId === null) {
|
|
77
|
-
pId = findParentForEdges(id, layoutGraph.successors(id), layoutGraph);
|
|
78
|
-
}
|
|
79
|
-
return pId;
|
|
80
|
-
};
|
|
81
73
|
const findParentForEdges = (id, connectedNodes, layoutGraph) => {
|
|
82
74
|
const { rank: currentRank } = layoutGraph.node(id);
|
|
83
75
|
let pRank = null;
|
|
@@ -99,6 +91,14 @@ const findParentForEdges = (id, connectedNodes, layoutGraph) => {
|
|
|
99
91
|
}
|
|
100
92
|
return pId;
|
|
101
93
|
};
|
|
94
|
+
const findParent = (id, layoutGraph) => {
|
|
95
|
+
// predecessors uses inEdges, successors uses outEdges
|
|
96
|
+
let pId = findParentForEdges(id, layoutGraph.predecessors(id), layoutGraph);
|
|
97
|
+
if (pId === null) {
|
|
98
|
+
pId = findParentForEdges(id, layoutGraph.successors(id), layoutGraph);
|
|
99
|
+
}
|
|
100
|
+
return pId;
|
|
101
|
+
};
|
|
102
102
|
const getConnectedSubGraphs = (g, pixelRatio) => {
|
|
103
103
|
const subGraphs = [];
|
|
104
104
|
const components = graphlib.alg.components(g);
|
|
@@ -126,9 +126,9 @@ const getConnectedSubGraphs = (g, pixelRatio) => {
|
|
|
126
126
|
const layoutGraph = (g, direction, parents) => {
|
|
127
127
|
g.graph().ranker = Ranker;
|
|
128
128
|
g.graph().rankdir = Directions[direction];
|
|
129
|
-
const
|
|
130
|
-
for (const id of
|
|
131
|
-
const pId = findParent(id,
|
|
129
|
+
const dagreLayoutGraph = dagre.layout(g);
|
|
130
|
+
for (const id of dagreLayoutGraph.nodes()) {
|
|
131
|
+
const pId = findParent(id, dagreLayoutGraph);
|
|
132
132
|
if (pId !== null) {
|
|
133
133
|
parents[id] = pId;
|
|
134
134
|
}
|
|
@@ -189,8 +189,8 @@ export const layout = (nodes, nodeIds, idToPosition, rels, direction, packing, p
|
|
|
189
189
|
subGraphs.forEach((subGraph) => layoutGraph(subGraph, direction, parents));
|
|
190
190
|
const isVertical = isDirectionVertical(direction);
|
|
191
191
|
const isNatural = isDirectionNatural(direction);
|
|
192
|
-
const singleNodeGraphs = subGraphs.filter((
|
|
193
|
-
const multiNodeGraphs = subGraphs.filter((
|
|
192
|
+
const singleNodeGraphs = subGraphs.filter((sg) => sg.nodeCount() === 1);
|
|
193
|
+
const multiNodeGraphs = subGraphs.filter((sg) => sg.nodeCount() !== 1);
|
|
194
194
|
if (packing === PackingBin) {
|
|
195
195
|
multiNodeGraphs.sort((a, b) => b.nodeCount() - a.nodeCount());
|
|
196
196
|
const adjustDimensionPaddingNormal = ({ width, height, ...rest }) => ({
|
|
@@ -214,10 +214,12 @@ export const layout = (nodes, nodeIds, idToPosition, rels, direction, packing, p
|
|
|
214
214
|
if (!isNatural) {
|
|
215
215
|
const positionProp = isVertical ? 'y' : 'x';
|
|
216
216
|
const extentProp = isVertical ? 'height' : 'width';
|
|
217
|
-
const min = bins.reduce((
|
|
218
|
-
const max = bins.reduce((
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
const min = bins.reduce((minBin, d) => (minBin === null ? d[positionProp] : Math.min(d[positionProp], minBin[extentProp] || 0)), null);
|
|
218
|
+
const max = bins.reduce((maxBin, d) => {
|
|
219
|
+
return maxBin === null
|
|
220
|
+
? d[positionProp] + d[extentProp]
|
|
221
|
+
: Math.max(d[positionProp] + d[extentProp], maxBin[extentProp] || 0);
|
|
222
|
+
}, null);
|
|
221
223
|
bins.forEach((d) => {
|
|
222
224
|
d[positionProp] = min + (max - (d[positionProp] + d[extentProp]));
|
|
223
225
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-nvl/layout-workers",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6-ade05d13",
|
|
4
4
|
"license": "SEE LICENSE IN 'LICENSE.txt'",
|
|
5
5
|
"description": "Layout workers for the Neo4j Visualization Library",
|
|
6
6
|
"keywords": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"watch": "yarn global:tsc -w",
|
|
23
23
|
"prepack": "cp ../../LICENSE.txt ./",
|
|
24
24
|
"postpack": "rm LICENSE.txt",
|
|
25
|
-
"eslint": "yarn global:eslint ./src/ --ext .js,.mjs
|
|
25
|
+
"eslint": "yarn global:eslint ./src/ --ext .js,.mjs"
|
|
26
26
|
},
|
|
27
27
|
"typedoc": {
|
|
28
28
|
"entryPoint": "./src/index.js",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^18.11.11"
|
|
42
42
|
},
|
|
43
|
-
"stableVersion": "0.3.
|
|
43
|
+
"stableVersion": "0.3.6"
|
|
44
44
|
}
|