-1

the dataset is a json file like this [{from: x, to: y}, {from: x, to: z}] and so on.

    partitioned_data = d3.partition().size([2*Math.PI, 100]);
    root_node = d3.hierarchy(data).sum(d => d.size);
    partitioned_data(root_node); 

this is what I have so far

I'm getting this as the root node: root node

... and root_node.children is still undefined. I'm using an example dataset which is just 99->77, 77->112 and 112->82. I want it to give a hierarchy of root_node = 99 and root_node.children[0] = 77 and so on.

1 Answers1

3

There is a reason why you cannot convert your email data into an hierarchical one:

Your data represents a linked non-hierarchical graph, where every node can be linked to everyone else.

The d3.hierarchy requires data, where each node can have only one parent and no loops allowed. If you identify the parent by fromId, the child by toId, and your data looks like this:

[
  {fromId: 1, toId: 2},
  {fromId: 2, toId: 3},
  {fromId: 3, toId: 1},
]

... you have a link loop and cannot create an hierarchy from that data.

Michael Rovinsky
  • 6,807
  • 7
  • 15
  • 30