sunny
sunny

Reputation: 3891

Assign hyperlink attribute to svg element not working

I am trying to follow the advice laid out in this post's answer and comments: Hyperlinks in d3.js objects to add hyperlinks to circles in a d3.js bubble graph. Here's where I am trying to do this, and here's the original bl.ock I am trying to modify. As you can see all I've done is the following:

  1. Replace <html> tag with: <html xmlns:xlink="http://www.w3.org/1999/xlink">
  2. Insert this code right after creation of var node

    node.append("svg:a"). attr("xlink:href", function(d){return "http://www.google.com";});

I am using Chrome and Firefox to test the page, and I don't see a hyperlink in either. Following some comments on the answer, I have tried:

  1. Removing the html namespace declaration
  2. Using node.append("a")

I don't see any results with any of these options, though I have been clearing my browser cache and using multiple computers to make sure I am seeing the fresh code. What am I doing wrong?

Upvotes: 0

Views: 77

Answers (1)

Robert Longson
Robert Longson

Reputation: 124059

The <a> has no content so it has no click area. You need to make something a child of the <a> nodes.

Upvotes: 1

Related Questions