MCPcopy Create free account
hub / github.com/breck7/scroll / resquarify

Function resquarify

external/.d3.js:14278–14300  ·  view source on GitHub ↗
(parent, x0, y0, x1, y1)

Source from the content-addressed store, hash-verified

14276var resquarify = (function custom(ratio) {
14277
14278 function resquarify(parent, x0, y0, x1, y1) {
14279 if ((rows = parent._squarify) && (rows.ratio === ratio)) {
14280 var rows,
14281 row,
14282 nodes,
14283 i,
14284 j = -1,
14285 n,
14286 m = rows.length,
14287 value = parent.value;
14288
14289 while (++j < m) {
14290 row = rows[j], nodes = row.children;
14291 for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
14292 if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += (y1 - y0) * row.value / value : y1);
14293 else treemapSlice(row, x0, y0, value ? x0 += (x1 - x0) * row.value / value : x1, y1);
14294 value -= row.value;
14295 }
14296 } else {
14297 parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
14298 rows.ratio = ratio;
14299 }
14300 }
14301
14302 resquarify.ratio = function(x) {
14303 return custom((x = +x) > 1 ? x : 1);

Callers

nothing calls this directly

Calls 3

treemapDiceFunction · 0.85
treemapSliceFunction · 0.85
squarifyRatioFunction · 0.85

Tested by

no test coverage detected