Skip to content

cy.center(eles?)

cy.center — Core > Viewport manipulation > Pan, zoom, fit and bounds. Cytoscape.js signatures, parameters and return contract.

cy.center — Core › Viewport manipulation › Pan, zoom, fit and bounds

Preview · Core › Viewport manipulation › Pan, zoom, fit and bounds

Read in the complete API reference · All API members

// Pan so the given elements are centred, leaving the zoom alone
cy.center(eles?: Collection): this

Pan so the given elements are centred, leaving the zoom alone. Bounds include labels, as in fit().

Parameters
NameDescription
eles: Collection?

the elements to centre on; omit for the whole graph

Returns this

this core, for chaining

Example

cy.center(cy.nodes());
console.log(Number.isFinite(cy.pan().x)); // true

Example graph and handle setup

Also spelled cy.centre.