dagre
dagre copied to clipboard
When each node has its own child nodes, their child nodes will not affect each other. Now they will be displayed equally
if (isNode(element)) {
const { data,id } = element
if(id!=="0"){
const {parentId} = data
if(parentId===0||parentId){
g.setParent(id, parentId+"");
}
}
g.setNode(element.id, {
width: element.__rf?.width,
height: element.__rf?.height,
});
} else {
g.setEdge(element.source, element.target);
}
I used setEdge
before
but i got the graph drawn by the nodes of the second level is evenly spaced, so I think they are caused by no parent-child relationship
So you see that code
i added the setParent
I hope they can divide the space equally in their own area
but i failed
Uncaught TypeError: Cannot set properties of undefined (setting 'rank')
i don't know what to use
const g = new dagre.graphlib.Graph({compound: true });
g.setGraph({ rankdir: isHorizontal ? "LR" : "TB", nodesep: 12, ranksep: 80 });
g.setDefaultEdgeLabel(() => ({}));
Its child nodes will affect each other and divide the spacing between them equally