score:3

Accepted answer

The problem is just the first line in this selection:

var circle = svg.selectAll("circle")
    .data(aNumCircles)
    .enter()
    .append("circle")
    //etc...

Since there are already circles in the SVG at the second time addpoints() runs, your "enter" selection will be empty.

Instead of that, it should be:

var circle = svg.selectAll(null)
    .data(aNumCircles)
    .enter()
    .append("circle")
    //etc...

By using selectAll(null) you can be completely sure that your "enter" selection has all the elements in your data array.

Here is the updated plunker: https://plnkr.co/edit/3u0er01thuj5P8e0XqO6?p=preview


Related Query

More Query from same tag