(d, i)
| 5953 | d3.layout.pack = function() { |
| 5954 | var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ]; |
| 5955 | function pack(d, i) { |
| 5956 | var nodes = hierarchy.call(this, d, i), root = nodes[0]; |
| 5957 | root.x = 0; |
| 5958 | root.y = 0; |
| 5959 | d3_layout_treeVisitAfter(root, function(d) { |
| 5960 | d.r = Math.sqrt(d.value); |
| 5961 | }); |
| 5962 | d3_layout_treeVisitAfter(root, d3_layout_packSiblings); |
| 5963 | var w = size[0], h = size[1], k = Math.max(2 * root.r / w, 2 * root.r / h); |
| 5964 | if (padding > 0) { |
| 5965 | var dr = padding * k / 2; |
| 5966 | d3_layout_treeVisitAfter(root, function(d) { |
| 5967 | d.r += dr; |
| 5968 | }); |
| 5969 | d3_layout_treeVisitAfter(root, d3_layout_packSiblings); |
| 5970 | d3_layout_treeVisitAfter(root, function(d) { |
| 5971 | d.r -= dr; |
| 5972 | }); |
| 5973 | k = Math.max(2 * root.r / w, 2 * root.r / h); |
| 5974 | } |
| 5975 | d3_layout_packTransform(root, w / 2, h / 2, 1 / k); |
| 5976 | return nodes; |
| 5977 | } |
| 5978 | pack.size = function(x) { |
| 5979 | if (!arguments.length) return size; |
| 5980 | size = x; |
nothing calls this directly
no test coverage detected