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();

效果图如下 image

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 / 其他

It looks as expected

posted by uhobnil 4 months ago

I also encountered the same problem. There would be some deviation between the created edge and the cursor.

posted by LWtower 1 day ago

Moreover, this bug will only occur if placement is added

posted by LWtower 1 day ago

Image

posted by LWtower 1 day ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests