antvis/G6


Do you want to work on this issue?
You can request for a bounty in order to promote it!
[Bug]: Error: [G6 v5.0.43] Unknown element type of id: #6865
mianbing posted onGitHub
Describe the bug / 问题描述
// 配置可拖拽元素
// behaviors: ['drag-element'],
// 自定义六边形组合
export default class CircleComboWithExtraButton extends BaseCombo {
protected getKeyStyle(attributes: Required<BaseComboStyleProps>) {
const [width] = this.getKeySize(attributes);
return { ...super.getKeyStyle(attributes), size: width };
}
// 实现 drawKeyShape 方法
protected drawKeyShape(attributes: Required<BaseComboStyleProps>, container: any) {
return this.upsert('Hexagon', Hexagon, this.getKeyStyle(attributes), container) as Hexagon;
}
}
注册 -> 添加combo数据 -> render,之后拖拽Node元素没有问题,拖拽combo时,无法拖动,控制台报错 Error: [G6 v5.0.43] Unknown element type of id:
// 排查是 this.upsert 返回的元素没有id值,临时解决方案如下:
export default class CircleComboWithExtraButton extends BaseCombo {
protected getKeyStyle(attributes: Required<BaseComboStyleProps>) {
const [width] = this.getKeySize(attributes);
return { ...super.getKeyStyle(attributes), size: width };
}
protected drawKeyShape(attributes: Required<BaseComboStyleProps>, container: any) {
// 临时解决方案,将container的id,赋值给新的图形
const customCombo = this.upsert('Hexagon', Hexagon, this.getKeyStyle(attributes), container) as Hexagon;
customCombo.id = container.id
return customCombo
}
}
Reproduction link / 复现链接
https://stackblitz.com/edit/react-wcozswdw?file=index.js
Steps to Reproduce the Bug or Issue / 重现步骤
No response
Version / 版本
🆕 5.x
OS / 操作系统
- macOS
- Windows
- Linux
- Others / 其他
Browser / 浏览器
- Chrome
- Edge
- Firefox
- Safari (Limited support / 有限支持)
- IE (Nonsupport / 不支持)
- Others / 其他