antvis/G6




Do you want to work on this issue?
You can request for a bounty in order to promote it!
[Bug]: After setting the ports attribute to style in node, there is a difference between the end and the mouse position when using the create-edge plugin to create edges #6714
fxLion posted onGitHub
Describe the bug / 问题描述
创建边无异常的代码
import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
data: {
nodes: [{ id: 'node1' }, { id: 'node2' }, { id: 'node3' }, { id: 'node4' }, { id: 'node5' }],
edges: [
{ source: 'node1', target: 'node2' },
{ source: 'node1', target: 'node3' },
{ source: 'node1', target: 'node4' },
{ source: 'node2', target: 'node3' },
{ source: 'node3', target: 'node4' },
{ source: 'node4', target: 'node5' },
],
},
layout: {
type: 'grid',
},
node: {
style: {
// ports: [
// {
// "key": "top",
// "placement": [0.5, 0],
// },
// ]
}
},
behaviors: [
{
type: 'create-edge',
trigger: 'drag',
style: {
fill: 'red',
lineWidth: 2,
},
},
],
});
graph.render();
添加ports属性后,创建边的末端与鼠标位置有差异
import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
data: {
nodes: [{ id: 'node1' }, { id: 'node2' }, { id: 'node3' }, { id: 'node4' }, { id: 'node5' }],
edges: [
{ source: 'node1', target: 'node2' },
{ source: 'node1', target: 'node3' },
{ source: 'node1', target: 'node4' },
{ source: 'node2', target: 'node3' },
{ source: 'node3', target: 'node4' },
{ source: 'node4', target: 'node5' },
],
},
layout: {
type: 'grid',
},
node: {
style: {
ports: [
{
"key": "top",
"placement": [0.5, 0],
},
]
}
},
behaviors: [
{
type: 'create-edge',
trigger: 'drag',
style: {
fill: 'red',
lineWidth: 2,
},
},
],
});
graph.render();
效果图如下
Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
No response
G6 Version / G6 版本
🆕 5.x
OS / 操作系统
- macOS
- Windows
- Linux
- Others / 其他
Browser / 浏览器
- Chrome
- Edge
- Firefox
- Safari (Limited support / 有限支持)
- IE (Nonsupport / 不支持)
- Others / 其他