antvis/G6

antv-dagre error "Edge not found for id:", the edge and id exist on the graph, and it is no problem to replace it with dagre #6477

xiaoxiaofu1 posted onGitHub

Describe the bug / 问题描述

const layouts = [ { type: 'antv-dagre', // type: 'dagre', label: '层次布局', rankdir: 'LR', nodeSep: 30, ranksep: 700, icon: <ApartmentOutlined />, } ]; const handleLayout = () => { const selectedNodesIds = graph.getElementDataByState('node', 'selected').map((item) => item.id); const nodeFilter = (item) => selectedNodesIds.includes(item.id); const begin = graph.getViewportCenter(); const config = mode === 'global' ? layout : { ...layout, nodeFilter, begin }; graph.setLayout(config); graph.layout() }; 如图是部分代码,如果把antv-dagre改成dagre就没有这个错误

No response

Steps to Reproduce the Bug or Issue / 重现步骤

No response

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

macOS

Browser / 浏览器

Chrome

Additional context / 补充说明

No response


请提供完整复现 demo~

posted by yvonneyx 6 months ago

请提供完整复现 demo~

我发现是当存在平行边,然后指定layer就会出这个问题,可以用下面的例子 import { Graph } from '@antv/g6';

const data = { nodes: [ { id: '0', layer: 0 }, { id: '01', layer: 0 }, { id: '1', layer: 1 }, { id: '2', layer: 1 }, { id: '-1', layer: -1 }, { id: '-2', layer: -1 } ], edges: [ { source: '0', target: '1' }, { source: '1', target: '0' }, { source: '0', target: '2' }, { source: '-1', target: '0' }, { source: '-2', target: '0' }, ], };

const graph = new Graph({ container: 'container', autoFit: 'view', animation: false, data, layout: { type: 'antv-dagre', rankdir: 'LR', nodeSize: [60, 30], nodesep: 60, ranksep: 40, controlPoints: true, }, node: { type: 'rect', style: { size: [60, 30], radius: 8, labelText: (d) => d.id, labelBackground: true, } }, edge: { type: 'polyline', }, behaviors: ['drag-element', 'drag-canvas', 'zoom-canvas'], });

graph.render();

window.addPanel((gui) => { const config = { layout: 'default' }; const layouts = { default: { type: 'antv-dagre', nodesep: 100, ranksep: 70, controlPoints: true }, LR: { type: 'antv-dagre', rankdir: 'LR', align: 'DL', nodesep: 50, ranksep: 70, controlPoints: true }, 'LR&UL': { type: 'antv-dagre', rankdir: 'LR', align: 'UL', controlPoints: true, nodesep: 50, ranksep: 70 }, };

gui.add(config, 'layout', Object.keys(layouts)).onChange(async (layout) => { graph.setLayout(layouts[layout]); await graph.layout(); graph.fitCenter(); }); });

posted by songxiaoyu321 6 months 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] 5 months ago

Fund this Issue

$0.00
Funded

Pull requests