Skip to content

API reference

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

eles.renderedPosition — Collection › Position and dimensions

Preview · Collection › Position and dimensions

Read in the complete API reference · All API members

#ele.renderedPosition()

// Get the position
ele.renderedPosition(): Position | undefined

Read the first element's position in rendered CSS pixels, after applying the graph's zoom and pan.

Returns Position | undefined

the first element's position, or undefined when empty

Example

cy.zoom(1); cy.pan({ x: 0, y: 0 });
console.log(cy.getElementById('a').renderedPosition()); // { x: 0, y: 0 }

Example graph and handle setup

#ele.renderedPosition(dim)

// Get one coordinate
ele.renderedPosition(dim: string): number | undefined

Read one coordinate of the first element.

Parameters
NameDescription
dim: string

the coordinate, 'x' or 'y'

Returns number | undefined

the first element's coordinate, or undefined when empty

Example

cy.zoom(1); cy.pan({ x: 0, y: 0 });
console.log(cy.getElementById('a').renderedPosition('x')); // 0

Example graph and handle setup

#eles.renderedPosition(position)

// Set the position
eles.renderedPosition(position: Position): this

Set the position on every unlocked node.

Parameters
NameDescription
position: Position

the coordinates to write

Fields of position
NameDescription
x: number
y: number
Returns this

this collection, for chaining

Example

const result = eles.renderedPosition({ x: 20, y: 10 });
console.log(result === eles); // true

Example graph and handle setup

#eles.renderedPosition(dim, value)

// Set one coordinate
eles.renderedPosition(dim: string, value: number): this

Set one coordinate on every unlocked node.

Parameters
NameDescription
dim: string

the coordinate, 'x' or 'y'

value: number

the coordinate to write

Returns this

this collection, for chaining

Example

const result = eles.renderedPosition('x', 20);
console.log(result === eles); // true

Example graph and handle setup

Also spelled eles.renderedPoint.