Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

官网的自定义边,如果节点是垂直方向,自定义连接线路径有错误 #5622

Closed
Shen120 opened this issue Apr 7, 2024 · 3 comments

Comments

@Shen120
Copy link

Shen120 commented Apr 7, 2024

问题描述

image
图中只是处理了横向连接线的路径,但是垂直走向就是错误的;正常情况应该是这样的:
image
;请问如何计算?

重现链接

https://g6.antv.antgroup.com/zh/examples/item/customEdge/#customPolyline

重现步骤

打开页面拖动节点,进行垂直摆放

预期行为

正确的路径走向

平台

  • 操作系统: Windows 10
  • 网页浏览器: Chrome
  • G6 版本: 4.8.21

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

@Aarebecca
Copy link
Contributor

Aarebecca commented Apr 7, 2024

image

看着没什么问题呢

  getPath(points) {
      const { x: x1, y: y1 } = points[0];
      const { x: x2, y: y2 } = points[1];
      const [width, height] = [x2 - x1, y2 - y1];
      return [
        ['M', x1, y1],
        ['L', x1, y1 + height / 2],
        ['L', x2, y1 + height / 2],
        ['L', x2, y2],
      ];
    }

@Shen120
Copy link
Author

Shen120 commented Apr 8, 2024

image 看着没什么问题呢
  getPath(points) {
      const { x: x1, y: y1 } = points[0];
      const { x: x2, y: y2 } = points[1];
      const [width, height] = [x2 - x1, y2 - y1];
      return [
        ['M', x1, y1],
        ['L', x1, y1 + height / 2],
        ['L', x2, y1 + height / 2],
        ['L', x2, y2],
      ];
    }

能否实现自动变化路径呢,以适配各种方向的节点,搞不明白这

@Aarebecca
Copy link
Contributor

Aarebecca commented Apr 8, 2024

G6 中 Path 遵守 SVG Path 规范,不过使用的是数组形式表达。
自动寻径能力仅 5.x 版本可用 Demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants