antvis / antvis/G6

[Bug]: 通过addItem动态添加边edge时,若其中一端的节点位于收缩状态的combo内部时,会导致edge的这一端出现浮空。

Open
#7,436 2 comments 0 reactions 0 assignees View on GitHub
bug 🐛 v4
Dominant language
TypeScript
Stars
12.3k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug / 问题描述

使用版本:antv g6 v4

问题标题:通过addItem动态添加边edge时,若其中一端的节点位于收缩状态的combo内部时,会导致edge的这一端出现浮空。

问题详情:当Combo处于收缩状态时,直接给其内部节点添加连接外部节点的边,边的另一端会直接出现浮空问题。
我认为这是因为收缩状态下,Combo作为一个整体,其内部节点的具体位置被隐藏了,端点计算bbox时出现了问题,不论通过refresh方法,还是updateCombos等方法,都无法使其正确渲染。唯独使用graph.render可以正常渲染,但会报错,希望官方能够修复。

graph.render时控制台报错信息如下:
Uncaught TypeError: bboxMethod is not a function
at ShapeBase3.calculateBBox (@antv_g6.js?v=100e5096:75608:18)
at AbstractShape2.getBBox (@antv_g6.js?v=100e5096:63505:21)
at getBBox2 (@antv_g6.js?v=100e5096:57986:22)
at Combo2.calculateCanvasBBox (@antv_g6.js?v=100e5096:67756:18)
at Combo2.getBBox (@antv_g6.js?v=100e5096:67871:23)
at MiniMap2.updateOneComboKeyShape (@antv_g6.js?v=100e5096:82880:23)
at @antv_g6.js?v=100e5096:82968:19
at each (chunk-KTG5AIZC.js?v=100e5096:136:13)
at @antv_g6.js?v=100e5096:82967:11

另外地,当某个节点与某个combo作为边的两个端点进行连接时,正常是应该只有一条边的(由于未使用曲线作为连线,所以即使有多条直线边重合了,在视觉上也应该只有一条边),如图就出现了多了几条浮空的边,希望这个问题官方能够一并解决(底层上可能与上述问题是同一个问题)。

Image

### Reproduction link / 复现链接

_No response_

### Steps to Reproduce the Bug or Issue / 重现步骤

1.删除节点:graph.removeItem(item, true);
2.尝试通过undo栈取出刚刚删除的节点:beforedata = graph.getUndoStack().pop();
3.将beforedata中的nodes和edges进行遍历,将删除节点的相关信息进行重新添加:graph.addItem(itemType, model, false);

结果:节点正确恢复,但combo处于收缩状态下时edge的端点出现问题。

### Version / 版本

4.x

### OS / 操作系统

- [ ] macOS
- [x] Windows
- [ ] Linux
- [ ] Others / 其他

### Browser / 浏览器

- [x] Chrome
- [ ] Edge
- [ ] Firefox
- [ ] Safari (Limited support / 有限支持)
- [ ] IE (Nonsupport / 不支持)
- [ ] Others / 其他

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the undo-stack sequence using graph.removeItem, graph.getUndoStack().pop(), and graph.addItem with a collapsed combo. Start by tracing edge endpoint and bounding-box handling through graph.addItem, graph.render, Combo.calculateCanvasBBox, and MiniMap.updateOneComboKeyShape. Done means collapsed-combo edges connect correctly, duplicate floating edges are absent, and rendering no longer raises the reported bboxMethod error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.