MCPcopy Create free account
hub / github.com/idank/explainshell / pack

Function pack

explainshell/web/static/js/d3.v3.js:5955–5977  ·  view source on GitHub ↗
(d, i)

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 3

d3_layout_treeVisitAfterFunction · 0.85
d3_layout_packTransformFunction · 0.85
callMethod · 0.45

Tested by

no test coverage detected