我第一次尝试使用D3js Hive图表,并且在理解如何将标签放置在每个轴上的节点旁边方面遇到了困难。请参见我的fiddle,链接如下:
http://jsfiddle.net/NovasTaylor/jgkqoasm/#base
使用这段代码,我可以将每个节点的标签放置在其正确的轴上。但是标签(名称)不靠近其相应的节点。我需要哪些代码才能将标签位置调整到节点旁边?
任何帮助都将不胜感激!
祝好,
Tim
nodes.append("text")
.attr("class", "text")
.text(function(d) {return d.name;})
// Following is needed to place E,F on the vertical axis toward the top
// of the graph (group=3)
.attr("y", function(d) {
if (d.group === 3) {
return -radius(d.y);
} else {
return radius(d.y);
}
})
.attr("transform", function(d) {
if (d.group !== 3) {
return "rotate(" + (degrees(angle(d.group)) - 90) + ")";
}
})
任何帮助都将不胜感激!
祝好,
Tim
translate
来定位组,这样就不需要在圆形上使用冗余的cx
属性和在文本上使用x
属性了。 - Mark