In this example, how can I make the text of each node to be a clickable link?
I tried something similar to this code, but the values were not clickable:
var links = text.append("a").attr("xlink:href", "http://www.google.com/");
// A copy of the text with a thick white stroke for legibility.
links.append("svg:text")
.attr("x", 8)
.attr("y", ".31em")
.attr("class", "shadow")
.text(function(d) { return d.name; });
links.append("svg:text")
.attr("x", 8)
.attr("y", ".31em")
.text(function(d) { return d.name; });
EDIT / SOLUTION: turns out the css had this attriubte: pointer-events: none;
I had to delete it and then use as Elijah suggested.
Don’t use links, drop it and append directly to your text
<g>and it should work.Also, if you want to pass the bound data, you’d do that like this:
Whereas if you want to pass the actual d object, you can do it like this:
In which case yourFunction(d,i) can then reference d.whatever from your bound data.