From 1eea9ec2bb1773d65cfcc73e55cb3a594c587f3d Mon Sep 17 00:00:00 2001 From: "Alex M. Sielicki" Date: Wed, 13 Apr 2016 18:45:17 +0000 Subject: [PATCH] Changing dendrogram node placement to take up all available space instead of being based on a fully expanded tree. Closes #611 --- .../js/timeseries-dendrogram.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/web-server/plugins/slycat-timeseries-model/js/timeseries-dendrogram.js b/web-server/plugins/slycat-timeseries-model/js/timeseries-dendrogram.js index ad30a69ee..c10ec16dd 100644 --- a/web-server/plugins/slycat-timeseries-model/js/timeseries-dendrogram.js +++ b/web-server/plugins/slycat-timeseries-model/js/timeseries-dendrogram.js @@ -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")