antvis/G6




The issue has been closed
单独使用布局报这个错 Cannot read properties of undefined (reading 'rank') #5033
katerinaaaaaa posted onGitHub
问题描述
单独使用布局报这个错 Cannot read properties of undefined (reading 'rank')
重现链接
重现步骤
1.
import { DagreLayout } from '@antv/layout'
const data = {
nodes: [
{
name: '应用服务器',
id: '8c811eec-e60b-4609-a9f6-ed5d36d58ab9',
comboId: 'sasasa'
},
{
name: '防火墙',
id: '170a711d-0c1c-4778-98a7-04c6b095110e',
comboId: 'sasasa'
},
{
name: '路由器',
id: '38069dbb-b526-4c87-b182-7093b91dfc3f'
},
{
name: '应用服务器',
id: '016af125-ab6e-499b-9456-b06590bbd81a'
},
{
name: '防火墙',
id: 'e055704a-3c3c-4f5b-afdd-fdaf7739b868'
}
],
combos: [
{
id: 'sasasa'
}
],
edges: [
{
source: '170a711d-0c1c-4778-98a7-04c6b095110e',
target: 'e055704a-3c3c-4f5b-afdd-fdaf7739b868'
},
{
source: '8c811eec-e60b-4609-a9f6-ed5d36d58ab9',
target: '016af125-ab6e-499b-9456-b06590bbd81a'
},
{
source: '016af125-ab6e-499b-9456-b06590bbd81a',
target: '38069dbb-b526-4c87-b182-7093b91dfc3f'
},
{
source: 'sasasa',
target: '38069dbb-b526-4c87-b182-7093b91dfc3f'
}
]
}
const darge = new DagreLayout({
type: 'dagre',
ranker: 'network-simplex', // 节点分层算法,可选:'tight-tree' 'longest-path' 'network-simplex'
rankdir: 'TB', // 图的延展方向,可选: 'TB' | 'BT' | 'LR' | 'RL'
ranksep: 100, // 图的各个层次之间的间距
nodesep: 100, // 同层各个节点之间的间距
sortByCombo: true,
nodeSize: 30
})
const res = darge.layout(data)
console.log('res', res)
2.浏览器报错 Cannot read properties of undefined (reading 'rank')
预期行为
期望正常运行,输出布局位置信息
平台
- 操作系统: [macOS, Windows, Linux, React Native ...]
- 网页浏览器: [Google Chrome, Safari, Firefox]
- G6 版本: [4.8.21 ... ]
屏幕截图或视频(可选)
https://github.com/antvis/G6/assets/87105438/debbc4f6-fa8f-49ec-a8a4-861db8f3b0e4
补充说明(可选)
No response