Skip to content Skip to sidebar Skip to footer

Problems With Latest Cluster Force Layout Example

Based on this work: http://bl.ocks.org/mbostock/7882658 If I substitute the automatic nodes creation by a JSON.stringify() output of the automatically generated data like this... v

Solution 1:

The problem is that nodes is not the only data structure that needs to be initialised -- clusters needs to be as well. In particular, specific nodes are assigned to specific cluster indices. If you don't do that, things will break.

To fix, do something like

nodes.forEach(function(d) { clusters[d.cluster] = d; });

Complete jsfiddle here.

Post a Comment for "Problems With Latest Cluster Force Layout Example"