antvis/G6

有没有办法能够获取到dagre布局后,横向和纵向的节点数量? #4979

XiaoRIGE posted onGitHub

问题描述

希望分别获取到dagre布局后横向和纵向的节点数量

重现链接

www.test.com

重现步骤

1.使用dagre布局, 2.想要获取dagre布局后横向和纵向的节点数量

预期行为

想要获取dagre布局后横向和纵向的节点数量

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]
  • G6 版本: [4.5.1 ... ]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


没太明白,哪些属于横向节点哪些属于纵向节点?

posted by Yanyan-Wang over 1 year ago

假设我们的布局配置是

type: 'dagre',
rankdir: 'TB', 
align: 'DL',

能不能在布局完成前获取到横排/纵排的最大节点数量

posted by XiaoRIGE over 1 year ago

不能,布局完成后你可以通过坐标去判断

posted by Yanyan-Wang over 1 year ago

dagre配置中的nodesep是如何计算的?单位是px吗?为什么最后的展示效果会感觉有的节点明显是偏的 4f9f39018d7430144b7a403996fb8b5

posted by XiaoRIGE over 1 year ago

从上至下/从下至上的情况下,nodesep 是同行节点之间的水平间距,不会考虑和其他行节点的水平间距

posted by Yanyan-Wang over 1 year ago

请教下如果想要在此基础上调整是修改layout/dagre/src/position/index.js中的positionX方法吗?

posted by XiaoRIGE over 1 year ago

不需要吧,在 graph.on('afterlayout', e => { }) 监听里面去修改节点 x y 就可以,graph.updateItem('node1', { x: xxx, y: yyy })

或者像另外一个 issue 我回复的那样用自定义布局,本质上都是先用 dagre 布局完,然后再调整 x y

posted by Yanyan-Wang over 1 year ago

This issue has been closed because it has been outdate for a long time. Please open a new issue if you still need help.

这个 issue 已经被关闭,因为 它已经过期很久了。 如果你仍然需要帮助,请创建一个新的 issue。

posted by github-actions[bot] 10 months ago

Fund this Issue

$0.00
Funded

Pull requests