Derived from the D3.js example force_cluster.html
- Click on node to expand or collapse.
- Click on hull (which shows up when you expanded a group node) to collapse the group.
- Drag node to move entire graph around.
-
network()is the one who takes care of (re)generating the nodes and links from the original data, based on theexpand[]info, i.e. which group(s) should be shown in expanded form and which shouldn't. -
only group nodes are expected to a
.sizeattribute (read: your own JSON should use that attribute for any node). Same goes for the fields.group_dataand.link_count: all of these are expected to be generated by thenetwork()call. (.group_datais a reference to the group (x/y/size/link_count) for a node,group_node.link_countcounts the number of links between groups.) -
you'll very probably have to tweak
.gravity,.charge,.linkDistanceand maybe also.linkStrengthto make your own graphs look good. Compare the final layout of this graph with the ones produced by the v2.9.6 force_cluster.html D3 code: note the generally quite different position of the groups which have only a single link to other groups; that and other differences are all due to the 4 aforementionedforceparameters.
I am trying to update this for d3 v4. Preview
Click on node is not working properly. There are edges which are not connected to nodes.