Skip to content

Edge points

Read rendered or model-space endpoints and route geometry.

#ele.midpoint()

// Midpoint of the edge: the curve/route midpoint for curved edges , the endpoint-center average for straight ones
ele.midpoint(): Position | undefined

Midpoint of the edge: the curve/route midpoint for curved edges , the endpoint-center average for straight ones.

Returns Position | undefined

the point a mid-label and a mid-arrow anchor at, in model space; undefined for non-edges. Mid-tween it inherits the position lease's staleness, like the endpoints it derives from

Example

const point = cy.getElementById('ab').midpoint();
console.log(Number.isFinite(point.x)); // true

Example graph and handle setup

#ele.renderedMidpoint()

// midpoint() in rendered (CSS px) space
ele.renderedMidpoint(): Position | undefined

midpoint() in rendered (CSS px) space.

Returns Position | undefined

the rendered midpoint, or undefined for non-edges

Example

const point = cy.getElementById('ab').renderedMidpoint();
console.log(Number.isFinite(point.x)); // true

Example graph and handle setup

#ele.sourceEndpoint()

// Get the first edge's source arrow position in model coordinates
ele.sourceEndpoint(): Position | undefined

Get the first edge's source arrow position in model coordinates. Straight edges meet the source node's boundary with the arrowhead's spacing applied. The line can end farther back to leave room for a hollow arrowhead.

Curved routes return the corresponding point along their computed geometry. Returns undefined when the first element is not an edge.

Returns Position | undefined

the endpoint, or undefined for non-edges

Example

const point = cy.getElementById('ab').sourceEndpoint();
console.log(Number.isFinite(point.x)); // true

Example graph and handle setup

#ele.targetEndpoint()

// Get the first edge's target arrow position in model coordinates
ele.targetEndpoint(): Position | undefined

Get the first edge's target arrow position in model coordinates. Straight edges meet the target node's boundary with the arrowhead's spacing applied. The line can end farther back to leave room for a hollow arrowhead.

Curved routes return the corresponding point along their computed geometry. Returns undefined when the first element is not an edge.

Returns Position | undefined

the endpoint, or undefined for non-edges

Example

const point = cy.getElementById('ab').targetEndpoint();
console.log(Number.isFinite(point.x)); // true

Example graph and handle setup

#ele.renderedSourceEndpoint()

// sourceEndpoint() in rendered (CSS px) space
ele.renderedSourceEndpoint(): Position | undefined

sourceEndpoint() in rendered (CSS px) space.

Returns Position | undefined

the rendered endpoint, or undefined for non-edges

Example

const point = cy.getElementById('ab').renderedSourceEndpoint();
console.log(Number.isFinite(point.x)); // true

Example graph and handle setup

#ele.renderedTargetEndpoint()

// targetEndpoint() in rendered (CSS px) space
ele.renderedTargetEndpoint(): Position | undefined

targetEndpoint() in rendered (CSS px) space.

Returns Position | undefined

the rendered endpoint, or undefined for non-edges

Example

const point = cy.getElementById('ab').renderedTargetEndpoint();
console.log(Number.isFinite(point.x)); // true

Example graph and handle setup

#ele.controlPoints()

// The edge's curve control points (model coords): one for a bundled bezier, two for a self-loop, the control list for an unbundled bezier, undefined otherwise (segments/taxi answer segmentPoints() instead)
ele.controlPoints(): Position[] | undefined

The edge's curve control points (model coords): one for a bundled bezier, two for a self-loop, the control list for an unbundled bezier, undefined otherwise (segments/taxi answer segmentPoints() instead).

Returns Position[] | undefined

the control points in model space, or undefined when the edge has none — which covers straight edges, segments/taxi routes, and a straight edge carrying manual endpoints (the 12c n = 0 chord)

Example

// Straight edges have no intermediate control points.
console.log(cy.getElementById('ab').controlPoints()); // undefined

Example graph and handle setup

#ele.renderedControlPoints()

// controlPoints() in rendered (CSS px) space
ele.renderedControlPoints(): Position[] | undefined

controlPoints() in rendered (CSS px) space.

Returns Position[] | undefined

the rendered control points, or undefined when the edge has none

Example

// Straight edges have no intermediate control points.
console.log(cy.getElementById('ab').renderedControlPoints()); // undefined

Example graph and handle setup

#ele.segmentPoints()

// The edge's segment points (model coords): defined for segments and taxi edges (taxi derives its points), undefined otherwise
ele.segmentPoints(): Position[] | undefined

The edge's segment points (model coords): defined for segments and taxi edges (taxi derives its points), undefined otherwise.

Returns Position[] | undefined

the interior route points in model space — derived ones for taxi, which computes rather than declares them — or undefined for every other family

Example

// Straight edges have no intermediate segment points.
console.log(cy.getElementById('ab').segmentPoints()); // undefined

Example graph and handle setup

#ele.renderedSegmentPoints()

// segmentPoints() in rendered (CSS px) space
ele.renderedSegmentPoints(): Position[] | undefined

segmentPoints() in rendered (CSS px) space.

Returns Position[] | undefined

the rendered segment points, or undefined when the edge has none

Example

// Straight edges have no intermediate segment points.
console.log(cy.getElementById('ab').renderedSegmentPoints()); // undefined

Example graph and handle setup

All guides · Alphabetical API index · Read continuously