Skip to content
maxkfranz edited this page May 1, 2012 · 5 revisions

Layout specification

Prototype

layout( options )

Constructor to initialise the layout
options : The layout options to initialise with

  • Automatically populated by the core
  • options.cy : A reference to the core
  • options.renderer : A reference to the renderer
  • options.name : The name of the layout
  • Customary options
  • options.ready : Customarily a callback function triggered when the layout fires layoutready
  • options.stop : Customarily a callback function triggered when the layout fires layoutstop
  • options.fit : Customary option to fit the viewport to the graph (given that the layout may move nodes outside of the current viewport)

layout.run()

Runs the layout; layoutready and layoutstop events should be triggered at the relevant times

layout.stop()

Stops the layout if it's currently running (used for layouts that have live updating of node positions)

Details

A layout must trigger the layoutready event on the core when each node has been assigned a position by the layout. When the layout has finished or is otherwise stopped, it must trigger the layoutstop event on the core. This facilitates layouts that run continuously.

Example

See the random layout.

Clone this wiki locally