I have javascript / svg / d3js noob, but I “solved” this by placing a hypertext transparent rectangle above the text, this workaround is available as bl.ock .
nodeEnter .append("a") .attr("xlink:href", function (d) { return "http://www.example.com/flare/" + d.id; }) .append("rect") .attr("class", "clickable") .attr("y", -6) .attr("x", function (d) { return d.children || d._children ? -60 : 10; }) .attr("width", 50) //2*4.5) .attr("height", 12) .style("fill", "lightsteelblue") .style("fill-opacity", .3) // set to 1e-6 to make transparent ;
I added an extra clickable style and add .on("click", click) to the circle instead of the group element ( g ).
This works, but has the disadvantage that the size of the clickable rectangle is not the size of the label text.
I really look forward to a better solution, so +1 for your question!
Marijn
source share