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

How do I dynamically add new edges like in 4.x? #6357

Open
ZhouYC404 opened this issue Sep 20, 2024 · 1 comment
Open

How do I dynamically add new edges like in 4.x? #6357

ZhouYC404 opened this issue Sep 20, 2024 · 1 comment

Comments

@ZhouYC404
Copy link

ZhouYC404 commented Sep 20, 2024

Describe the bug / 问题描述

image

请问如何通过上下文菜单来新增边,而不是默认的behavior那样通过点击和拖拽新增?

本来想像4.x的demo那样手写监听事件的方式来实现,但是监听canvas:pointermove事件的时候每次都要调用graph.draw方法不然edge不会实时更新位置,但是这样页面就会很卡顿;而且edge的target也不能像4.x那样直接指向一个坐标了,必须指向一个node的id。

内置的新增边功能还有一个bug,就是新增边后,在页面第一帧时,edge会飞到canvas的左上角去:

image

Reproduction link / 重现链接

No response

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

No response

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

macOS

Browser / 浏览器

Chrome

Additional context / 补充说明

No response

@github-actions github-actions bot changed the title 如何像4.x一样动态新增边? How do I dynamically add new edges like in 4.x? Sep 20, 2024
@ZhouYC404
Copy link
Author

把源码中的create-edge代码抽出来魔改了一个自定义的新增边,也算解决问题了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant