2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Add a Hover Effect to a D3 Element
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Add a Hover Effect to a D3 Element
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-10-17 22:12:38 +05:30
|
|
|
### Hint 1
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-10-17 22:12:38 +05:30
|
|
|
Add the ` bar ` class to all `rect ` elements.
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-10-17 22:12:38 +05:30
|
|
|
### Hint 2
|
|
|
|
|
|
|
|
Use the ` attr() ` method to add attributes.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
2018-10-17 22:12:38 +05:30
|
|
|
|
|
|
|
Add the following line of code to the end of your ` rect ` methods chain:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
.attr("class","bar");
|
|
|
|
```
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
</details>
|