vasturiano/force-graph

dagMode none

Closed this issue · 4 comments

Sometimes, for a DAG, the non-DAG layout is better than any of the dagMode layouts and I would like to return to the non-DagMode layout but there doesn't seem to be any value for dagMode that I can set to achieve this.

I can switch between various dagModes but even when I re-render the component rebuilding the graph completely without setting dagMode it still comes out with the last set dagMode until I render a completely new graph with different nodes. I'd like to switch back to non-Dag mode by setting dagMode to some specific value.

I have tried .dagMode(null) and .dagMode('') without success.

@ingodahn any falsy value that you pass onto dagMode should have the effect of switching off its current dag mode. So, either of your options mentioned above should work.
You can see that switching possible in this example:
https://vasturiano.github.io/force-graph/example/tree/

If you pick the null option on the DAG orientation box it will cancel the DAG functionality.

If this is not working for you, could you make a reproduceable simple example on codepen that we can use to debug?

@ingodahn the issue there is that you're re-instantiating the ForceGraph object every time. You shouldn't do that. You only need to do this once, every following updata should be performed on this variable:

const myGraph = ForceGraph()(<myDomElement>);

Thanks, re-calling .dagMode(null) after configuring the graph is indeed a workaround.