1

d3.layout.partition automatically sorts children nodes in descending order by default. I'm using an icicle plot to show a binary tree where I want to keep the original tree structure without any node reordering. How do I create an array of nodes from my tree without the sort? My code sets the nodes as follows:

 var partition = d3.layout.partition()
.size([width, height])
.value(function(d) { return d.size; });
 var nodes= partition.nodes(root);
MaYa
  • 180
  • 7

1 Answers1

1

According to the API, when using partition.sort([comparator]):

A null comparator disables sorting and uses tree traversal order.

Thus, it should be:

var partition = d3.layout.partition()
    .size([width, height])
    .value(function(d) { return d.size; })
    .sort(null);
Gerardo Furtado
  • 100,839
  • 9
  • 121
  • 171