diff --git a/src/partition.js b/src/partition.js index 862b7ca6..269b12d9 100644 --- a/src/partition.js +++ b/src/partition.js @@ -5,10 +5,12 @@ export default function() { var dx = 1, dy = 1, padding = 0, - round = false; + round = false, + rootDepth = null; function partition(root) { var n = root.height + 1; + rootDepth = root.depth; root.x0 = root.y0 = padding; root.x1 = dx; @@ -21,7 +23,7 @@ export default function() { function positionNode(dy, n) { return function(node) { if (node.children) { - treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n); + treemapDice(node, node.x0, dy * (node.depth - rootDepth + 1) / n, node.x1, dy * (node.depth - rootDepth + 2) / n); } var x0 = node.x0, y0 = node.y0,