Accepted answer

This should help:

.on("mouseover", function(d)
.on("mouseout", function(d)


Learning d3 myself here - also thanks very much to juvian

I find a more transparent way of coding this would be to say

.on("mouseover", function(d) {"text").style("visibility", "visible") 

which selects the object you hover over (a group), selects the text inside it and changes the style to visible. This also avoids the need to make a labels variable which gets a bit messy with the array indexing.

Related Query