Skip to content

cy.width()

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

cy.width — 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

// The rendered width in CSS px
cy.width(): number

The rendered width in CSS px. Headless instances report the configured headlessWidth (default 800), so viewport maths works without a DOM.

Returns number

the viewport width in CSS px

Example

console.log(cy.width()); // 800

Example graph and handle setup