(d, i)
| 6277 | d3.layout.pack = function() { |
| 6278 | var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius; |
| 6279 | function pack(d, i) { |
| 6280 | var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === "function" ? radius : function() { |
| 6281 | return radius; |
| 6282 | }; |
| 6283 | root.x = root.y = 0; |
| 6284 | d3_layout_treeVisitAfter(root, function(d) { |
| 6285 | d.r = +r(d.value); |
| 6286 | }); |
| 6287 | d3_layout_treeVisitAfter(root, d3_layout_packSiblings); |
| 6288 | if (padding) { |
| 6289 | var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2; |
| 6290 | d3_layout_treeVisitAfter(root, function(d) { |
| 6291 | d.r += dr; |
| 6292 | }); |
| 6293 | d3_layout_treeVisitAfter(root, d3_layout_packSiblings); |
| 6294 | d3_layout_treeVisitAfter(root, function(d) { |
| 6295 | d.r -= dr; |
| 6296 | }); |
| 6297 | } |
| 6298 | d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h)); |
| 6299 | return nodes; |
| 6300 | } |
| 6301 | pack.size = function(_) { |
| 6302 | if (!arguments.length) return size; |
| 6303 | size = _; |
no test coverage detected