graph scrolls left after loading multiple nodes. #108
-
Describe the bug To Reproduce Expected behavior Desktop (please complete the following information):
I'm not sure if this is a bug or I'm doing it the wrong way |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I believe this is an interesting question in general so I converted it to a discussion again for others to discover 🙂 This behaviour is caused by the collision and repelling forces between the nodes. Especially in the beginning stages when all nodes are generated at the same default coordinates (0, 0) this can often result in a rather uncontrolled "explosion" of the graph which can also cause a shift in random directions. This setup is very volatile an slight changes to the start configuration can have large effects on the movements of all nodes. In cases like yours where you wish to have a rather finite control of the outcome, there are a few strategies you can consider.
A few more things you could experiment with: One more thing that might get handy is the simulation.moveTo({
nodes: graph.nodes,
}); |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply and great explanation, Tbh, I'm really new to the d3; I have to learn much more to be able to use it. Thanks to your library, it's much easier to create things. |
Beta Was this translation helpful? Give feedback.
I believe this is an interesting question in general so I converted it to a discussion again for others to discover 🙂
This behaviour is caused by the collision and repelling forces between the nodes. Especially in the beginning stages when all nodes are generated at the same default coordinates (0, 0) this can often result in a rather uncontrolled "explosion" of the graph which can also cause a shift in random directions. This setup is very volatile an slight changes to the start configuration can have large effects on the movements of all nodes.
In cases like yours where you wish to have a rather finite control of the outcome, there are a few strategies you can consider.