ノードをクリックすると、ノードが大きくなり、ノードが大きくなったので、他のノードをさらに反発させたいと思います。ノードの充電を変更するにはどうすればよいですか?
コードの抜粋:
[...]
//draw new graph
d3.json(file, function(error, graph) {
force
.nodes(graph.nodes)
.links(graph.links)
.start();
var nodeCircle = node.append("circle")
.attr("id", function(d) { return "node"+d.id })
.attr("class", function(d) {return "node "+d.nodeclass; })
.attr("r", 8) // R = Radius of node
.style("fill", function(d) { return d.color; }) // Will overwrite CSS style
.on("click",function(d) {
//When CTRL key is pressed ....
if (d3.event.ctrlKey) {
if(d3.select(this).attr('r')==8){
d3.select(this).attr('r', 12);
//ToDo: node Charge = -1000
}else{
d3.select(this).attr('r', 8);
//ToDo: node Charge = -500
}
}
}).call(force.drag);
[...]