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

  • SEARCH
  • Home
  • 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 9232641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:21:44+00:00 2026-06-18T06:21:44+00:00

here is my code : I want multiple dendograms for each topic of many

  • 0

here is my code : I want multiple dendograms for each topic of many email threads in one page:

var w = 1350, h;
var margin = {top: 20, right: 120, bottom: 20, left: 120}
var tree = d3.layout.tree();
//.size([h, w - 160]);

var diagonal = d3.svg.diagonal().projection(function(d) {
    return [d.y, d.x];
});

//  .attr("width", w + 200)
//  .attr("height", h + 160)
//.append("svg:g")
//  .attr("transform", "translate(40, 0)");

d3.json("flare2.json", function(error, json) {
    for (var tree_key in json.children) {

        build_tree(json.children[tree_key])
    }

});

function build_tree(tree_obj) {
    var vis = d3.select("#chart").append("svg:svg")
    h = 20
    h = h + (tree_obj.count * 15)
    tree.size([h, w]);

    vis.attr("width", w +1000)
        .attr("height", h)
    var nodes = tree.nodes(tree_obj);

    var link = vis.selectAll("path.link").data(tree.links(nodes)).enter().append("svg:path").attr("class", "link").attr("d", diagonal);
    // .attr("d", diagonal);

    var node = vis.selectAll("g.node").data(nodes).enter().append("svg:g").attr("class", "node").attr("transform", function(d) {
        return "translate(" + d.y + "," + d.x + ")";
    })

    node.append("svg:circle").attr("r", 4.5);

    node.append("svg:text").attr("dx", function(d) {
        return d.children ? -8 : 8;
    }).attr("dy", 3).attr("text-anchor", function(d) {
        return d.children ? "end" : "start";
    }).text(function(d) {
        return d.name;
    });
}

resulting this :

Root topics hidden partially

I don’t know how to make them appear , i tried translating and it do not work.

Here is the result of svg nodes:

<svg width="2350" height="170"><path class="link" d="M0,85C225,85 225,17 450,17"></path><path class="link" d="M0,85C225,85 225,85 450,85"></path><path class="link" d="M0,85C225,85 225,153 450,153"></path><path class="link" d="M450,17C675,17 675,17 900,17"></path><path class="link" d="M900,17C1125,17 1125,17 1350,17"></path><path class="link" d="M450,85C675,85 675,85 900,85"></path><path class="link" d="M900,85C1125,85 1125,85 1350,85"></path><path class="link" d="M450,153C675,153 675,153 900,153"></path><path class="link" d="M900,153C1125,153 1125,153 1350,153"></path><g class="node" transform="translate(0,85)"><circle r="4.5"></circle><text dx="-8" dy="3" text-anchor="end">Re: Amusing atheists and anarchists</text></g><g class="node" transform="translate(450,17)"><circle r="4.5"></circle><text dx="-8" dy="3" text-anchor="end">Re: Amusing atheists and anarchists</text></g><g class="node" transform="translate(900,17)"><circle r="4.5"></circle><text dx="-8" dy="3" text-anchor="end">timmbake@mcl.ucsb.edu (Bake Timmons)</text></g><g class="node" transform="translate(1350,17)"><circle r="4.5"></circle><text dx="8" dy="3" text-anchor="start">alt.atheism</text></g><g class="node" transform="translate(450,85)"><circle r="4.5"></circle><text dx="-8" dy="3" text-anchor="end">Hard/Soft == Strong/Weak.  KISS!</text></g><g class="node" transform="translate(900,85)"><circle r="4.5"></circle><text dx="-8" dy="3" text-anchor="end">mam@mouse.cmhnet.org (Mike McAngus)</text></g><g class="node" transform="translate(1350,85)"><circle r="4.5"></circle><text dx="8" dy="3" text-anchor="start">alt.atheism</text></g><g class="node" transform="translate(450,153)"><circle r="4.5"></circle><text dx="-8" dy="3" text-anchor="end">Re: Amusing atheists and anarchists</text></g><g class="node" transform="translate(900,153)"><circle r="4.5"></circle><text dx="-8" dy="3" text-anchor="end">mccullou@snake2.cs.wisc.edu (Mark McCullough)</text></g><g class="node" transform="translate(1350,153)"><circle r="4.5"></circle><text dx="8" dy="3" text-anchor="start">alt.atheism</text></g></svg>
  • 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-18T06:21:45+00:00Added an answer on June 18, 2026 at 6:21 am

    As nobody can help here is the functioning code:

    function build_tree(tree_obj,is_diagonal) {
        var height = tree_obj.count * 10
        var cluster = d3.layout.tree().size([height, width - 300]);
    
        var diagonal = d3.svg.diagonal().projection(function(d) {
            return [d.y, d.x];
        });
    
        var vis = d3.select("#chart").append("svg").attr("width", width).attr("height", height).append("g").attr("transform", "translate(40, 0)");
    
        var nodes = cluster.nodes(tree_obj);
        var link = vis.selectAll("path.link")
                        .data(cluster.links(nodes))
                        .enter().append("path")
                        .attr("class", "link")
        if (is_diagonal==true){
            link.attr("d", diagonal);
        } else {
            link.attr("d", elbow);
        };
    
        var node = vis.selectAll("g.node").data(nodes).enter().append("g").attr("class", "node").attr("transform", function(d) {
            return "translate(" + d.y + "," + d.x + ")";
        })
    
        node.append("circle").attr("r", 4.5);
    
        node.append("text").attr("dx", function(d) {
            return d.children ? -8 : 8;
        }).attr("dy", 3).attr("text-anchor", function(d) {
            return d.children ? "end" : "start";
        }).text(function(d) {
            return d.name;
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code, I have two checkboxes and want to keep one disabled
I want to add multiple View in a LinearLayout . Here is the code
enter code here Want to remove items from a Main list , but give
I'm programming Java in Eclipse IDE. Here is code I want to read file:
Here is my code : What i want is just to make scrollbar available
i just want to ask about my html code here, i have a bit
I'm using the code here and I want all the functions which call SDL
Just some example code here, but I have lists of strings that I want
I want to download and save pdf file to internal storage. Here is code
Here's my code, what I want to do is to be able to have

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.