1、上个图:
官方地址:https://x6.antv.antgroup.com/tutorial/intermediate/tools
2、鼠标移上去,左上角会有一个删除小按钮,这个是x6自动的功能,只要稍微写二行代码就实现了:
graph.on('node:mouseenter', ({ e, node, view }) => {
node.addTools({
name: 'button-remove',
args: {
x: 10,
y: 10,
offset: { x: 0, y: 0 },
},
})
});
graph.on('node:mouseleave', ({ e, node, view }) => {
node.removeTools();
});
其实x,y可以自动调整,来改变这个X的位置,比如说:
x:'100%', y:0,这样会显示在最右上角。