antvis / G6

♾ A Graph Visualization Framework in JavaScript.
https://g6.antv.antgroup.com/
MIT License
11k stars 1.3k forks source link

When an edge occurs, no event is triggered before or after. #5794

Closed RackweLLizm closed 2 months ago

RackweLLizm commented 2 months ago

Describe the bug

graph.on(GraphEvent.BEFORE_ELEMENT_CREATE, (e: any) => { }) This event is not triggered when Edge is created. So I Couldn't Find Any Event Triggered When Before or After Edge is Created. I also looked at the EdgeEvent class.

It is triggered when the node is created, no problem.

Your Example Website or App

notFound

Steps to Reproduce the Bug or Issue

notFound

Expected behavior

notFound

Screenshots or Videos

notFound

Platform

Windows Chrome 124 "@antv/g6": "^5.0.0-beta.37",

Additional context

No response

RackweLLizm commented 2 months ago

@Aarebecca Is there any progress on this issue? In beta 40, the event is still not triggered when the edge is created.

RackweLLizm commented 2 months ago
  this.graphInstance.updateBehavior({
                key: 'create-edge',
                enable: true,
                onFinish: this.onFinishEdge
            });

I solved my problem with the onFinish method when creating an edge. The method returns source and target properly. The targetSource mock id will be in the event data you receive with BEFORE_ELEMENT_CREATE. You can get the source and target correctly with the onFinish method.