Browse Source

Network: Fix tree collision in hierarchical layout (#2625)

Using the 'directed' sort method, the layout engine seemed to ignore treeSpacing (or only apply it to the first tree). This would also lead to trees colliding with one another, and having their nodes tangled in space. This complaint surfaced in a couple bugs, including #2494. This should be a step toward fixing that. For whatever reason, this code never runs when using the "hubsize" sort method.
runTests
Josh Ventura 7 years ago
committed by yotamberk
parent
commit
3456acffa1
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      lib/network/modules/LayoutEngine.js

+ 4
- 2
lib/network/modules/LayoutEngine.js View File

@ -381,9 +381,11 @@ class LayoutEngine {
// the main method to shift the trees
let shiftTrees = () => {
let treeSizes = getTreeSizes();
let shiftBy = 0;
for (let i = 0; i < treeSizes.length - 1; i++) {
let diff = treeSizes[i].max - treeSizes[i+1].min;
shiftTree(i + 1, diff + this.options.hierarchical.treeSpacing);
shiftBy += diff + this.options.hierarchical.treeSpacing;
shiftTree(i + 1, shiftBy);
}
};
@ -1358,4 +1360,4 @@ class LayoutEngine {
}
export default LayoutEngine;
export default LayoutEngine;

Loading…
Cancel
Save