0

How do you make a force-directed-tree layout into a circle shape

D3.js Titles on Collapsible Force-Directed graph

instead of hanging?

http://bl.ocks.org/mbostock/1138500

Found an unanswered similar question here: D3.js how do I arrange nodes of a force layout to be on a circle

Apparently it can be done as seen in the second link. Just no idea how. Thanks!

Community
  • 1
  • 1

1 Answers1

0

You can use the charge() function to specify how repellant each node is each other. The more negative the number, the more they will repel each other. For example, try -250 or -500.

One side-effect of increasing the charge is the initial layout is more "bouncy" since the nodes are applying more force on each other.

Ed Ballot
  • 3,405
  • 1
  • 17
  • 24
  • Thanks will try that too! –  Jul 03 '15 at 22:52
  • `charge()` did it, thanks. Also seems [`size()` has some say in it too](https://github.com/mbostock/d3/wiki/Force-Layout#size). If you remove `size()` from [this example](http://jsfiddle.net/xnwyzj6q/2/) (Line 12) it all "falls" to one side. –  Jul 06 '15 at 16:06