G6
G6 copied to clipboard
自定义节点registerNode的getAnchorPoints方法不被触发
Describe the bug
registerNode的getAnchorPoints方法不被触发
CodeSandBox
https://codesandbox.io/p/sandbox/gallant-booth-rlj33t?file=%2Fsrc%2Fcomponents%2FbloodG6%2Findex.vue%3A1%2C1
Your Example Website or App
https://rlj33t-5173.csb.app/
Steps to Reproduce the Bug or Issue
无
Expected behavior
触发getAnchorPoints,进行锚点位置的自定义
Screenshots or Videos
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response
给个在线复现 demo?看不到代码呀
给个在线复现 demo?看不到代码呀
不好意思,贴错地址,已附上
需要配置啥吗 为啥我的getAnchorPoints也触发不了? G6.registerNode( "card-node", { drawShape: function drawShape(cfg, group) { const color = cfg.error ? "#F4664A" : "#30BF78"; const r = 2; const shape = group.addShape("rect", { attrs: { x: 0, y: 0, width: 100, height: 100, // stroke: color, fill: color, }, name: "main-box", draggable: true, });
group.addShape("text", {
attrs: {
textBaseline: "middle",
y: 60 / 2 - 10,
x: 100 / 2,
textAlign: "center",
lineHeight: 20,
fontSize: 12,
text: cfg.title,
fill: "#fff",
},
name: "title",
});
group.addShape("text", {
attrs: {
textBaseline: "middle",
y: 60 / 2 + 10,
x: 100 / 2,
textAlign: "center",
lineHeight: 20,
fontSize: 12,
text: "重要变更",
fill: "#fff",
},
name: "title",
});
cfg.panels.forEach((item, index) => {
group.addShape("image", {
attrs: {
y: 70,
x: 24 + index * 40,
height: 16,
width: 16,
cursor: "pointer",
img: item,
},
name: `node-icon-${index}`,
});
});
return shape;
},
getControlPoints() {
console.log(1111);
},
getAnchorPoints() {
return [
[0, 0.5], // 左侧中间
[1, 0.5], // 右侧中间
];
},
},
"react"
);
请问有什么进展吗?