antvis/G6

removeNodeData bug #5789

RackweLLizm posted onGitHub

问题描述

in Graphin graph.updateItem(id,{...}) graph.removeItem(id);

I could easily perform update and remove operations using it. But now I have to specify the type and this seems to make things a little complicated. When I give the ID for Delete and Update operations, it would be nice to have a method that would find the type from the ID in the graph and perform the operation. This is a suggestion.

I perform the deletion using the method below and the deletion is successful and there is no problem.

 RemoveItem = (id: string) => {
 let elementType = this.graphInstance.getElementType(id)
 if (elementType === "node") {
 this.graphInstance.removeNodeData([id])
 this.graphInstance.render();
 }
 else if (elementType === "edge") {
 this.graphInstance.removeEdgeData([id])
 }
 else if (elementType === "combo") {
 this.graphInstance.removeComboData([id])
 }
 }

But no matter what operation I do in the graph, I get the error shown in the picture below. Clicking on the node, clicking on the canvas, etc. All operations result in the following error.

silmebug

重现链接

notFound

重现步骤

bug

预期行为

notFound

平台

  • 操作系统: [Windows,]
  • 网页浏览器: [Google Chrome,]
  • G6 版本: "@antv/g6": "^5.0.0-beta.37",

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


Can you provide an example of your data

posted by Aarebecca 11 months ago

A simple but perhaps not elegant way is as follows:

const typeName = `${graph.getElementType(id)}s` as const;
graph.removeData({
 [typeName]: [id]
})
posted by Aarebecca 11 months ago

@Aarebecca

image

NodeType: Image

Method I use: graph.removeNodeData([id])

Additional Question: Is it Mandatory to Use graph.render() after using addNodeData and removeNodeData to the graph?

posted by RackweLLizm 11 months ago

"@antv/g6": "^5.0.0-beta.40", It does not give this error in the above version. Thank you

posted by RackweLLizm 11 months ago

Fund this Issue

$0.00
Funded

Pull requests