score:0

When I tried the node solution, some of my data disappeared (?), so I just added a new class called "dodo" which worked for me:

svg.selectAll(".dot")
  .data(data)
 .enter().append("circle")
  .attr("class", "dot")
  .attr("r", 3.5)
  .attr("cx", function(d) { return x(d.time); })
  .attr("cy", function(d) { return y(d.place); })
  .style("fill", function(d) { return color(d.species); });

svg.selectAll(".dodo")
  .data(data)
 .enter().append("text")
  .attr("class", "dodo")
  .attr("x", function(d) { return x(d.time); })
  .attr("y", function(d) { return y(d.place); })
  .attr("dx", ".71em")
  .attr("dy", ".35em")
  .text(function(d) { return d.name;});

score:16

Mike Robinson, your example helped.

For those who are wondering, here is what I did:

I removed:

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);

and added:

var node = svg.selectAll("g")
                .data(data)
                .enter()
                .append("g");

node.append("circle")
  .attr("class", "dot")
  .attr("cx", function(d) { return x(d.x); })
  .attr("cy", function(d) { return y(d.y); })
  .attr("r", 12);

node.append("text")
  .attr("x", function(d) { return x(d.x); })
  .attr("y", function(d) { return y(d.y); })
  .text("fooLabelsOfScatterPoints");

I appended "text" tags onto "g" tags, as opposed to appending "text" tags onto "circle" tags.


Related Query

More Query from same tag