如何使用d3.js在力定向图中设置对数比例?
域的最小值和最大值 0.36 且 15926.29
以下是我的代码。
var hitsscale = d3.scale.log().base(10)
.domain([d3.min(nodes.filter(function(d){return d.group==1;}), function(d) { return d.value; }),
d3.max(nodes.filter(function(d){return d.group==1;}), function(d) { return d.value; })]);
d3.selectAll(".circle")
.append("circle")
.style("fill",function(d){return color(d.group);})
.attr("r",function(d){return hitsscale(d.value); })
.attr('class',function(d){
//return d.type + d.node_name.replace(/[^a-zA-Z0-9 ]/gi, "");
return d.type + d.node_name.replace(/[^a-zA-Z0-9 ]/gi, "") +" "+"A"+d.value.toString().replace('.',"");
})
;
我将对数刻度设置为力导向图中的半径。主要问题是圆圈不可见。