来两个Node,添加Edge
const source = this.graph.addNode({
// shape: 'react',
x: 250,
y: 50,
width: 100,
height: 40,
shape: 'rect',
attrs: { label: { text: 'source-起点' } }
})
// C
const target = this.graph.addNode({
x: 350,
y: 150,
width: 100,
height: 40,
shape: 'circle',
attrs: { label: { text: 'target-终点' } }
})
// 添加边
this.graph.addEdge({
source,
target,
attrs: {
line: {
stroke: 'red', // #a0a0a0
strokeWidth: 1
}
}
})
![](https://img.haomeiwen.com/i19339252/e66c10cc930f9669.png)
image.png
可以自定义边
// 添加边
this.graph.addEdge({
source,
target,
attrs: {
line: {
stroke: 'red', // #a0a0a0
strokeWidth: 1,
// 自定义的
targetMarker: {
tagName: 'path',
fill: 'yellow', // 使用自定义填充色
stroke: 'green', // 使用自定义边框色
strokeWidth: 2,
d: 'M 20 -10 0 0 20 10 Z'
}
}
}
})
![](https://img.haomeiwen.com/i19339252/27bff540a0bead41.png)
image.png
网友评论