vasturiano / force-graph

Force-directed graph rendered on HTML5 canvas
https://vasturiano.github.io/force-graph/example/directional-links-particles/
MIT License
1.6k stars 248 forks source link

children of node are not put in front of parent #105

Open maximegheraille opened 4 years ago

maximegheraille commented 4 years ago

Describe the bug Some children node's are not correctly grouped with each other.

To Reproduce Steps to reproduce the behavior: https://codesandbox.io/s/dazzling-hermann-vyuyb?fontsize=14&hidenavigation=1&theme=dark

Expected behavior The children 26 and 29 should be in front of their parent. Child 28 should also not be that far away and should be next to 26. Number 8 should be in front of his parent number 2

is there a way to control that behaviour ? because it is makes the graph a lot more complex to look at and use

Screenshots If applicable, add screenshots to help explain your problem.

Screenshot 2020-03-09 at 09 55 41

Desktop (please complete the following information):

vasturiano commented 4 years ago

@maximegheraille you can set starting positions on the nodes if you want to help the layout. You just need to add x, y attributes to the nodes objects you'd like to pre-set. Otherwise the force engine will assign sequential positions in a phylotaxis arrangement, which is why it may end up with line crossings after unfolding.

maximegheraille commented 4 years ago

@vasturiano that is the problem I don't actually want to use x, y attributes. I was hoping it was possible to change the behavior without the attributes but i guess ovoiding overlapping links is not possible without using those attributes?

jrmartin commented 3 years ago

Hello @maximegheraille , did you manage to fix this issue? Playing with d3-forces to removes these links overlaps is giving me a headache, wondering if I can avoid having to set the x,y positions myself.

maximegheraille commented 3 years ago

@jrmartin Hi, I haven't worked with this in a long time, but I remember that I had to manually save all nodes positions before closing them and reuse them when they open again.