Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3js create a force layout with fixed nodes [closed]

i've implemented this http://jsbin.com/omokap/3/edit:

enter image description here

However, I would like to cancel the dynamic behavior of the graph (like in the dragend state, but that is only for the single node) and place the nodes in the set points, taken from json.

I've see this questions Moving fixed nodes in D3 and Fix Node Position in D3 Force-Directed Layout. I did not understand how to use them in my example.

can someone give me a help?

like image 574
Scorpy86 Avatar asked Jul 15 '13 14:07

Scorpy86


1 Answers

the solution is simple insert into the nodes object x,y coordinates and fixed:true like this

{ name: "Sara", id:"1", x:239.31191418045182, y:296.78520431471384, fixed:true},
{ name: "Raul", id:"2", x:261.1651006560272, y:200.78448049334696, fixed:true},
{ name: "Stefano", id:"3", fixed:false},
{ name: "Michele", id:"4", fixed:false}

this is a working example http://jsbin.com/omokap/8/edit please add yourself d3js library.

for my purpose works fine.

like image 50
Scorpy86 Avatar answered Oct 23 '22 14:10

Scorpy86