请问继承内置点或边时,想复用内置点和边的原有的方法,该如何写?
- G6 Version:
- Platform:
- Mini Showcase(like screenshots):
- CodePen Link:
自定义节点或边,继承内置点或边。 继承内置点或边后,想对它的位置进行修改,该如何重写方法呢?没有看到如何调用父类的方法。 比如继承了 边 loop类型,想对它的起始节点进行修改。 重写draw方法,但是想复用之前的draw方法,请问这个如何实现,烦请回复,谢谢
修改的东西可以在 afterDraw 里面写,同理还有 afterUpdate https://g6.antv.vision/zh/docs/manual/middle/elements/nodes/custom-node
修改的东西可以在 afterDraw 里面写,同理还有 afterUpdate https://g6.antv.vision/zh/docs/manual/middle/elements/nodes/custom-node
我继承的是loop, 使用的是自定义节点 请问重写了afterDraw之后,它的样式有问题,当我拖动节点之后,才会显示正常。 当我未重写afterDraw,它的样式显示的是正常的。 这个是我有什么方法未调用吗?
写成在线 demo 看下
https://codesandbox.io/s/blissful-archimedes-4noqw?file=/index.js
属性为空的这个这个节点,上方是一个自环的边,拖动一下就会好。
未拖动前

拖动后

复写 afterDraw 时,需要在 afterDraw 中把 controlPoints 设置为 undefined,cfg.controlPoints = undefined; 因为 loop 是基于 cubic 定义的。
复写 afterDraw 时,需要在 afterDraw 中把 controlPoints 设置为 undefined,cfg.controlPoints = undefined; 因为 loop 是基于 cubic 定义的。
好的 多谢。