title: Plot multiple lines in a for loop in d3
body: <p>There are many cases online how to plot couple of lines in d3 if you add svg object only once, such as </p>
  
  <pre><code>   svg.selectAll("line")
     .data(dataset)
     .enter().append("line")
     .style("stroke", "black")  // colour the line
     .attr("x1", function(d) { console.log(d); return xScale(d.x1); })
     .attr("y1", function(d) { return yScale(d.y1); })
     .attr("x2", function(d) { return xScale(d.x2); })
     .attr("y2", function(d) { return yScale(d.y2); }); 
  </code></pre>
  
  <p>This plot create one line. I want to create many different lines in an array smth like </p>
  
  <pre><code>   var svg = d3.select("body")
     .append("svg")
     .attr("width", w)
     .attr("height", h);
  
     for (a_ind=1; a_ind&lt;3; a_ind++){
     dataset_a=dataset.filter(function(d) { return (d.a==a_ind)})
  
     svg.selectAll("line")
     .data(dataset_a) - //!!! using new dataset in each cycle
     .enter().append("line")
     .style("stroke", "black")  // colour the line
     .attr("x1", function(d) { console.log(d); return xScale(d.x1); })
     .attr("y1", function(d) { return yScale(d.y1); })
     .attr("x2", function(d) { return xScale(d.x2); })
     .attr("y2", function(d) { return yScale(d.y2); }); 
     }
  </code></pre>
  
  <p>I was told it's impossible. Or maybe there is the way? And also how to access then line from dataset_a if i want to delete it with the click of the mouse? </p>