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

Connection Point

Previous
Edge Anchor
Next
Port Layout Algorithm

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...

The Connection Point and Anchor jointly determine the starting or ending point of an edge.

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

X6 provides the following built-in connection point calculation methods.

  • boundary Default value, intersection with the boundary of the linked shape.
  • bbox Intersection with the bounding box of the linked element.
  • rect Intersection with the rotated rectangular region of the linked element.
  • anchor Use the anchor point as the connection point.

You can specify the connection point when creating an edge:

const edge = graph.addEdge({
source: {
cell: 'source-id',
connectionPoint: {
name: 'boundary',
args: {
sticky: true,
},
},
},
target: {
cell: 'target-id',
connectionPoint: 'boundary', // Simplified writing when there are no parameters
},
})

After creation, you can modify the connection point by calling the edge.setSource and edge.setTarget methods:

edge.setSource({
cell: 'source-id',
connectionPoint: {
name: 'boundary',
args: {
sticky: true,
},
},
})

When creating a canvas, you can set the global default connection point through the connecting option:

new Graph({
connecting: {
connectionPoint: {
name: 'boundary',
args: {
sticky: true,
},
},
},
})

Simplified writing when there are no parameters:

new Graph({
connecting: {
connectionPoint: 'boundary',
},
})

Built-in Connection Points

boundary

Automatically recognize the boundary of the linked shape and calculate the intersection point of the reference line and the anchor point (Anchor). For example, an <ellipse> element will be recognized as an ellipse, and the intersection point of the ellipse and the reference line will be calculated. Elements that cannot be recognized (such as text or <path>) will use the bounding box of the shape as the connection point, which is the same as using 'bbox'.

Supported parameters are as follows:

Parameter NameParameter TypeRequiredDefault ValueParameter Description
offsetnumber | Point.PointLikeNo0Offset of the connection point.
strokedbooleanNotrueWhether to consider the stroke width of the shape.
insideoutbooleanNotrueWhen the reference line is inside the shape and there is no intersection point, whether to extend the reference line to calculate the intersection point, default is true.
extrapolatebooleanNofalseWhen the reference line is outside the shape and there is no intersection point, whether to extend the reference line to calculate the intersection point, default is false. This parameter has higher priority than sticky.
stickybooleanNofalseWhen the reference line is outside the shape and there is no intersection point, whether to use the point on the boundary closest to the reference line as the connection point, default is false.
precisionnumberNo2Precision of intersection point calculation.
selectorstringNoundefinedSelector, used to identify an element, and use the boundary of the element to calculate the intersection point. Default uses the first child element that is not in the <g> element in the node.

anchor

Use the anchor point as the connection point, supporting the following parameters:

Parameter NameParameter TypeRequiredDefault ValueParameter Description
offsetnumber | Point.PointLikeNo0Offset of the connection point.

bbox

Intersection point of the bounding box of the linked element and the reference line, supporting the following parameters:

Parameter NameParameter TypeRequiredDefault ValueParameter Description
offsetnumber | Point.PointLikeNo0Offset of the connection point.
strokedbooleanNofalseWhether to consider the stroke width of the shape.

rect

Intersection point of the rotated rectangular region of the linked element and the reference line, supporting the following parameters:

Parameter NameParameter TypeRequiredDefault ValueParameter Description
offsetnumber | Point.PointLikeNo0Offset of the connection point.
strokedbooleanNofalseWhether to consider the stroke width of the shape.

Custom Connection Points

A connection point definition is a function with the following signature, returning the connection point.

export type Definition<T> = (
line: Line,
view: NodeView,
magnet: SVGElement,
args: T,
) => Point
Parameter NameParameter TypeParameter Description
lineLineReference line.
nodeViewNodeViewView of the connected node.
magnetSVGElementElement on the connected node.
argsTParameters.

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

Graph.registerConnectionPoint('custom-connection-point', ...)

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

new Graph({
connecting: {
connectionPoint: 'custom-connection-point'
},
})
Settings
anchor
connectionPoint
angle
45°