Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintaining custom node order in dagre layout #359

Open
OhadTutay opened this issue Sep 5, 2023 · 7 comments
Open

Maintaining custom node order in dagre layout #359

OhadTutay opened this issue Sep 5, 2023 · 7 comments

Comments

@OhadTutay
Copy link

Hello,
I am currently working on a project where I'm using Dagre.js for graph layout, specifically for tree structures.
While Dagre.js excels at automatic graph layout, I have a specific requirement that I'm finding challenging to implement: I need to enforce a specific order for the children of a tree node, such as rendering children from left to right.

Dagre.js automatically arranges nodes and edges to optimize the layout, which sometimes results in nodes being placed in an order that doesn't align with my intended structure. I'm looking for a way to define and maintain the order of child nodes within a tree node using Dagre.js - I want the order of the nodes to be the same as their order in the array of nodes I provide to the dagre layout.

Is there currently a feature or approach in dagre that enables such custom node ordering? If not, would it be possible to consider adding this functionality in a future release? (For reference, a similar option is available in Elk.js:
https://eclipse.dev/elk/reference/options/org-eclipse-elk-layered-layering-strategy.html (INTERACTIVE option) and
https://www.eclipse.org/elk/reference/options/org-eclipse-elk-layered-crossingMinimization-forceNodeModelOrder.html)

Thank you for your assistance.

@voxpelli
Copy link

voxpelli commented Feb 9, 2024

This fork claims to support custom node order: https://www.npmjs.com/package/@pinging/dagrejs

@volkandkaya
Copy link

Did you ever end up solving it @OhadTutay ? I tried Elk but the laying out isn't as good as Dagre.

@voxpelli did you try that solution?

@voxpelli
Copy link

@volkandkaya I have not tried it (yet), the fork seems a bit outdated in other aspects

@volkandkaya
Copy link

@voxpelli felt the same, I have went with Elk for now. Should be easy to swap back to Dagre if they add it.

@rudyLittleLove
Copy link

rudyLittleLove commented Aug 21, 2024

布局顺序是根据传入的节点顺序排序的
image
setNode 时,根据上面顺序插入数据
image

@dbl520
Copy link

dbl520 commented Aug 23, 2024

大佬这个key是id吗
image

@luckyship
Copy link

布局顺序是根据传入的节点顺序排序的 image setNode 时,根据上面顺序插入数据 image

实测和setEdge也有关系

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants