Skip to content

ctx.nodeDimensions(slots?, options?)

ctx.nodeDimensions — Extensions > Layout context > Columnar reads. Cytoscape.js signatures, parameters and return contract.

ctx.nodeDimensions — Extensions › Layout context › Columnar reads

Preview · Extensions › Layout context › Columnar reads

Read in the complete API reference · All API members

// The layout boxes of the scope's nodes: slot-parallel node-local extents read off the size, border and label columns — the one reading every built-in spaces by
ctx.nodeDimensions(slots?: ArrayLike<number>, options?: DimsOptions): LayoutNodeDims

The layout boxes of the scope's nodes: slot-parallel node-local extents read off the size, border and label columns — the one reading every built-in spaces by. Labels are included when the run's nodeDimensionsIncludeLabels is true (default false), making the box asymmetric when a label hangs below the body; take max( -y1, y2) for a symmetric half. Headless label dimensions are estimates (16.4), exact once a renderer has laid the glyphs.

Parameters
NameDescription
slots: ArrayLike<number>?Default: this.nodeSlots()

the node slots to measure (default nodeSlots())

options: DimsOptions?Default: {}

includeLabels (default: the run's option, itself defaulting to false) and padding (split half per side)

Fields of options
NameDescription
includeLabels: boolean?

union the label box into each node's box (default true here; the layouts pass their nodeDimensionsIncludeLabels, default false)

padding: number?

extra room around every node, split half per side (default 0)

Returns LayoutNodeDims

the boxes, parallel to slots

Example

cy.layout({ impl: { run(ctx) {
console.log(ctx.nodeDimensions().n); // 3
} } }).run();

Example graph and handle setup