Skip to content

Commit

Permalink
Changing dendrogram node placement to take up all available space ins…
Browse files Browse the repository at this point in the history
…tead of being based on a fully expanded tree. Closes #611
  • Loading branch information
alexsielicki committed Apr 13, 2016
1 parent a61ec29 commit 1eea9ec
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,19 @@ define("slycat-timeseries-dendrogram", ["d3"], function(d3)
// Compute the new layout.
var nodes = layout.nodes(root).reverse();

// Normalize for fixed-depth.
nodes.forEach(function(d) { if(d.children || d._children) d.y = d.depth * (diagram_width / max_depth); });
// Compute the currend dendrogram depth
var current_depth = -1;
nodes.forEach(function(d) {
current_depth = Math.max(current_depth, d.children ? d.depth : -1);
});

// Normalize for current depth.
nodes.forEach(function(d) {
if(d.children || d._children)
{
d.y = d.depth * (diagram_width / (current_depth+1));
}
});

// Update the nodes.
var node = vis.selectAll("g.node")
Expand Down

0 comments on commit 1eea9ec

Please sign in to comment.