Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: After clearing the canvas and adding a node again, the node will display an exception #6649

Open
2 of 10 tasks
tabzhao opened this issue Dec 19, 2024 · 2 comments
Open
2 of 10 tasks
Labels
bug status: waiting for maintainer These issues have not yet been reviewed by a maintainer

Comments

@tabzhao
Copy link

tabzhao commented Dec 19, 2024

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 / 其他
@tabzhao tabzhao added the status: waiting for maintainer These issues have not yet been reviewed by a maintainer label Dec 19, 2024
@github-actions github-actions bot changed the title [Bug]: 清空画布后再次添加节点,节点会显示异常 [Bug]: After clearing the canvas and adding a node again, the node will display an exception Dec 19, 2024
@yvonneyx yvonneyx added Need Improvement Lack of information or incorrect format status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues have not yet been reviewed by a maintainer labels Dec 19, 2024
Copy link

Please provide more information, or use the standard format, otherwise we will not process this issue.
Reference document:


请提供更多信息,或者使用规范的格式,否则我们不会处理这个 issue。
参考文档:

@tabzhao
Copy link
Author

tabzhao commented Dec 20, 2024

G6 v5.0.35版本,最新的v5.0.38也试过了 可以复现

@github-actions github-actions bot added status: waiting for maintainer These issues have not yet been reviewed by a maintainer and removed status: waiting for author Issue with insufficient information labels Dec 20, 2024
@Aarebecca Aarebecca added bug and removed Need Improvement Lack of information or incorrect format labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status: waiting for maintainer These issues have not yet been reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants