Skip to content

cy.mount(container)

cy.mount — Core > Initialisation and lifecycle. Cytoscape.js signatures, parameters and return contract.

cy.mount — Core › Initialisation and lifecycle

Preview · Core › Initialisation and lifecycle

Read in the complete API reference · All API members

// (Re)attach a renderer to a container
cy.mount(container: HTMLElement): this

(Re)attach a renderer to a container. Re-mounting to a different container unmounts first; the fresh renderer re-uploads every column from the CPU-canonical model and rebuilds all glyph runs.

Parameters
NameDescription
container: HTMLElement

the element to render into

Returns this

this

Example

// container is an existing, sized HTML element.
cy.mount(document.getElementById('graph'));
await cy.ready;

Example graph and handle setup

Throws

if no container is given, if the instance was built directly rather than through the cytoscape factory (there is no renderer to attach), if it was built by cytoscape/headless or cytoscape/headless-gpu (a build with no renderer), or if WebGPU is unavailable — mounting is the one way a headless instance can demand a GPU after construction