vasturiano / force-graph

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

question simple function ! #269

Open NoviceInWeb opened 2 years ago

NoviceInWeb commented 2 years ago

Hi, @vasturiano

I am using 'force-graph' very well. thank you.

I have a question.

After nodes and edges are drawing, the node was dragged or the position was moved. then, I want initialize the coordinates nodes position.

same node information and the same edge information, I want to initialize only the coordinate calculation. Is there a function provided to initialize the coordinates?

or do I put data again like when i first made it??

thank you.🤷‍♂️

vasturiano commented 2 years ago

@NoviceInWeb thanks for reaching out.

You can simply add x and y attributes to each of your nodes. This will tell the force simulation to use those coordinates as starting points for the nodes.

See more at: https://github.com/d3/d3-force#simulation_nodes

NoviceInWeb commented 2 years ago

@NoviceInWeb thanks for reaching out.

thank you . have a nice day !