Skip to content

eles.boundingBox(options?)

eles.boundingBox — Collection > Position and dimensions. Cytoscape.js signatures, parameters and return contract.

eles.boundingBox — Collection › Position and dimensions

Preview · Collection › Position and dimensions

Read in the complete API reference · All API members

// The model-space box enclosing every element of the collection
eles.boundingBox(options?: { includeLabels?: boolean }): { x1: number; y1: number; x2: number; y2: number; w: number; h: number; }

The model-space box enclosing every element of the collection.

Labels are included by default. Node label terms are exact (the laid text block at its anchor plus text-box padding); edge label terms are conservative (a rotation-safe radius about both endpoints), so a box may be slightly larger than the ink but never smaller. The box also covers ghost offsets, overlay/underlay padding and outlines.

Parameters
NameDescription
options: { includeLabels?: boolean }?

{ includeLabels } (default true)

Fields of options
NameDescription
includeLabels: boolean?
Returns { x1: number; y1: number; x2: number; y2: number; w: number; h: number; }

{ x1, y1, x2, y2, w, h } in model coordinates

Example

console.log(cy.nodes().boundingBox().w); // 130

Example graph and handle setup

Throws

on an unknown option key — a typo must not silently change fit semantics

See

Collection#labelBoundingBox for the label box alone