-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The spacing argument is for extra space between siblings or the tree-levels ? #12
Comments
This was a mistake. The originally computed layout does not take ein account the Re-computing of the X/Y values in a loop afterwards. Doing this led to overlapping nodes of distant some sub-trees with many children on one level. |
Another approach: add the tree-level spacing in the nodeSize function |
@karlitos |
I got it working. |
Just want to turn @sanket03 's comment into code for future travelers: const tree = {size:[100,100],children:[{size:[100,100]},{size:[100,100]}]};
const horisontalSpacing = 100;
const verticalSpacing = 100;
const layout = d3Flextree.flextree().spacing((nodeA, nodeB) => nodeA.path(nodeB).length + horisontalSpacing);
const flexyTree = layout.hierarchy(tree); // Prepare our tree
layout(flexyTree); // Call the D3 Flextree layout to add X/Y coords to our tree
flexyTree.each((node) => {
node.y += node.depth * verticalSpacing;
}); |
Hello,
I am trying to implement an "horizontal" flextree layout. So far so good, after I switched some x and y coordinates. I would like to add some extra separation between the parent nodes and the children nodes. So I introduced the spacing parameter. It looks to me, that this adds only spacing between the siblings, not between the tree levels.
This is how my chart looks like with spacing 0.
This is how my chart looks like with spacing 50.
In the flextree example it looks like the spacing is only between the "sibling" nodes. How can I achieve extra tree-level spacing without introducing some opaque container workaround ?
The text was updated successfully, but these errors were encountered: