a lot of what I've read regarding d3.js and tooltips makes reference to having individual points on a graph.
instead, my graph graph is using one long path to render. I was wondering how I would apply mouseover methods to such a path, where I would then tie a tooltip div accordingly
http://jsfiddle.net/ericps/xJ3Ke/6/
svg.append("path")
.attr("class", "area")
.attr("clip-path", "url(#clip)")
.style("fill", "url(#gradient)");
Below is a simple Tooltip class I used.
Usage (assuming you have
countries
data series withdate
on X andshare
on Y):Note make sure you prepare tooltip after other things on the chart or it will not be visible. Also make sure you have enough room on the right of the chart (e.g. set right margin of the chart to 100 or more).
You can set a layer of invisible objects representing each point you'd like to have a tooltip for, and add mouse interactions to those objects.
I've updated your jsfiddle with the following -
This adds a circle element to each data point, and a title element to each of those circles. Note that the
"pointer-events","all"
allows the mouse interactions even though the elements are invisiblefull jsfiddle here: http://jsfiddle.net/xJ3Ke/9/