()
| 13627 | } |
| 13628 | |
| 13629 | function partition() { |
| 13630 | var dx = 1, |
| 13631 | dy = 1, |
| 13632 | padding = 0, |
| 13633 | round = false; |
| 13634 | |
| 13635 | function partition(root) { |
| 13636 | var n = root.height + 1; |
| 13637 | root.x0 = |
| 13638 | root.y0 = padding; |
| 13639 | root.x1 = dx; |
| 13640 | root.y1 = dy / n; |
| 13641 | root.eachBefore(positionNode(dy, n)); |
| 13642 | if (round) root.eachBefore(roundNode); |
| 13643 | return root; |
| 13644 | } |
| 13645 | |
| 13646 | function positionNode(dy, n) { |
| 13647 | return function(node) { |
| 13648 | if (node.children) { |
| 13649 | treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n); |
| 13650 | } |
| 13651 | var x0 = node.x0, |
| 13652 | y0 = node.y0, |
| 13653 | x1 = node.x1 - padding, |
| 13654 | y1 = node.y1 - padding; |
| 13655 | if (x1 < x0) x0 = x1 = (x0 + x1) / 2; |
| 13656 | if (y1 < y0) y0 = y1 = (y0 + y1) / 2; |
| 13657 | node.x0 = x0; |
| 13658 | node.y0 = y0; |
| 13659 | node.x1 = x1; |
| 13660 | node.y1 = y1; |
| 13661 | }; |
| 13662 | } |
| 13663 | |
| 13664 | partition.round = function(x) { |
| 13665 | return arguments.length ? (round = !!x, partition) : round; |
| 13666 | }; |
| 13667 | |
| 13668 | partition.size = function(x) { |
| 13669 | return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy]; |
| 13670 | }; |
| 13671 | |
| 13672 | partition.padding = function(x) { |
| 13673 | return arguments.length ? (padding = +x, partition) : padding; |
| 13674 | }; |
| 13675 | |
| 13676 | return partition; |
| 13677 | } |
| 13678 | |
| 13679 | var preroot = {depth: -1}, |
| 13680 | ambiguous = {}, |
no test coverage detected