Loredra L
Loredra L

Reputation: 1553

D3 selection variable reuse after append

this might sound totally noob but I am confused about:

var link1=container.append("g").selectAll(".link")
    .data(graph.links)
      .enter().append("line")

If I use link1 again, would it append another "g" and "line" instead of just choosing them?

Or do i have to do something like link.select....

Upvotes: 1

Views: 43

Answers (1)

Seemant Kulleen
Seemant Kulleen

Reputation: 131

link1 gets assigned to the results of the right hand side, not the right-hand-side as you've typed it. So it'll point to the "line" that got created.

Upvotes: 1

Related Questions