How to add constraints to d3 graph layout?
Malikx-Alee opened this issue · comments
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.
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.
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 layoutEngine
would be the old layoutEngine.adjustNodes
?