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.
X6 provides the following built-in anchor point definitions:
The anchor point is located at a specified proportion of the connected edge. Supports the following parameters:
Parameter Name | Parameter Type | Required | Default Value | Parameter Description |
---|---|---|---|---|
ratio | number | No | 0.5 | The proportion of the edge length from the starting point, defaulting to the center of the edge length. |
The anchor point is located at a specified length from the connected edge. Supports the following parameters:
Parameter Name | Parameter Type | Required | Default Value | Parameter Description |
---|---|---|---|---|
length | number | No | 20 | The length from the starting point of the edge, defaulting to 20px from the starting point. |
Uses the point closest to the reference point as the anchor point.
Orthogonal anchor point. Supports the following parameters:
Parameter Name | Parameter Type | Required | Default Value | Parameter Description |
---|---|---|---|---|
fallbackAt | number | string | No | undefined | When 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. |
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 Name | Parameter Type | Parameter Description |
---|---|---|
this | EdgeView | The view of the edge. |
view | EdgeView | The view of the connected edge. |
magnet | SVGElement | The element of the connected edge. |
ref | Point.PointLike | SVGElement | The reference point/element. |
args | T | The 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',},},})