An item (node/edge) in G6 Consists of One or MoreGraphics Shape. You can add shapes to a custom item by group.addShape in the draw function of registering item. The shapes in G6:
It can be an integer or an array, representing the border radii of lefttop, righttop, rightbottom, leftbotton respectively. - radius: 1 or radius: [ 1 ] is equal to radius: [ 1, 1, 1, 1 ] - radius: [ 1, 2 ] is equal to radius: [ 1, 2, 1, 2 ] - radius: [ 1, 2, 3 ] is equal to radius: [ 1, 2, 3, 2 ]
We built in some commonly used shapes for it: circle, square, diamond, triangle, and triangle-down. You can customize it by path
Usage
group.addShape('marker',{
attrs:{
x:10,
y:10,
r:10,symbol:function(x, y, r){return[['M', x, y],['L', x + r, y + r],['L', x + r *2, y],['Z']];},},});
Path
⚠️Attention:
When the edge is too thin to be hitted by mouse, set lineAppendWidth to enlarge the hitting area.
Property
Name
Description
Remark
path
The path.
It can be a String, or an Array of path
startArrow
The arrow on the start of the path
When startArrow is true, show a default arrow on the start of the path. User can customize an arrow by path
endArrow
The arrow on the end of the path
When startArrow is true, show a default arrow on the end of the path. User can customize an arrow by path
lineAppendWidth
The hitting area of the path
Enlarge the hitting area by enlarging its value
lineCap
The style of two ends of the path
lineJoin
The style of the intersection of two path
lineWidth
The line width of the current path
miterLimit
The maximum miter length
lineDash
The style of the dash line
It is an array that describes the length of gaps and line segments. If the number of the elements in the array is odd, the elements will be dulplicated. Such as [5, 15, 25] will be regarded as [5, 15, 25, 5, 15, 25]
Usage
group.addShape('path',{
attrs:{
startArrow:{
path:'M 10,0 L -10,-10 L -10,10 Z',// The custom arrow is a path centered at (0, 0), and points to the positive direction of x-axis
d:10,},
endArrow:{
path:'M 10,0 L -10,-10 L -10,10 Z',// The custom arrow is a path centered at (0, 0), and points to the positive direction of x-axis
d:10,},
path:[['M',100,100],['L',200,200],],
stroke:'#000',
lineWidth:8,
lineAppendWidth:5,},});
Text
Properties
Name
Description
Remark
fill
The color or gradient color for filling.
The corresponding property in Canvas is fillStyle.
stroke
The color, gradient color, or pattern for stroke.
The corresponding property in Canvas is strokeStyle.
shadowColor
The color for shadow.
shadowBlur
The blur level for shadow.
Larger the value, more blur.
shadowOffsetX
The horizontal offset of the shadow.
shadowOffsetY
The vertical offset of the shadow.
opacity
The opacity (alpha value) of the shape.
The corresponding property in Canvas is globalAlpha.