Skip to content Skip to sidebar Skip to footer

Grouping Nodes In D3.js In Multiforce Layout

Hi I am trying to group nodes generated as floating images in below code. For grouping I am using array arrInt[] which has many values of(0,1,2). Based on arrInt values, all 0's, 1

Solution 1:

In

 nodes.forEach(function(o, i) {
    o.y += i & 1 ? k : -k;
    o.x += i & 2 ? k : -k;

  });

You are using the index i for clustering... this won't work, you want to use arrInt[i] instead:

 nodes.forEach(function(o, i) {
    o.y += arrInt[i] & 1 ? k : -k;
    o.x += arrInt[i] & 2 ? k : -k;
  });

Post a Comment for "Grouping Nodes In D3.js In Multiforce Layout"