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显示不出来。

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 / 其他

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


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

posted by github-actions[bot] 4 months ago

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

posted by tabzhao 4 months ago

临时规避手段:

setData后,把全部节点的zIndex都更新为1,graph.updateNodeData([{id:'xx',style:{zIndex:1}}])

posted by TZZack 4 months ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests