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

How to add constraints to d3 graph layout? #282

Open
Malikx-Alee opened this issue Oct 26, 2020 · 2 comments
Open

How to add constraints to d3 graph layout? #282

Malikx-Alee opened this issue Oct 26, 2020 · 2 comments

Comments

@Malikx-Alee
Copy link
Contributor

Malikx-Alee commented Oct 26, 2020

How can we use d3 layout and add constraints to it using webcola in react-digraph? If you could suggest any method of implementation it would be a great help.

I want to change the layout generator from dagre to webcola for better layout.

@ajbogh
Copy link
Contributor

ajbogh commented Nov 16, 2020

You can create a LayoutEngine class and add your own code to it. The LayoutEngine essentially loops through the nodes and modifies the {x,y} properties for each node. You will need a PR to include a new LayoutEngine in the code.

I believe the LayoutEngine uses a string and the engines are defined in the project, but feel free to change the layoutEngineType attribute to accept functions as well so that you can develop your own class or function that is not within the react-digraph codebase (call it layoutEngine instead and deprecate layoutEngineType with a console.warn). You will need to open a PR for this.

@Djazouli
Copy link
Contributor

Hello,
I would also like to be able to change the layout generator to customize my rendering a bit. What do you think the new layoutEngine attribute should be ? A class, that we instanciate within the graph-view ? An instance of a class that has an adjustNode method ? Or a function that takes an array of INode, and a nodesMap? (and thus the new layoutEnginewould be the old layoutEngine.adjustNodes ?

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

3 participants