Dagre auto-layout not working properly after editing the layout ( delete node, and insert new node in-between nodes )
See original GitHub issueDescribe the Bug
I’m building a binary tree structure node visualisation web-app I want to be able to re-render all nodes with the new position after deleting a node
Current behaviour On adding a new node after deleting a node, the new node jumps to a new position as the deleted node is still present
code sample
const CustomNodeFlow = () => {
const dispatch = useAppDispatch();
const { elements } = useAppSelector((state) => state.flowgraphSlice);
const layeredElements = useMemo(
() => getLayoutedElements(elements, 'LR'),
[elements]
);
const onElementClick = (
event: React.MouseEvent<Element, MouseEvent>,
element: Node | Edge
) => {
if (element.type === NodeTypesEnum.DecisionNode) return;
dispatch(setSelectedNode(element as Node));
};
return (
<ReactFlow
elements={layeredElements}
nodeTypes={nodeTypes}
onElementClick={onElementClick}
defaultZoom={0.75}
>
<Background variant={BackgroundVariant.Dots} gap={24} size={0.5} />
<Controls />
</ReactFlow>
);
};
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
On adding a new node after deleting a node, the new node jumps to a new position as the deleted node is still present
Expected behavior
The graph should re-render nodes with newly calculated position
Screenshots or Videos
https://www.loom.com/share/e918c73a3e534e1f8c7fb72b159fff16
Platform
- OS: macOS
- Browser: Chrome, Safari, Firefox
- Version: 10
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
error when autolayout · Issue #205 · dagrejs/dagre - GitHub
The case is : we use graphlib to create a graph g g.setNode("boss1", { label: "boss1", ... when we create edge which from...
Read more >Dagre Tree Example - React Flow
This example shows how you can integrate dagre.js with React Flow to create simple tree layouts. Good alternatives to dagre are d3-hierarchy or...
Read more >Adding and Removing Nodes in D3js Force Graph
Now let's make that function that will add a node to the layout once the graph has been initialized! newNodeData is an object...
Read more >GEPHI – Introduction to Network Analysis and Visualization ...
The size of a node depends on the value of its “degree centrality” ... Let's add some more information to our graph by...
Read more >Aspire V9.0 User Manual - Vectric
When you create or open a two-sided project, Aspire will display two new icons ... Node Editing to fine tune the vectors of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @dexkode4 , I’m facing the similar issue, could you please share the codesandbox link if you have it.
Seen this happen in my setup too, but it wasn’t an issue for me. My guess: you will have to study dagre internals if you want to sort this out.