Creating a tooltip for a line in d3.js?

So as far as I can tell all tooltips are based getting a value from the attributes of the srcElement, but if I have a line that doesn’t have many paths, (as for example a bar chart, where every single bar has a path element) but instead only one, is there a nice way to create a tooltip in this case?

The only thing I could think of so far, was to split the d attribute required to create a line in order to get an array that is equal in length to the data I have. Then I get the current x-Value of my mouse, find the corresponding element in the array created from the d element and return the element of the data array that has the same index.

Somehow this doesn’t seem right, but I haven’t really been able to work it out with what I have found on google.

(just to clarify, with ‘d element’, I basically mean a string of this form: ‘M0,1L1,3.4L4,6L7,2L80…’)