logo

X6

  • Tutorials
  • API
  • Examples
  • Q&A
  • Change Log
  • XFlow
  • Productsantv logo arrow
  • 2.x
  • Graph
    • Graph
    • Grid
    • Background
    • Panning
    • Mousewheel
    • Viewport Transformation
    • Coordinate Systems
  • Element
    • Cell
    • Node
    • Edge
    • Labels
    • Arrow
    • Element Attributes
    • Interaction
  • MVC
    • Model
    • View
  • Extension
    • Node Tools
    • Edge Tools
    • Routing
    • Connector
    • Node Anchor
    • Edge Anchor
    • Connection Point
    • Port Layout Algorithm
    • Port Label Layout
    • Attributes
    • Highlighter
    • Filter

Edge Anchor

Previous
Node Anchor
Next
Connection Point

Resource

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-Interactive solution
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

When an edge connects to another edge, you can use EdgeAnchor to specify the anchor point on the connected edge. The anchor point, along with the connection point ConnectionPoint, determines the starting and ending points of the edge.

  • Starting point: Draw a reference line from the first path point or the center of the target node (if there are no path points) to the anchor point of the source node, and then calculate the intersection point of the reference line and the graph according to the intersection calculation method specified by connectionPoint. This intersection point is the starting point of the edge.
  • Ending point: Draw a reference line from the last path point or the center of the source node (if there are no path points) to the anchor point of the target node, and then calculate the intersection point of the reference line and the graph according to the intersection calculation method specified by connectionPoint. This intersection point is the ending point of the edge.

X6 provides the following built-in anchor point definitions:

  • ratio The default value, where the anchor point is located at a specified proportion of the connected edge.
  • length The anchor point is located at a specified length from the connected edge.
  • closest Uses the point closest to the reference point as the anchor point.
  • orth Orthogonal anchor point.

Built-in Anchor Points

ratio

The anchor point is located at a specified proportion of the connected edge. Supports the following parameters:

Parameter NameParameter TypeRequiredDefault ValueParameter Description
rationumberNo0.5The proportion of the edge length from the starting point, defaulting to the center of the edge length.

length

The anchor point is located at a specified length from the connected edge. Supports the following parameters:

Parameter NameParameter TypeRequiredDefault ValueParameter Description
lengthnumberNo20The length from the starting point of the edge, defaulting to 20px from the starting point.

closest

Uses the point closest to the reference point as the anchor point.

orth

Orthogonal anchor point. Supports the following parameters:

Parameter NameParameter TypeRequiredDefault ValueParameter Description
fallbackAtnumber | stringNoundefinedWhen there is no orthogonal point, use the point specified by fallbackAt as the anchor point.
When fallbackAt is a percentage string, it represents the proportion of the edge length from the starting point.
When fallbackAt is a number, it represents the length from the starting point of the edge.

Custom Anchor Points

The edge anchor point definition is a function with the following signature, which returns the anchor point.

export type Definition<T> = (
this: EdgeView,
view: EdgeView,
magnet: SVGElement,
ref: Point.PointLike | SVGElement,
args: T,
) => Point
Parameter NameParameter TypeParameter Description
thisEdgeViewThe view of the edge.
viewEdgeViewThe view of the connected edge.
magnetSVGElementThe element of the connected edge.
refPoint.PointLike | SVGElementThe reference point/element.
argsTThe arguments.

After completing the anchor point definition, we register the anchor point:

Graph.registerEdgeAnchor('custom-anchor', ...)

After registration, we can use the anchor point by name:

new Graph({
connecting: {
edgeAnchor: {
name: 'custom-anchor',
},
},
})
Anchor
ratio
50%