Skip to content

[draft] add d3-based auto-layout #231

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

Closed
wants to merge 1 commit into from

Conversation

lihebi
Copy link
Collaborator

@lihebi lihebi commented Mar 1, 2023

This is an ongoing draft of adding d3-based auto-layout. There're still many details to be figured out.

An "auto-layout" button is added to the scope's toolbar. Once clicked, the pods inside the scope shall be auto-layouted. A global auto-layout button shall auto-layout the entire canvas.

Before auto-layout:
Screenshot 2023-03-01 at 12 42 11 PM

After auto-layout:
Screenshot 2023-03-01 at 12 42 30 PM

Known issues:

  • The layout position didn't consider the scope's position, thus the layout is not inside the scope.

@lihebi
Copy link
Collaborator Author

lihebi commented Mar 1, 2023

This PR has three layout algorithms:

  • d3-force: this is not ideal, as the layout results are dependent on the original position of the nodes. Our layout engine should be purely functional w.r.t. the edge and parent relations among the pods.
  • d3-hierarchy: this does not support nodes with variable width and height.
  • d3-flextree: this should be the most promising one.

Details of how to use d3 to auto-layout our pods:

  • create a d3 compatible graph data structure from our nodes
  • call d3's auto-layout algorithm on the newly created data structure. We need to choose what kind of force to use
  • get the updated positions of the d3 data structure and set the corresponding reactflow node positions.

@lihebi lihebi linked an issue Mar 1, 2023 that may be closed by this pull request
@lihebi
Copy link
Collaborator Author

lihebi commented Mar 1, 2023

Related issues:
#204
#49
#176

@lihebi
Copy link
Collaborator Author

lihebi commented Apr 29, 2023

merged #245

@lihebi lihebi closed this Apr 29, 2023
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

Successfully merging this pull request may close these issues.

Directed autolayout
1 participant