Update SCATTER_PLOT.md

notes
Matt Huntington 3 years ago committed by GitHub
parent 62169d918c
commit 93466db16f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1201,7 +1201,7 @@ change it to this:
```javascript ```javascript
d3.select('#points').html(''); d3.select('#points').html('');
var circles = d3.select('#points') const circles = d3.select('#points')
.selectAll('circle') .selectAll('circle')
.data(runs); .data(runs);
circles.enter().append('circle'); circles.enter().append('circle');
@ -1220,7 +1220,7 @@ If we click on the middle circle (2nd), it deletes the 2nd "run" object in the `
To avoid these affects, we need to make sure that each circle stays with the data it used to be assigned to when we call `render()`. To do this, we can tell D3 to map `<circles>` to datum by id, rather than index in the array. At the top of the `render()` function, find this code: To avoid these affects, we need to make sure that each circle stays with the data it used to be assigned to when we call `render()`. To do this, we can tell D3 to map `<circles>` to datum by id, rather than index in the array. At the top of the `render()` function, find this code:
```javascript ```javascript
var circles = d3.select('#points') const circles = d3.select('#points')
.selectAll('circle') .selectAll('circle')
.data(runs); .data(runs);
``` ```
@ -1228,9 +1228,9 @@ var circles = d3.select('#points')
Change it to this: Change it to this:
```javascript ```javascript
var circles = d3.select('#points') const circles = d3.select('#points')
.selectAll('circle') .selectAll('circle')
.data(runs, function(datum){ .data(runs, (datum)=>{
return datum.id return datum.id
}); });
``` ```

Loading…
Cancel
Save