VivaGraphJS icon indicating copy to clipboard operation
VivaGraphJS copied to clipboard

Add ability to stop force animation

Open ghost opened this issue 10 years ago • 2 comments
trafficstars

I've modified the webGLRenderer.html example to load my medium-sized graph data. It has 6,026 nodes with 5,885 edges. The webgl graph does a decent job rendering, however once the nodes have settled and it zooms out, some of the nodes are still animating (jiggling). Is there a way to stop this? I can make a video of the effect if need be...

ghost avatar May 21 '15 20:05 ghost

You can pause the layout using renderer.pause()

This node jiggling is because your graph is not actually stable yet. It may never stabilise depending on:

  • how nodes are connected
  • all force-directed layout parameters (in particular stableThreshold and dragCoeff)

Key layout parameters taken from the source with example values:

  • Maximum movement of the system which can be considered as stabilized: stableThreshold: 0.09 // default: 0.009
  • Drag force coefficient. Used to slow down system, thus should be less than 1. The closer it is to 0 the less tight system will be. dragCoeff : 0.04, // default: 0.02
  • Hook's law coefficient. 1 - solid spring: springCoeff : 0.0004, // default: 0.0008
  • Coulomb's law coefficient. It's used to repel nodes thus should be negative if you make it positive nodes start attract each other :) gravity : -1.5, // default: -1.2
  • Ideal length for links (springs in physical model): springLength : 150, // default: 30

In your case if you know the graph will look pretty after a while you could pause the renderer in a timeout function using: renderer.pause();

You can later on resume with renderer.resume()

julbra avatar May 22 '15 12:05 julbra

@julbra :+1:

anvaka avatar May 22 '15 17:05 anvaka