I am new to D3.js
and currently developing a line chart
for one of my projects. I referred the documentation and example here and created my own version here.
Now, I am planning to add two interactive features here:
- On mouseover in the chart draw a vertical line to the nearest data point.
- Show a label with X and Y attributes next to this vertical line.
To make this features more clear, please refer this example.
Here is what I tried which came from a suggestion:
svg.append("g") // creating new 'group' element
.selectAll('rect') // adding a rectangle for the label
.selectAll('line'); // adding a line
However, the line ans rectangle doesnt show up. I have been Googling a lot but in no vain. What am I missing?