d3.js - set links size to a force layout -


based on "molecule" example of michael bostock, available @ url : http://bl.ocks.org/mbostock/3037015.

i'm trying set size of links several values. that, disabled "gravity", put important negative value in "charge" , fixed first node center of window.

var force = d3.layout.force()     .size([width, height])     .charge(-800)     .friction(0.45)     .linkstrength(1)     .gravity(0)     .linkdistance(function(d) {          return radius(d.target.size * 10);      }); 

my problem (as can see on image below) size of links differents, links defined little value.

does know 1 solution problem?

you can see code here : http://jsfiddle.net/awpn3/

it's characteristic of force layout length of links variable -- point nodes laid out automatically , don't have worry it. implement checks make sure distances want them be, quite difficult.

the linkdistance function you're using direct way (weakly) enforce such constraint. if that's not enough, there's no easy way of mitigating it. option implement checks i've mentioned above @ each tick of simulation.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -