0
我有一个条形图和我在一些贴标(后已经有创建的酒吧)是这样的:D3选择在SVG对象的多个元素
svg.selectAll("text").data(labels).enter().append("text").text(function(d) { return d; })
.attr("text-anchor", "middle")
.attr("x", parseFloat(d3.selectAll("#bar").attr("x")) +
parseFloat(d3.selectAll("#bar").attr("width"))/2)
.attr("y", 90);
};
//when I am creating the bars using selectAll("rect").... at the end of the attr()
//function I have specified an id called bar so I can reference it later that way.
但这仅选择第一并将所有标签放在彼此的顶部。为什么是这样的,如何选择svg中的所有矩形?
你能否提供JS代码来绘制你的条形图以及你想添加为标签的文本到每一列? (如果我理解正确) – Fered