【发布时间】:2018-09-01 19:01:06
【问题描述】:
我正在尝试在我的节点中添加标签,但这似乎不起作用。
//draw circles for the nodes
var node = g.append("g")
.attr("class", "nodes")
.selectAll("circle")
.data(nodes_data)
.enter()
.append("circle")
.attr("r", radius)
.attr("fill", circleColour);
node.append("text")
.attr("dx", 12)
.attr("dy", ".35em")
.text(function (d) { return d.name });
当我检查节点的元素时,我可以看到节点内的文本:
<circle r="15" fill="blue" style="touch-action: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);" cx="421.4930863434973" cy="221.26393165638473"><text dx="12" dy=".35em">some name</text></circle>
但它不会显示在图表中。任何人都可以在这里帮助我吗? 这是完整的 plunkr:
【问题讨论】:
标签: javascript angularjs d3.js charts