Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8750041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:47:47+00:00 2026-06-13T12:47:47+00:00

I am a complete novice at d3.js or java in general. I am using

  • 0

I am a complete novice at d3.js or java in general. I am using the indented tree example from http://bl.ocks.org/1093025. It took me two hours to get this to work on my local computer, so that should give you an idea of my skill level.

I opened the flare.json file and started messing with it and was able to manipulate it successfully. It looks like this

{
    "name": "Test D3",
    "children": [
        {
            "name": "News",
            "children": [
                {
                    "name": "CNN",
                    "size": 1000
                },
                {
                    "name": "BBC",
                    "size": 3812
                }
            ]
        },
        {
            "name": "Blogs",
            "children": [
                {
                    "name": "Engaget",
                    "size": 3938
                }
            ]
        },
        {
            "name": "Search",
            "children": [
                {
                    "name": "Google",
                    "size": 3938
                },
                {
                    "name": "Bing",
                    "size": 3938
                }
            ]
        }
    ]
}

What I want to do now, is to try to add hyperlinks. For example, I want to be able to click on “CNN” and go to CNN.com. Is there a modification I can make to flare.json that will do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:47:48+00:00Added an answer on June 13, 2026 at 12:47 pm

    It is quite easy, just add some more “key” : “value” pairs. Example:

            "children": [
                {
                    "name": "Google",
                    "size": 3938,
                    "url":  "https://www.google.com"
    
                },
                {
                    "name": "Bing",
                    "size": 3938,
                    "url":  "http://www.bing.com"
    
                }
            ]
    

    Of course, in your d3 code you then need to append <svg:a> tags and set their xlink:href attribute.

    Here is some html and d3-code that might be of help to you. First you need to import the xlink namespace in your html file:

    <html xmlns:xlink="http://www.w3.org/1999/xlink">
    ...
    </html>
    

    Then in the d3 drawing code where you append nodes for each data element you wrap the element you want to be clickable links with an svg:a tag:

    nodeEnter.append("svg:a")
      .attr("xlink:href", function(d){return d.url;})  // <-- reading the new "url" property
    .append("svg:rect")
      .attr("y", -barHeight / 2)
      .attr("height", barHeight)
      .attr("width", barWidth)
      .style("fill", color)
      .on("click", click);  // <- remove this if you like
    

    You might want to remove the click handler (which is present in the original example) by deleting the .on(“click”, click) as it might interfere with the default behavior of SVG links.

    Clicking on your rects should now lead you to the appropriate url.
    SVG links might not be fully implemented in all browsers.

    Alternatively you could modify the click handler to read the URL from d.url and use that one to manually redirect the browser to that URL via JavaScript: window.location = d.url;. Then you do not need the svg:a tag and the xlink code. Though adding a real link (not a scripted one) has the benefit that the user/browser can decide what to do (e.g., open in new tab/page). It also helps if some of your users have JavaScript disabled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Complete C++ i18n gettext() hello world example I changed the locale from es_MX
I am a complete novice when coming to using Flash but I am looking
Hi Im a complete novice when it coems to using JSP. Im trying to
I'm a complete perl novice, am running a perl script using perl 5.10 and
I'm a complete novice when it comes to SSL and security in general. I
Ok,so I'm a complete novice at programming and I just started coding in Java.
Experienced .Net developer but a complete ASP MVC (and web dev in general) novice.
So, to preface, I'm a complete novice at this Excel business. I've found similar
Preface: I consider myself slightly effective in ruby on rails, and a complete novice
Complete C++ i18n gettext() hello world example has C++ code that works for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.