我很难在力图上放置文本标签。它们彼此重叠,我不知道如何解决它。而且我已经尝试了许多在线解决方案,但都没有一个很好的解决方案。你能帮我看看吗?
这是我的文本标签的代码:
var node_text = node_textNew.append("svg:text")
.attr("class", "text_note")
.attr("dx", 0)
.attr("dy", -0.5)
.attr('background-color', '#fff')
.attr("x", function(d, i) { return circleWidth + 5; })
.attr("y", function(d, i) { if (i>0) { return circleWidth + 0 } else { return 8 } })
.text(function(d) { return d.name});
现在的样子如下:
非常感谢你的帮助!
最佳答案
试试这个http://bl.ocks.org/MoritzStefaner/1377729。
在这里,作者介绍一种使用另一种力布局将标签放置在节点附近的方法。