G6 icon indicating copy to clipboard operation
G6 copied to clipboard

afteradditem 回调函数里面e.item.get('parent')为null

Open xhay1122 opened this issue 6 years ago • 3 comments

  • G6 Version: 3.3.5
  • Platform: MAC OS
  • Mini Showcase(like screenshots):
  • CodePen Link:

在afteradditem回调中无法获取parent

xhay1122 avatar Feb 24 '20 06:02 xhay1122

是 TreeGraph 吗?想拿到的 parent 是 group 还是父节点?

Yanyan-Wang avatar Feb 25 '20 06:02 Yanyan-Wang

TreeGraph 想拿到parent实例

https://codesandbox.io/s/purple-snow-hdj0t

xhay1122 avatar Feb 26 '20 03:02 xhay1122

树图在 addChild 的时候,先 addItem 创建了新的 item 实例之后,才能把 parent 挂在到 item 上面,所以在 afteradditem 的时候还没有挂在 parent。

为满足这个需求,v3.3.7 在 TreeGraph 上增加了 beforeaddchild 和 afteraddchild 时机事件。

Yanyan-Wang avatar Mar 05 '20 14:03 Yanyan-Wang