Added D3 solution (#19607)

* Update index.md

* Update index.md
This commit is contained in:
The Coding Aviator
2018-10-17 22:05:20 +05:30
committed by Aditya
parent f46e517eb7
commit 28eb17914a

View File

@ -3,8 +3,27 @@ title: Add a Tooltip to a D3 Element
---
## Add a Tooltip to a D3 Element
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/data-visualization/data-visualization-with-d3/add-a-tooltip-to-a-d3-element/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
### Hint 1
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
Use the ` .append() ` method.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
### Hint 2
Use the ` .text() ` method.
### Hint 3
Chain the ` .append() ` and ` .text() ` methods.
### Hint 4
Use a callback function in the ` .text() ` method.
### Solution
Chain the following lines of code with your ` svg.selectAll("rect") ` method.
```javascript
.append("title")
.text(d=>d);
```