Skip to Content
Vue Flow v2 is here and joins xyflow! Read more here →
ReferenceUtils

getBezierPath()

Source on GitHub 

The getBezierPath util returns the SVG path string for a bezier edge, along with the label coordinates and the edge’s center. Use it inside a custom edge to draw the path.

import { BaseEdge, getBezierPath } from '@xyflow/vue'; const [path, labelX, labelY] = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, });

Signature

Parameters:
NameTypeDefault
sourceXnumber

The x position of the source handle.

sourceYnumber

The y position of the source handle.

sourcePositionPosition

The position of the source handle.

Position.Bottom
targetXnumber

The x position of the target handle.

targetYnumber

The y position of the target handle.

targetPositionPosition

The position of the target handle.

Position.Top
curvaturenumber

The curvature of the bezier edge.

0.25
Returns:
[path: string, labelX: number, labelY: number, offsetX: number, offsetY: number]

A path string you can use in an SVG, the labelX and labelY position (center of path) and offsetX, offsetY between source handle and label.

  • path: the path to use in an SVG <path> element.
  • labelX: the x position you can use to render a label for this edge.
  • labelY: the y position you can use to render a label for this edge.
  • offsetX: the absolute difference between the source x position and the x position of the middle of this path.
  • offsetY: the absolute difference between the source y position and the y position of the middle of this path.