MCPcopy
hub / github.com/jipegit/OSXAuditor / pack

Function pack

d3-3.2.8/d3.js:6279–6300  ·  view source on GitHub ↗
(d, i)

Source from the content-addressed store, hash-verified

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 = _;

Callers 1

pack-test.jsFile · 0.85

Calls 3

d3_layout_treeVisitAfterFunction · 0.85
d3_layout_packTransformFunction · 0.85
rFunction · 0.70

Tested by

no test coverage detected