antvis/G6


The issue has been closed
如何 extend function? #5117
neolee6053 posted onGitHub
问题描述
我想extend(不是override) edge现有的drawLabel function 。
chatgpt 的建议, 有没有更好的办法? class CustomEdge extends G6.Edge { constructor(cfg) { super(cfg); }
draw(cfg, group) { // Call the parent class's draw method to retain its functionality super.draw(cfg, group);
// Add your custom behavior here
// For example, you can customize the label rendering:
this.drawCustomLabel(cfg, group);
}
drawCustomLabel(cfg, group) { // Your custom label rendering logic goes here } }
G6.registerEdge('custom-edge', CustomEdge);
重现链接
重现步骤
如上
预期行为
如上
平台
- 操作系统: [ Windows]
- 网页浏览器: [Google Chrome]
- G6 版本: [4.8.15 ]
屏幕截图或视频(可选)
No response
补充说明(可选)
No response