Reputation: 44308
I am not sure why my click method is not working. In this test I want to be able to click on one of the circle nodes on the graph and display its number. Hovering over works kind of.
What library's click event am I using, D3? Jquery? normal JS?
ultimately I want to do tooltips when I hover over the nodes, and make them go away when I move the mouse away
http://jsfiddle.net/ericps/b5v4R/
dots.enter()
.append("circle")
//.append("svg:circle")
.attr("class", "dot")
.attr("cx", complete_line.x())
.attr("cy", complete_line.y())
.attr("r",3.5)
.append("title")
.text(function(d){ return d.completed;})
.on("click", function(d) { alert("hello"); });
Upvotes: 1
Views: 21383
Reputation: 5233
You've attached the event handler to svg:text element. I think you want to attach it to the svg:circle element:
dots.enter().append("circle")
.attr("class", "dot")
.attr("cx", complete_line.x())
.attr("cy", complete_line.y())
.attr("r",3.5)
.on("click", function(d) { alert("hello"); })
.append("title")
.text(function(d){ return d.completed; });
Upvotes: 6