vasturiano / react-force-graph

React component for 2D, 3D, VR and AR force directed graphs
https://vasturiano.github.io/react-force-graph/example/large-graph/
MIT License
2.06k stars 266 forks source link

Can we somehow obtain the d3 force engine? #213

Open HansvdLaan opened 3 years ago

HansvdLaan commented 3 years ago

Hey,

Is it possible to somehow access the d3 force engine directly?

The use case is that I want to build a stop button which allows users to stop the layout algorithm manually. For this use case, pauseAnimation() is a bit too much as I do not want to freeze the visualization entirely.

Kind regards,

Hans

vasturiano commented 3 years ago

Hi @HansvdLaan, the engine itself is not directly accessible, but several of its properties are, for instance d3AlphaMin, d3VelocityDecay, d3Force, etc.

For your case, you can simply do .cooldownTicks(0) and it will stop the iteration. Setting the cooldown ticks to the previous (non-zero) value will re-ignite the engine.

HansvdLaan commented 3 years ago

Thanks!