1

(I'm a d3js newbie)

I'm using the d3.layout.force to visualize a graph of nodes that are divided into clusters, basically something like this (even if in my version every cluster's node keep the gravity focus set to its cluster's center):

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

What I'd like to accomplish is to keep each cluster separated from the other with a MIN distance.

I set random points for each cluster center at initial stage:

for(var i = 0; i < clusterLength; i++) {
    var baseX = 3
    var baseY = 7

    var x = halton(i + 1, baseX) * width + (Math.random() * 50)
    var y = halton(i + 1, baseY) * height + (Math.random() * 50)     

    clusterCoords.push({ 
      x: x,
      y: y
    })

    j += 1
  }

Then I'd like to be able to reposition each cluster keeping a distance between the others.

Hope it's clear.

1 Answer 1

3

This is what the padding variable is used for in the mbostock example.

See my example with padding set to 30: http://bl.ocks.org/mccannf/5548435

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.