The `<circle>` elements aren't be removed though. Let's put them in a `<g>` so that it's easy to clear out:
The `<circle>` elements aren't be removed though:
![]()
In the image above, it appears as though, there are only two circles, but really, the middle one has had its `cx` set to 800 and its `cy` set to 0. It's overlapping the other circle in the same position.
Let's put the circles in a `<g>` so that it's easy to clear out:
```html
<svg>
@ -710,43 +716,60 @@ The `<circle>` elements aren't be removed though. Let's put them in a `<g>` so
</svg>
```
Now we can clear out the `<circle>` elements each time `render()` is called.
Now we can clear out the `<circle>` elements each time `render()` is called. This is a little crude, but it'll work for now. Later on, we'll do things in a more elegant fashion.
```javascript
var render = function(){
d3.select('#points').html(''); //clear out all circles when rendering
d3.select('#points').selectAll('circle') //add circles to #points group, not svg
.data(runs)
.enter()
.append('circle');
// ==================================
// rest of render function code goes here...
// ==================================
}
render();
```
Let's put in a little code to handle when the user has deleted all runs and tries to add a new one:
![]()
If you try to delete all the circles and then add a new one, you'll get an error:
![]()
Inside the `<svg>` click handler, let's put in a little code to handle when the user has deleted all runs and tries to add a new one: