JonyEpsilon / gorilla-repl

A rich REPL for Clojure in the notebook style.
http://gorilla-repl.org
MIT License
887 stars 104 forks source link

Force directed graphs #99

Open paul-english opened 10 years ago

paul-english commented 10 years ago

Vega allows force-directed graphs, http://trifacta.github.io/vega/editor/index.html?spec=force

It would be nice to make use of these within gorilla-repl.

What needs to be done to add a new type of plot?

JonyEpsilon commented 10 years ago

Yes, this would be great. I think it's just a matter of coming up with some functions, probably in the gorilla-plot ns, which generate the appropriate vega data structures from clojure data. It kind of depends on what we want to be able to plot. I think Vega wants to work with nodes and edges - data in that format already would be very easy. Other data (say the adjacency matrix example you raised on #87) would need to be processed on the clojure side into node/edge lists.

paul-english commented 10 years ago

I had a chance to look at this a bit earlier in the week, and had something basic rendering. I'll improve it and see if I can get a pull request for you.

JonyEpsilon commented 10 years ago

That would be great, thanks!

paul-english commented 10 years ago

Just had a look at loom-gorilla it's great.

Here's a start to using vega's force layout just using example data.

http://viewer.gorilla-repl.org/view.html?source=github&user=log0ymxm&repo=gorilla-worksheets&path=src/drawing-graphs.clj

JonyEpsilon commented 10 years ago

That's really neat. It would definitely be good to have something like that in gorilla-plot.

I was doing some idle googling the other day, and came across this:

https://github.com/cpettitt/dagre-d3

It has a very OO interface, but looks pretty useful. In particular, it gives more control over the layout, which would be nice (I've been meaning to write a function to display sexprs as trees, and I don't think the force-directed layout would be very clear!)