Skip to content

layout.run()

layout.run — Layouts > Layout handle. Cytoscape.js signatures, parameters and return contract.

layout.run — Layouts › Layout handle

Preview · Layouts › Layout handle

Read in the complete API reference · All API members

// Start the layout
layout.run(): this

Start the layout. Emits a layoutstart event on the core, calls impl.run( ctx) and awaits it if it returns a promise (the shape a GPU-resident layout needs).

The lifecycle fires exactly once per run either way: an impl that finishes through ctx.layoutPositions() lets the finisher emit a layoutready event/layoutstop, and one that writes positions directly has them emitted here instead.

Returns this

this layout, for chaining; await promise() for completion

Example

layout.run();
await layout.promise();
console.log(cy.nodes().length); // 3

Example graph and handle setup