Skip to content

Metadata and environment

Inspect core configuration, environment and graph metadata.

#cy.headless()

// Whether this instance has no container and therefore no GPU — the Node-testable mode, in which every model API works and the render, pick and image-export paths are no-ops or reject
cy.headless(): boolean

Whether this instance has no container and therefore no GPU — the Node-testable mode, in which every model API works and the render, pick and image-export paths are no-ops or reject.

Returns boolean

true when running headless

Example

console.log(cy.headless()); // true

Example graph and handle setup

#cy.styleEnabled()

// Check whether style is enabled
cy.styleEnabled(): boolean

Always true: there is no style-disabled mode, since the columnar model derives geometry from stored style channels rather than treating style as an optional layer. Use this to inspect the instance's style capability.

Returns boolean

true

Example

console.log(cy.styleEnabled()); // true

Example graph and handle setup

#cy.hasCompoundNodes()

// Whether any node currently has a parent
cy.hasCompoundNodes(): boolean

Whether any node currently has a parent. Worth checking because the compound tier changes paint evaluation and draw order; the renderer pays nothing for compounds while this is false.

Returns boolean

true when the graph has at least one parent/child relation

Example

console.log(cy.hasCompoundNodes()); // false

Example graph and handle setup

#cy.hasElementWithId(id)

// Whether an element with this id exists, via the O(1) id index — cheaper than getElementById( id).nonempty() because no handle is materialized
cy.hasElementWithId(id: string): boolean

Whether an element with this id exists, via the O(1) id index — cheaper than getElementById( id).nonempty() because no handle is materialized.

Parameters
NameDescription
id: string

the element id

Returns boolean

true when the graph holds that element

Example

console.log(cy.hasElementWithId('a')); // true

Example graph and handle setup

#cy.window()

// The window this instance renders into, or null when there is no DOM (Node)
cy.window(): (Window & typeof globalThis) | null

The window this instance renders into, or null when there is no DOM (Node). Useful for extensions that need the hosting realm.

Returns (Window & typeof globalThis) | null

the global window, or null outside a browser

Example

console.log(cy.window()); // null

Example graph and handle setup

#cy.options()

// The options the instance was constructed with
cy.options(): CytoscapeOptions<NodeData, EdgeData>

The options the instance was constructed with.

Returns CytoscapeOptions<NodeData, EdgeData>

the caller's own options object, held by reference — not a copy and not a defaults-resolved view, so an option the caller omitted reads back absent rather than as the default in force

Example

console.log(cy.options().headless); // true

Example graph and handle setup

All guides · Alphabetical API index · Read continuously