2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Create a Scatterplot with SVG Circles
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Create a Scatterplot with SVG Circles
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-10-17 22:04:35 +05:30
|
|
|
### Hint 1
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-10-17 22:04:35 +05:30
|
|
|
Use the ` data() `, ` enter() `, and ` append() ` methods.
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-10-17 22:04:35 +05:30
|
|
|
### Hint 2
|
|
|
|
|
|
|
|
Append circles in the ` append() ` method.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
2018-10-17 22:04:35 +05:30
|
|
|
|
|
|
|
Chain the following lines of code in the ` svg.selectAll("circle") ` chain:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
.data(dataset)
|
|
|
|
.enter()
|
|
|
|
.append("circle")
|
|
|
|
```
|
|
|
|
|
|
|
|
The ` svg.selectAll("circle") ` chain should look like:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
svg.selectAll("circle")
|
|
|
|
.data(dataset)
|
|
|
|
.enter()
|
|
|
|
.append("circle")
|
|
|
|
```
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
**Note:** The circles won't be visible because we haven't set their attributes yet. We'll do that in the next challenge.
|
|
|
|
</details>
|