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

getStraightPath()

Source on GitHub 

The getStraightPath util returns the SVG path string for a straight edge, along with the label coordinates.

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

Signature

Parameters:
NameTypeDefault
sourceXnumber

The x position of the source handle.

sourceYnumber

The y position of the source handle.

targetXnumber

The x position of the target handle.

targetYnumber

The y position of the target handle.

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.