SpringLayout Class
Remarks See Also

Implements the Spring-Embedder graph layout algorithm.

Namespace: MindFusion.Graphs
Package: SpringLayout.js


JavaScript  Copy Code

// class
SpringLayout.prototype = {}


To apply this layout to a diagram, create a SpringLayout instance, set its members and invoke the arrange method of the Diagram class. The method lays out all subgraphs in the diagram.

Spring-Embedder produces layouts having uniform distribution of nodes by simulating a physical system in which nodes repulse each other and the links between them act as confining springs. Nodes are moved around in an iterative process. The forces that act on a node are calculated, taking in account the positions of surrounding nodes and links from the previous iteration.

The final appearance of arranged graphs depends on the nodeDistance value that specifies how nodes are distributed by the layout routine. The layout routine runs as much iterations as set in iterations, calculating better node positions at each step.


The following example applies a SpringLayout to a diagram:

JavaScript  Copy Code
var layout = new MindFusion.Graphs.SpringLayout();
layout.iterations = 100;

 Inheritance Hierarchy


 See Also