antvis/G6

报错Cannot read properties of undefined (reading 'on') #4952

7hao123 posted onGitHub

问题描述

使用相同的代码,有的页面可以将数据渲染出来,有的页面不能渲染出来,不能渲染的页面报错Cannot read properties of undefined (reading 'on'),怀疑是数据出错,可能是样例数据的label不能全为空吗?或者是不能指向多条边

重现链接

重现步骤

数据 "nodes": [ { "id": "7", "label": null, "icon": null, "x": 0.0, "y": 0.0,

        },
        {
            "id": "24",
            "label": null,
            "icon": null,
            "x": 0.0,
            "y": 0.0,

        },
        {
            "id": "73",
            "label": null,
            "icon": null,
            "x": 0.0,
            "y": 0.0,

        },
        {
            "id": "61",
            "label": null,
            "icon": null,
            "x": 0.0,
            "y": 0.0,

        }
    ],
    "edges": [
        {
            "id": "20",
            "label": null,
            "source": "73",
            "target": "7",

        },
        {
            "id": "46",
            "label": null,
            "source": "61",
            "target": "7",

        },
        {
            "id": "48",
            "label": null,
            "source": "24",
            "target": "7",

        }
    ]

预期行为

我希望得到为什么出现这个bug的问题,以及解决方案

平台

  • 操作系统: [ Windows,.]
  • 网页浏览器: [Google Chrome]
  • G6 版本: [4.8.17 ]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


给个在线复现 demo

posted by Yanyan-Wang over 1 year ago

新建 文本文档.txt 这个文件把后缀改成html即可得到复现结果,经我测试认为可能是自定义节点,label如果是空的话,则渲染不出来,如果空的label和非空label的节点相连也能够渲染出来,希望解答一下。

posted by 7hao123 over 1 year ago

image

这里问题就是节点没有四个图形呀,所以 const imgShape = group.getChildByIndex(3); 拿到的是 undefined。这里我理解做一下判断就好了吧

posted by Yanyan-Wang over 1 year ago

我觉得不像是这里的问题,即使我把afterDraw的代码全部注释了仍然不能正确渲染 MLOKLAZ(F _2RKM01ZQ%IVE

posted by 7hao123 over 1 year ago

我这里可以的。注释掉之后,不要热更新,手动刷新

posted by Yanyan-Wang over 1 year ago

This issue has been closed because it has been outdate for a long time. Please open a new issue if you still need help.

这个 issue 已经被关闭,因为 它已经过期很久了。 如果你仍然需要帮助,请创建一个新的 issue。

posted by github-actions[bot] 10 months ago

Fund this Issue

$0.00
Funded

Pull requests