antvis/G6



Do you want to work on this issue?
You can request for a bounty in order to promote it!
[Bug]: After clearing the canvas and adding a node again, the node will display an exception #6649
tabzhao posted onGitHub
Describe the bug / 问题描述
如题,再画布上添加两个node,一条edge,调用clear方法清空画布后,再次添加node之后,edge可以显示出来,node显示不出来。
Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
1、先在画布上渲染出来节点元素 2、调用clear方法清空画布元素 3、调用addData方法添加新的节点元素 4、节点显示异常
测试demo 1、点击删除按钮清空画布 2、点击edit按钮添加新的元素
import { Graph } from '@antv/g6'
let graph: Graph
const nodes = [
{ id: 'xxx2', label: 'xxx2' },
{ id: 'xxx3', label: 'xxx3' },
]
const edges = [
{ id: 'exx1', source: 'xxx2', target: 'xxx3' }
]
const clear = () => {
graph.clear().then(() => {
alert('已清空')
})
}
const add = () => {
graph.addData({
nodes,
edges
})
graph.render()
}
graph = new Graph({
container: "G6",
data: {
nodes,
edges
},
node: {
type: 'circle',
style: {
size: 50,
labelFontSize: '18px',
labelText: (d) => d.label as string
},
palette: {
field: 'group',
color: 'tableau',
},
},
layout: {
type: 'force',
},
animation: false,
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-element'],
plugins: [
{
type: 'toolbar',
key: 'toolbar',
position: 'top-left',
onClick: (item) => {
switch(item){
case 'delete':
clear()
break
case 'edit':
add()
break
}
},
getItems: () => {
return [
{ id: 'edit', value: 'edit' },
{ id: 'delete', value: 'delete' },
]
}
}
]
})
graph.render()
G6 Version / G6 版本
🆕 5.x
OS / 操作系统
- macOS
- Windows
- Linux
- Others / 其他
Browser / 浏览器
- Chrome
- Edge
- Firefox
- Safari (Limited support / 有限支持)
- IE (Nonsupport / 不支持)
- Others / 其他