EdgeLabels

A component that renders edge labels with text that are placed at coordinates that resulted from a yFiles layout algorithm. At a single edge, there can be multiple edge labels which may be rotated.

export function CustomEdge(props: EdgeProps) {
  const [edgePath] = getPolylinePath({
    sourceX: props.sourceX,
    sourceY: props.sourceY,
    targetX: props.targetX,
    targetY: props.targetY,
    bends: props.data?.yData?.bends ?? []
  })

  return (
    <>
      <BaseEdge path={edgePath} {...props} />
      <EdgeLabelRenderer>
        <EdgeLabels
          labels={labels}
          ownerId={props.id}
          labelBoxes={props.data?.yData?.labelBoxes ?? []}
        ></EdgeLabels>
      </EdgeLabelRenderer>
    </>
  )
}

Props

EdgeLabelsProps

NameDescriptionType
className?
An optional CSS class used for styling the label.
string
labelBoxes
The layout information for the labels.
LabelBox[]
labels
The list of labels for the given edge.
(
| Label
| string
| ReactNode
)[]
labelStyle?
An optional CSS style used for the label.
CSSProperties
ownerId
The id of the edge to which the labels belong.
string