D3: Hyperlinks in tree diagram

后端 未结 1 1424
孤街浪徒
孤街浪徒 2021-01-07 05:29

I\'m having trouble hyperlinking child elements in a Reingold-Tifold tree graph. The graph is built in D3 and is based on the one that Mike Bostock uses an example: http://b

相关标签:
1条回答
  • 2021-01-07 06:14

    Seems you've made a slight mistake when creating your dataset url attribute, or you should've adapted the code you're using to add the xlink:href attribute to the a element. You're calling:

    .attr("xlink:href", function(d) { return d.url; })
    

    But in your dataset the attribute defined like this:

    "URL": "http://www.google.co.uk"
    

    Those don't match, you should change your code to this:

    .attr("xlink:href", function(d) { return d.URL; })
    

    Or your dataset to this:

     "url": "http://www.google.co.uk"
    

    Remember that names of JSON properties are case-sensitive.

    0 讨论(0)
提交回复
热议问题