Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Commit

Permalink
Network: Fix tree collision in hierarchical layout (#2625)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JoshDreamland authored and yotamberk committed Jan 26, 2017
1 parent 81de568 commit 3456acf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/network/modules/LayoutEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -1358,4 +1360,4 @@ class LayoutEngine {

}

export default LayoutEngine;
export default LayoutEngine;

0 comments on commit 3456acf

Please sign in to comment.