patrickfuller / jgraph

An embeddable webGL graph visualization library.
http://patrickfuller.github.io/jgraph
MIT License
133 stars 31 forks source link

Force Directed Layout Restricted to 2D Plane #9

Open fredhohman opened 7 years ago

fredhohman commented 7 years ago

Is there a way to run the force directed graph layout on a graph but restrict the layout to 2D, say in the x-y plane?

i.e. just the standard layout technique found in other graph plotting packages.

Thanks!

patrickfuller commented 7 years ago

From here, jgraph.generate has an is_3d parameter. If you set that to False, it should generate a 2D graph.

fredhohman commented 7 years ago

Perfect, got it working. Is there any way to have this work with jgraph.draw() in order to preserve the animation of the nodes moving into a steady state (e.g. the optimize parameter)?

patrickfuller commented 7 years ago

Doing it client side (so you see the animations) would require stripping out a few lines from this javascript function. You might be able to overwrite from the notebook with something like:

from IPython.display import Javascript
Javascript('jgraph.optimize = function () { # new function here }')

Alternately, you could write your own 3d toggle option in the javascript file and then submit a PR with the change.