2017-03-23 55 views

回答

0

只是你的电话从循环往复到force.drag功能组,就像这样:

var nodes = svg.selectAll("g") 
    .data(d3.values(nodes)) 
    .enter() 
    .append("g") 
    .call(force.drag); // <= move that line here 

nodes.append("circle") 
    .attr("r", 10) 
    .style("fill", function (d, i) { return colors(i); }) 
    // .call(force.drag); // <= remove this line 

更新的小提琴是here

+0

thx。现在我看着它,是有道理的。 – Cmarv