score:5

Accepted answer

You want nested selections for this. Your code would look something like this.

var gs = d3.selectAll("g").data(data, function(d) { return d.id; });
gs.enter().append("g");

var line = d3.svg.line().x(function(d) { return xscale(d.timestamp); })
                        .y(function(d) { return yscale(d.value); });
gs.selectAll("path")
  .data(function(d) { return d.targets; }, function(d) { return d.idTarget; })
  .enter().append("path")
  .attr("d", function(d) { return line(d.events); });

Related Query

More Query from same tag