From 416cb7c75236d69befd03c3cb5172d61a1e0bd09 Mon Sep 17 00:00:00 2001 From: Ernest Okot Date: Sun, 4 Jun 2017 02:25:06 +0300 Subject: [PATCH] Fixes https://github.com/d3/d3-hierarchy/issues/91 (#1) --- src/partition.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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,