force-graph icon indicating copy to clipboard operation
force-graph copied to clipboard

on Nodedrag other nodes are moving away.

Open sr1k3sh opened this issue 4 years ago • 3 comments

While dragging the node the other nodes that are not related are moving away from each other.

Is it possible to prevent nodes from moving away while dragging nodes?

sr1k3sh avatar Apr 06 '21 08:04 sr1k3sh

Yes, you can set fixed coordinates to the nodes. You can see this example. It shows how to set fixed coordinates to the nodes.

https://github.com/vasturiano/force-graph/blob/master/example/fix-dragged-nodes/index.html

iviv62 avatar Apr 06 '21 09:04 iviv62

it will only set the fixed node on dragend . i want to prevent other nodes from keep moving.

sr1k3sh avatar Apr 06 '21 09:04 sr1k3sh

You can get the nodes with the graphData([data]) function, iterate through all the nodes and set fixed positions as shown in the example. After you have set the coordinates, you can use the same function to load the new data.

iviv62 avatar Apr 06 '21 09:04 iviv62