我正在尝试将标签添加到此图表上的散点图:
http://bost.ocks.org/mike/d3/workshop/dot-chart.html
svg.selectAll(".dot") .append("text") .text("fooLabelsOfScatterPoints");
解决方法
迈克罗宾逊,你的榜样帮了忙.
对于那些想知道的人,这就是我所做的:
我删除了:
svg.selectAll(".dot") .data(data) .enter().append("circle") .attr("class","dot") .attr("cx",function(d) { return x(d.x); }) .attr("cy",function(d) { return y(d.y); }) .attr("r",12);
并补充说:
var node = svg.selectAll("g") .data(data) .enter() .append("g"); node.append("circle") .attr("class",12); node.append("text") .attr("x",function(d) { return x(d.x); }) .attr("y",function(d) { return y(d.y); }) .text("fooLabelsOfScatterPoints");