This is a force-directed layout that models edges as springs. Wikipedia has a good introduction to these types of layouts.
This layout is useful for unstructured data - database schemas, mind maps, graphs, etc. Force-directed algorithms initially position nodes with a degree of randomness and so do not ever produce exactly the same result twice (try reloading this page); for this reason it is recommended that you read the note on refresh vs re-layout, and also familiarise yourself with the UI state features provided by the Surface component.
- padding Optional [ x, y ] array of values to use as the padding between elements. Defaults to [50, 50], which is taken to mean 50 pixels around each individual Node.
- magnetize Optional parameters for the magnetizer.
- absoluteBacked By default this is set to true. See below for a discussion of this.
SpringLayout extends AbsoluteLayout, which means that, by default, the layout will defer to absolute node positions that are stored in the backing data for each node. This is a very useful feature for the majority of applications: you do not typically want the layout to run if a human being has already taken a look at the data and perhaps moved things around to be more to their liking.
The default parameters used by
top. So for instance you might have these nodes in your data:
By default, the Spring layout will honour these values if they are present, rather than processing the nodes.
If you do not wish to use
top, you can provide your own
locationFunction. This is discussed in the documentation for the Absolute layout.
You can switch off Absolute backing via the
A relayout will generate a brand new arrangement of Nodes, due to the fact that Nodes are placed randomly initially.
A refresh of the layout locks the positions of any nodes that were positioned in a previous run of the layout, and these nodes do not move: only nodes that have not yet been positioned by the layout algorithm will move.
This layout switches on magnetization by default. You can suppress this behaviour by setting
magnetize:false on your layout parameters:
By default, when the magnetizer runs it runs through 10 iterations. For some datasets this may not be enough (in particular for large datasets). In that case you can specify how many iterations you'd like the magnetizer to run for: