I\'d like to label points in a ggplot interactively, so that mousing over a point shows a label.
I\'m trying to adapt the answer given in this question so that it works
Thanks to tracy for a good question and Julius for the very helpful answer.
To make Julius's javascript work for me in Chrome and Safari, I had to replace this.id with this.correspondingUseElement.id. This makes sense because the single SVG element doesn't have an id for each geom_point, the id we want is attached to the elements.
Even that didn't work for me in Firefox, so I changed it to attach the event listener to the elements themselves. Note that if the SVG is more complicated, it might have s other than the geom_points, so I added an if to only attach the event to the geom_point.XX elements. This works in Chrome, Safari, and Firefox for me:
window.addEventListener("load",function(){
var es = document.getElementsByTagName("use");
for (i=0; i= 0) es[i].addEventListener("mouseover", f, false);
}
txt = (document.getElementById("text_place").getElementsByTagName("tspan"))[0];
},false);
(all other code same as Julius's)