Node-Red configuration
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

d3-hierarchy.js 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  1. // https://d3js.org/d3-hierarchy/ v3.1.2 Copyright 2010-2021 Mike Bostock
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  4. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  5. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}));
  6. })(this, (function (exports) { 'use strict';
  7. function defaultSeparation$1(a, b) {
  8. return a.parent === b.parent ? 1 : 2;
  9. }
  10. function meanX(children) {
  11. return children.reduce(meanXReduce, 0) / children.length;
  12. }
  13. function meanXReduce(x, c) {
  14. return x + c.x;
  15. }
  16. function maxY(children) {
  17. return 1 + children.reduce(maxYReduce, 0);
  18. }
  19. function maxYReduce(y, c) {
  20. return Math.max(y, c.y);
  21. }
  22. function leafLeft(node) {
  23. var children;
  24. while (children = node.children) node = children[0];
  25. return node;
  26. }
  27. function leafRight(node) {
  28. var children;
  29. while (children = node.children) node = children[children.length - 1];
  30. return node;
  31. }
  32. function cluster() {
  33. var separation = defaultSeparation$1,
  34. dx = 1,
  35. dy = 1,
  36. nodeSize = false;
  37. function cluster(root) {
  38. var previousNode,
  39. x = 0;
  40. // First walk, computing the initial x & y values.
  41. root.eachAfter(function(node) {
  42. var children = node.children;
  43. if (children) {
  44. node.x = meanX(children);
  45. node.y = maxY(children);
  46. } else {
  47. node.x = previousNode ? x += separation(node, previousNode) : 0;
  48. node.y = 0;
  49. previousNode = node;
  50. }
  51. });
  52. var left = leafLeft(root),
  53. right = leafRight(root),
  54. x0 = left.x - separation(left, right) / 2,
  55. x1 = right.x + separation(right, left) / 2;
  56. // Second walk, normalizing x & y to the desired size.
  57. return root.eachAfter(nodeSize ? function(node) {
  58. node.x = (node.x - root.x) * dx;
  59. node.y = (root.y - node.y) * dy;
  60. } : function(node) {
  61. node.x = (node.x - x0) / (x1 - x0) * dx;
  62. node.y = (1 - (root.y ? node.y / root.y : 1)) * dy;
  63. });
  64. }
  65. cluster.separation = function(x) {
  66. return arguments.length ? (separation = x, cluster) : separation;
  67. };
  68. cluster.size = function(x) {
  69. return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? null : [dx, dy]);
  70. };
  71. cluster.nodeSize = function(x) {
  72. return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? [dx, dy] : null);
  73. };
  74. return cluster;
  75. }
  76. function count(node) {
  77. var sum = 0,
  78. children = node.children,
  79. i = children && children.length;
  80. if (!i) sum = 1;
  81. else while (--i >= 0) sum += children[i].value;
  82. node.value = sum;
  83. }
  84. function node_count() {
  85. return this.eachAfter(count);
  86. }
  87. function node_each(callback, that) {
  88. let index = -1;
  89. for (const node of this) {
  90. callback.call(that, node, ++index, this);
  91. }
  92. return this;
  93. }
  94. function node_eachBefore(callback, that) {
  95. var node = this, nodes = [node], children, i, index = -1;
  96. while (node = nodes.pop()) {
  97. callback.call(that, node, ++index, this);
  98. if (children = node.children) {
  99. for (i = children.length - 1; i >= 0; --i) {
  100. nodes.push(children[i]);
  101. }
  102. }
  103. }
  104. return this;
  105. }
  106. function node_eachAfter(callback, that) {
  107. var node = this, nodes = [node], next = [], children, i, n, index = -1;
  108. while (node = nodes.pop()) {
  109. next.push(node);
  110. if (children = node.children) {
  111. for (i = 0, n = children.length; i < n; ++i) {
  112. nodes.push(children[i]);
  113. }
  114. }
  115. }
  116. while (node = next.pop()) {
  117. callback.call(that, node, ++index, this);
  118. }
  119. return this;
  120. }
  121. function node_find(callback, that) {
  122. let index = -1;
  123. for (const node of this) {
  124. if (callback.call(that, node, ++index, this)) {
  125. return node;
  126. }
  127. }
  128. }
  129. function node_sum(value) {
  130. return this.eachAfter(function(node) {
  131. var sum = +value(node.data) || 0,
  132. children = node.children,
  133. i = children && children.length;
  134. while (--i >= 0) sum += children[i].value;
  135. node.value = sum;
  136. });
  137. }
  138. function node_sort(compare) {
  139. return this.eachBefore(function(node) {
  140. if (node.children) {
  141. node.children.sort(compare);
  142. }
  143. });
  144. }
  145. function node_path(end) {
  146. var start = this,
  147. ancestor = leastCommonAncestor(start, end),
  148. nodes = [start];
  149. while (start !== ancestor) {
  150. start = start.parent;
  151. nodes.push(start);
  152. }
  153. var k = nodes.length;
  154. while (end !== ancestor) {
  155. nodes.splice(k, 0, end);
  156. end = end.parent;
  157. }
  158. return nodes;
  159. }
  160. function leastCommonAncestor(a, b) {
  161. if (a === b) return a;
  162. var aNodes = a.ancestors(),
  163. bNodes = b.ancestors(),
  164. c = null;
  165. a = aNodes.pop();
  166. b = bNodes.pop();
  167. while (a === b) {
  168. c = a;
  169. a = aNodes.pop();
  170. b = bNodes.pop();
  171. }
  172. return c;
  173. }
  174. function node_ancestors() {
  175. var node = this, nodes = [node];
  176. while (node = node.parent) {
  177. nodes.push(node);
  178. }
  179. return nodes;
  180. }
  181. function node_descendants() {
  182. return Array.from(this);
  183. }
  184. function node_leaves() {
  185. var leaves = [];
  186. this.eachBefore(function(node) {
  187. if (!node.children) {
  188. leaves.push(node);
  189. }
  190. });
  191. return leaves;
  192. }
  193. function node_links() {
  194. var root = this, links = [];
  195. root.each(function(node) {
  196. if (node !== root) { // Don’t include the root’s parent, if any.
  197. links.push({source: node.parent, target: node});
  198. }
  199. });
  200. return links;
  201. }
  202. function* node_iterator() {
  203. var node = this, current, next = [node], children, i, n;
  204. do {
  205. current = next.reverse(), next = [];
  206. while (node = current.pop()) {
  207. yield node;
  208. if (children = node.children) {
  209. for (i = 0, n = children.length; i < n; ++i) {
  210. next.push(children[i]);
  211. }
  212. }
  213. }
  214. } while (next.length);
  215. }
  216. function hierarchy(data, children) {
  217. if (data instanceof Map) {
  218. data = [undefined, data];
  219. if (children === undefined) children = mapChildren;
  220. } else if (children === undefined) {
  221. children = objectChildren;
  222. }
  223. var root = new Node$1(data),
  224. node,
  225. nodes = [root],
  226. child,
  227. childs,
  228. i,
  229. n;
  230. while (node = nodes.pop()) {
  231. if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
  232. node.children = childs;
  233. for (i = n - 1; i >= 0; --i) {
  234. nodes.push(child = childs[i] = new Node$1(childs[i]));
  235. child.parent = node;
  236. child.depth = node.depth + 1;
  237. }
  238. }
  239. }
  240. return root.eachBefore(computeHeight);
  241. }
  242. function node_copy() {
  243. return hierarchy(this).eachBefore(copyData);
  244. }
  245. function objectChildren(d) {
  246. return d.children;
  247. }
  248. function mapChildren(d) {
  249. return Array.isArray(d) ? d[1] : null;
  250. }
  251. function copyData(node) {
  252. if (node.data.value !== undefined) node.value = node.data.value;
  253. node.data = node.data.data;
  254. }
  255. function computeHeight(node) {
  256. var height = 0;
  257. do node.height = height;
  258. while ((node = node.parent) && (node.height < ++height));
  259. }
  260. function Node$1(data) {
  261. this.data = data;
  262. this.depth =
  263. this.height = 0;
  264. this.parent = null;
  265. }
  266. Node$1.prototype = hierarchy.prototype = {
  267. constructor: Node$1,
  268. count: node_count,
  269. each: node_each,
  270. eachAfter: node_eachAfter,
  271. eachBefore: node_eachBefore,
  272. find: node_find,
  273. sum: node_sum,
  274. sort: node_sort,
  275. path: node_path,
  276. ancestors: node_ancestors,
  277. descendants: node_descendants,
  278. leaves: node_leaves,
  279. links: node_links,
  280. copy: node_copy,
  281. [Symbol.iterator]: node_iterator
  282. };
  283. function optional(f) {
  284. return f == null ? null : required(f);
  285. }
  286. function required(f) {
  287. if (typeof f !== "function") throw new Error;
  288. return f;
  289. }
  290. function constantZero() {
  291. return 0;
  292. }
  293. function constant(x) {
  294. return function() {
  295. return x;
  296. };
  297. }
  298. // https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
  299. const a = 1664525;
  300. const c = 1013904223;
  301. const m = 4294967296; // 2^32
  302. function lcg() {
  303. let s = 1;
  304. return () => (s = (a * s + c) % m) / m;
  305. }
  306. function array(x) {
  307. return typeof x === "object" && "length" in x
  308. ? x // Array, TypedArray, NodeList, array-like
  309. : Array.from(x); // Map, Set, iterable, string, or anything else
  310. }
  311. function shuffle(array, random) {
  312. let m = array.length,
  313. t,
  314. i;
  315. while (m) {
  316. i = random() * m-- | 0;
  317. t = array[m];
  318. array[m] = array[i];
  319. array[i] = t;
  320. }
  321. return array;
  322. }
  323. function enclose(circles) {
  324. return packEncloseRandom(circles, lcg());
  325. }
  326. function packEncloseRandom(circles, random) {
  327. var i = 0, n = (circles = shuffle(Array.from(circles), random)).length, B = [], p, e;
  328. while (i < n) {
  329. p = circles[i];
  330. if (e && enclosesWeak(e, p)) ++i;
  331. else e = encloseBasis(B = extendBasis(B, p)), i = 0;
  332. }
  333. return e;
  334. }
  335. function extendBasis(B, p) {
  336. var i, j;
  337. if (enclosesWeakAll(p, B)) return [p];
  338. // If we get here then B must have at least one element.
  339. for (i = 0; i < B.length; ++i) {
  340. if (enclosesNot(p, B[i])
  341. && enclosesWeakAll(encloseBasis2(B[i], p), B)) {
  342. return [B[i], p];
  343. }
  344. }
  345. // If we get here then B must have at least two elements.
  346. for (i = 0; i < B.length - 1; ++i) {
  347. for (j = i + 1; j < B.length; ++j) {
  348. if (enclosesNot(encloseBasis2(B[i], B[j]), p)
  349. && enclosesNot(encloseBasis2(B[i], p), B[j])
  350. && enclosesNot(encloseBasis2(B[j], p), B[i])
  351. && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
  352. return [B[i], B[j], p];
  353. }
  354. }
  355. }
  356. // If we get here then something is very wrong.
  357. throw new Error;
  358. }
  359. function enclosesNot(a, b) {
  360. var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
  361. return dr < 0 || dr * dr < dx * dx + dy * dy;
  362. }
  363. function enclosesWeak(a, b) {
  364. var dr = a.r - b.r + Math.max(a.r, b.r, 1) * 1e-9, dx = b.x - a.x, dy = b.y - a.y;
  365. return dr > 0 && dr * dr > dx * dx + dy * dy;
  366. }
  367. function enclosesWeakAll(a, B) {
  368. for (var i = 0; i < B.length; ++i) {
  369. if (!enclosesWeak(a, B[i])) {
  370. return false;
  371. }
  372. }
  373. return true;
  374. }
  375. function encloseBasis(B) {
  376. switch (B.length) {
  377. case 1: return encloseBasis1(B[0]);
  378. case 2: return encloseBasis2(B[0], B[1]);
  379. case 3: return encloseBasis3(B[0], B[1], B[2]);
  380. }
  381. }
  382. function encloseBasis1(a) {
  383. return {
  384. x: a.x,
  385. y: a.y,
  386. r: a.r
  387. };
  388. }
  389. function encloseBasis2(a, b) {
  390. var x1 = a.x, y1 = a.y, r1 = a.r,
  391. x2 = b.x, y2 = b.y, r2 = b.r,
  392. x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1,
  393. l = Math.sqrt(x21 * x21 + y21 * y21);
  394. return {
  395. x: (x1 + x2 + x21 / l * r21) / 2,
  396. y: (y1 + y2 + y21 / l * r21) / 2,
  397. r: (l + r1 + r2) / 2
  398. };
  399. }
  400. function encloseBasis3(a, b, c) {
  401. var x1 = a.x, y1 = a.y, r1 = a.r,
  402. x2 = b.x, y2 = b.y, r2 = b.r,
  403. x3 = c.x, y3 = c.y, r3 = c.r,
  404. a2 = x1 - x2,
  405. a3 = x1 - x3,
  406. b2 = y1 - y2,
  407. b3 = y1 - y3,
  408. c2 = r2 - r1,
  409. c3 = r3 - r1,
  410. d1 = x1 * x1 + y1 * y1 - r1 * r1,
  411. d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2,
  412. d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3,
  413. ab = a3 * b2 - a2 * b3,
  414. xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1,
  415. xb = (b3 * c2 - b2 * c3) / ab,
  416. ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1,
  417. yb = (a2 * c3 - a3 * c2) / ab,
  418. A = xb * xb + yb * yb - 1,
  419. B = 2 * (r1 + xa * xb + ya * yb),
  420. C = xa * xa + ya * ya - r1 * r1,
  421. r = -(Math.abs(A) > 1e-6 ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
  422. return {
  423. x: x1 + xa + xb * r,
  424. y: y1 + ya + yb * r,
  425. r: r
  426. };
  427. }
  428. function place(b, a, c) {
  429. var dx = b.x - a.x, x, a2,
  430. dy = b.y - a.y, y, b2,
  431. d2 = dx * dx + dy * dy;
  432. if (d2) {
  433. a2 = a.r + c.r, a2 *= a2;
  434. b2 = b.r + c.r, b2 *= b2;
  435. if (a2 > b2) {
  436. x = (d2 + b2 - a2) / (2 * d2);
  437. y = Math.sqrt(Math.max(0, b2 / d2 - x * x));
  438. c.x = b.x - x * dx - y * dy;
  439. c.y = b.y - x * dy + y * dx;
  440. } else {
  441. x = (d2 + a2 - b2) / (2 * d2);
  442. y = Math.sqrt(Math.max(0, a2 / d2 - x * x));
  443. c.x = a.x + x * dx - y * dy;
  444. c.y = a.y + x * dy + y * dx;
  445. }
  446. } else {
  447. c.x = a.x + c.r;
  448. c.y = a.y;
  449. }
  450. }
  451. function intersects(a, b) {
  452. var dr = a.r + b.r - 1e-6, dx = b.x - a.x, dy = b.y - a.y;
  453. return dr > 0 && dr * dr > dx * dx + dy * dy;
  454. }
  455. function score(node) {
  456. var a = node._,
  457. b = node.next._,
  458. ab = a.r + b.r,
  459. dx = (a.x * b.r + b.x * a.r) / ab,
  460. dy = (a.y * b.r + b.y * a.r) / ab;
  461. return dx * dx + dy * dy;
  462. }
  463. function Node(circle) {
  464. this._ = circle;
  465. this.next = null;
  466. this.previous = null;
  467. }
  468. function packSiblingsRandom(circles, random) {
  469. if (!(n = (circles = array(circles)).length)) return 0;
  470. var a, b, c, n, aa, ca, i, j, k, sj, sk;
  471. // Place the first circle.
  472. a = circles[0], a.x = 0, a.y = 0;
  473. if (!(n > 1)) return a.r;
  474. // Place the second circle.
  475. b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0;
  476. if (!(n > 2)) return a.r + b.r;
  477. // Place the third circle.
  478. place(b, a, c = circles[2]);
  479. // Initialize the front-chain using the first three circles a, b and c.
  480. a = new Node(a), b = new Node(b), c = new Node(c);
  481. a.next = c.previous = b;
  482. b.next = a.previous = c;
  483. c.next = b.previous = a;
  484. // Attempt to place each remaining circle…
  485. pack: for (i = 3; i < n; ++i) {
  486. place(a._, b._, c = circles[i]), c = new Node(c);
  487. // Find the closest intersecting circle on the front-chain, if any.
  488. // “Closeness” is determined by linear distance along the front-chain.
  489. // “Ahead” or “behind” is likewise determined by linear distance.
  490. j = b.next, k = a.previous, sj = b._.r, sk = a._.r;
  491. do {
  492. if (sj <= sk) {
  493. if (intersects(j._, c._)) {
  494. b = j, a.next = b, b.previous = a, --i;
  495. continue pack;
  496. }
  497. sj += j._.r, j = j.next;
  498. } else {
  499. if (intersects(k._, c._)) {
  500. a = k, a.next = b, b.previous = a, --i;
  501. continue pack;
  502. }
  503. sk += k._.r, k = k.previous;
  504. }
  505. } while (j !== k.next);
  506. // Success! Insert the new circle c between a and b.
  507. c.previous = a, c.next = b, a.next = b.previous = b = c;
  508. // Compute the new closest circle pair to the centroid.
  509. aa = score(a);
  510. while ((c = c.next) !== b) {
  511. if ((ca = score(c)) < aa) {
  512. a = c, aa = ca;
  513. }
  514. }
  515. b = a.next;
  516. }
  517. // Compute the enclosing circle of the front chain.
  518. a = [b._], c = b; while ((c = c.next) !== b) a.push(c._); c = packEncloseRandom(a, random);
  519. // Translate the circles to put the enclosing circle around the origin.
  520. for (i = 0; i < n; ++i) a = circles[i], a.x -= c.x, a.y -= c.y;
  521. return c.r;
  522. }
  523. function siblings(circles) {
  524. packSiblingsRandom(circles, lcg());
  525. return circles;
  526. }
  527. function defaultRadius(d) {
  528. return Math.sqrt(d.value);
  529. }
  530. function index$1() {
  531. var radius = null,
  532. dx = 1,
  533. dy = 1,
  534. padding = constantZero;
  535. function pack(root) {
  536. const random = lcg();
  537. root.x = dx / 2, root.y = dy / 2;
  538. if (radius) {
  539. root.eachBefore(radiusLeaf(radius))
  540. .eachAfter(packChildrenRandom(padding, 0.5, random))
  541. .eachBefore(translateChild(1));
  542. } else {
  543. root.eachBefore(radiusLeaf(defaultRadius))
  544. .eachAfter(packChildrenRandom(constantZero, 1, random))
  545. .eachAfter(packChildrenRandom(padding, root.r / Math.min(dx, dy), random))
  546. .eachBefore(translateChild(Math.min(dx, dy) / (2 * root.r)));
  547. }
  548. return root;
  549. }
  550. pack.radius = function(x) {
  551. return arguments.length ? (radius = optional(x), pack) : radius;
  552. };
  553. pack.size = function(x) {
  554. return arguments.length ? (dx = +x[0], dy = +x[1], pack) : [dx, dy];
  555. };
  556. pack.padding = function(x) {
  557. return arguments.length ? (padding = typeof x === "function" ? x : constant(+x), pack) : padding;
  558. };
  559. return pack;
  560. }
  561. function radiusLeaf(radius) {
  562. return function(node) {
  563. if (!node.children) {
  564. node.r = Math.max(0, +radius(node) || 0);
  565. }
  566. };
  567. }
  568. function packChildrenRandom(padding, k, random) {
  569. return function(node) {
  570. if (children = node.children) {
  571. var children,
  572. i,
  573. n = children.length,
  574. r = padding(node) * k || 0,
  575. e;
  576. if (r) for (i = 0; i < n; ++i) children[i].r += r;
  577. e = packSiblingsRandom(children, random);
  578. if (r) for (i = 0; i < n; ++i) children[i].r -= r;
  579. node.r = e + r;
  580. }
  581. };
  582. }
  583. function translateChild(k) {
  584. return function(node) {
  585. var parent = node.parent;
  586. node.r *= k;
  587. if (parent) {
  588. node.x = parent.x + k * node.x;
  589. node.y = parent.y + k * node.y;
  590. }
  591. };
  592. }
  593. function roundNode(node) {
  594. node.x0 = Math.round(node.x0);
  595. node.y0 = Math.round(node.y0);
  596. node.x1 = Math.round(node.x1);
  597. node.y1 = Math.round(node.y1);
  598. }
  599. function treemapDice(parent, x0, y0, x1, y1) {
  600. var nodes = parent.children,
  601. node,
  602. i = -1,
  603. n = nodes.length,
  604. k = parent.value && (x1 - x0) / parent.value;
  605. while (++i < n) {
  606. node = nodes[i], node.y0 = y0, node.y1 = y1;
  607. node.x0 = x0, node.x1 = x0 += node.value * k;
  608. }
  609. }
  610. function partition() {
  611. var dx = 1,
  612. dy = 1,
  613. padding = 0,
  614. round = false;
  615. function partition(root) {
  616. var n = root.height + 1;
  617. root.x0 =
  618. root.y0 = padding;
  619. root.x1 = dx;
  620. root.y1 = dy / n;
  621. root.eachBefore(positionNode(dy, n));
  622. if (round) root.eachBefore(roundNode);
  623. return root;
  624. }
  625. function positionNode(dy, n) {
  626. return function(node) {
  627. if (node.children) {
  628. treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n);
  629. }
  630. var x0 = node.x0,
  631. y0 = node.y0,
  632. x1 = node.x1 - padding,
  633. y1 = node.y1 - padding;
  634. if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
  635. if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
  636. node.x0 = x0;
  637. node.y0 = y0;
  638. node.x1 = x1;
  639. node.y1 = y1;
  640. };
  641. }
  642. partition.round = function(x) {
  643. return arguments.length ? (round = !!x, partition) : round;
  644. };
  645. partition.size = function(x) {
  646. return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy];
  647. };
  648. partition.padding = function(x) {
  649. return arguments.length ? (padding = +x, partition) : padding;
  650. };
  651. return partition;
  652. }
  653. var preroot = {depth: -1},
  654. ambiguous = {},
  655. imputed = {};
  656. function defaultId(d) {
  657. return d.id;
  658. }
  659. function defaultParentId(d) {
  660. return d.parentId;
  661. }
  662. function stratify() {
  663. var id = defaultId,
  664. parentId = defaultParentId,
  665. path;
  666. function stratify(data) {
  667. var nodes = Array.from(data),
  668. currentId = id,
  669. currentParentId = parentId,
  670. n,
  671. d,
  672. i,
  673. root,
  674. parent,
  675. node,
  676. nodeId,
  677. nodeKey,
  678. nodeByKey = new Map;
  679. if (path != null) {
  680. const I = nodes.map((d, i) => normalize(path(d, i, data)));
  681. const P = I.map(parentof);
  682. const S = new Set(I).add("");
  683. for (const i of P) {
  684. if (!S.has(i)) {
  685. S.add(i);
  686. I.push(i);
  687. P.push(parentof(i));
  688. nodes.push(imputed);
  689. }
  690. }
  691. currentId = (_, i) => I[i];
  692. currentParentId = (_, i) => P[i];
  693. }
  694. for (i = 0, n = nodes.length; i < n; ++i) {
  695. d = nodes[i], node = nodes[i] = new Node$1(d);
  696. if ((nodeId = currentId(d, i, data)) != null && (nodeId += "")) {
  697. nodeKey = node.id = nodeId;
  698. nodeByKey.set(nodeKey, nodeByKey.has(nodeKey) ? ambiguous : node);
  699. }
  700. if ((nodeId = currentParentId(d, i, data)) != null && (nodeId += "")) {
  701. node.parent = nodeId;
  702. }
  703. }
  704. for (i = 0; i < n; ++i) {
  705. node = nodes[i];
  706. if (nodeId = node.parent) {
  707. parent = nodeByKey.get(nodeId);
  708. if (!parent) throw new Error("missing: " + nodeId);
  709. if (parent === ambiguous) throw new Error("ambiguous: " + nodeId);
  710. if (parent.children) parent.children.push(node);
  711. else parent.children = [node];
  712. node.parent = parent;
  713. } else {
  714. if (root) throw new Error("multiple roots");
  715. root = node;
  716. }
  717. }
  718. if (!root) throw new Error("no root");
  719. // When imputing internal nodes, only introduce roots if needed.
  720. // Then replace the imputed marker data with null.
  721. if (path != null) {
  722. while (root.data === imputed && root.children.length === 1) {
  723. root = root.children[0], --n;
  724. }
  725. for (let i = nodes.length - 1; i >= 0; --i) {
  726. node = nodes[i];
  727. if (node.data !== imputed) break;
  728. node.data = null;
  729. }
  730. }
  731. root.parent = preroot;
  732. root.eachBefore(function(node) { node.depth = node.parent.depth + 1; --n; }).eachBefore(computeHeight);
  733. root.parent = null;
  734. if (n > 0) throw new Error("cycle");
  735. return root;
  736. }
  737. stratify.id = function(x) {
  738. return arguments.length ? (id = optional(x), stratify) : id;
  739. };
  740. stratify.parentId = function(x) {
  741. return arguments.length ? (parentId = optional(x), stratify) : parentId;
  742. };
  743. stratify.path = function(x) {
  744. return arguments.length ? (path = optional(x), stratify) : path;
  745. };
  746. return stratify;
  747. }
  748. // To normalize a path, we coerce to a string, strip the trailing slash if any
  749. // (as long as the trailing slash is not immediately preceded by another slash),
  750. // and add leading slash if missing.
  751. function normalize(path) {
  752. path = `${path}`;
  753. let i = path.length;
  754. if (slash(path, i - 1) && !slash(path, i - 2)) path = path.slice(0, -1);
  755. return path[0] === "/" ? path : `/${path}`;
  756. }
  757. // Walk backwards to find the first slash that is not the leading slash, e.g.:
  758. // "/foo/bar" ⇥ "/foo", "/foo" ⇥ "/", "/" ↦ "". (The root is special-cased
  759. // because the id of the root must be a truthy value.)
  760. function parentof(path) {
  761. let i = path.length;
  762. if (i < 2) return "";
  763. while (--i > 1) if (slash(path, i)) break;
  764. return path.slice(0, i);
  765. }
  766. // Slashes can be escaped; to determine whether a slash is a path delimiter, we
  767. // count the number of preceding backslashes escaping the forward slash: an odd
  768. // number indicates an escaped forward slash.
  769. function slash(path, i) {
  770. if (path[i] === "/") {
  771. let k = 0;
  772. while (i > 0 && path[--i] === "\\") ++k;
  773. if ((k & 1) === 0) return true;
  774. }
  775. return false;
  776. }
  777. function defaultSeparation(a, b) {
  778. return a.parent === b.parent ? 1 : 2;
  779. }
  780. // function radialSeparation(a, b) {
  781. // return (a.parent === b.parent ? 1 : 2) / a.depth;
  782. // }
  783. // This function is used to traverse the left contour of a subtree (or
  784. // subforest). It returns the successor of v on this contour. This successor is
  785. // either given by the leftmost child of v or by the thread of v. The function
  786. // returns null if and only if v is on the highest level of its subtree.
  787. function nextLeft(v) {
  788. var children = v.children;
  789. return children ? children[0] : v.t;
  790. }
  791. // This function works analogously to nextLeft.
  792. function nextRight(v) {
  793. var children = v.children;
  794. return children ? children[children.length - 1] : v.t;
  795. }
  796. // Shifts the current subtree rooted at w+. This is done by increasing
  797. // prelim(w+) and mod(w+) by shift.
  798. function moveSubtree(wm, wp, shift) {
  799. var change = shift / (wp.i - wm.i);
  800. wp.c -= change;
  801. wp.s += shift;
  802. wm.c += change;
  803. wp.z += shift;
  804. wp.m += shift;
  805. }
  806. // All other shifts, applied to the smaller subtrees between w- and w+, are
  807. // performed by this function. To prepare the shifts, we have to adjust
  808. // change(w+), shift(w+), and change(w-).
  809. function executeShifts(v) {
  810. var shift = 0,
  811. change = 0,
  812. children = v.children,
  813. i = children.length,
  814. w;
  815. while (--i >= 0) {
  816. w = children[i];
  817. w.z += shift;
  818. w.m += shift;
  819. shift += w.s + (change += w.c);
  820. }
  821. }
  822. // If vi-’s ancestor is a sibling of v, returns vi-’s ancestor. Otherwise,
  823. // returns the specified (default) ancestor.
  824. function nextAncestor(vim, v, ancestor) {
  825. return vim.a.parent === v.parent ? vim.a : ancestor;
  826. }
  827. function TreeNode(node, i) {
  828. this._ = node;
  829. this.parent = null;
  830. this.children = null;
  831. this.A = null; // default ancestor
  832. this.a = this; // ancestor
  833. this.z = 0; // prelim
  834. this.m = 0; // mod
  835. this.c = 0; // change
  836. this.s = 0; // shift
  837. this.t = null; // thread
  838. this.i = i; // number
  839. }
  840. TreeNode.prototype = Object.create(Node$1.prototype);
  841. function treeRoot(root) {
  842. var tree = new TreeNode(root, 0),
  843. node,
  844. nodes = [tree],
  845. child,
  846. children,
  847. i,
  848. n;
  849. while (node = nodes.pop()) {
  850. if (children = node._.children) {
  851. node.children = new Array(n = children.length);
  852. for (i = n - 1; i >= 0; --i) {
  853. nodes.push(child = node.children[i] = new TreeNode(children[i], i));
  854. child.parent = node;
  855. }
  856. }
  857. }
  858. (tree.parent = new TreeNode(null, 0)).children = [tree];
  859. return tree;
  860. }
  861. // Node-link tree diagram using the Reingold-Tilford "tidy" algorithm
  862. function tree() {
  863. var separation = defaultSeparation,
  864. dx = 1,
  865. dy = 1,
  866. nodeSize = null;
  867. function tree(root) {
  868. var t = treeRoot(root);
  869. // Compute the layout using Buchheim et al.’s algorithm.
  870. t.eachAfter(firstWalk), t.parent.m = -t.z;
  871. t.eachBefore(secondWalk);
  872. // If a fixed node size is specified, scale x and y.
  873. if (nodeSize) root.eachBefore(sizeNode);
  874. // If a fixed tree size is specified, scale x and y based on the extent.
  875. // Compute the left-most, right-most, and depth-most nodes for extents.
  876. else {
  877. var left = root,
  878. right = root,
  879. bottom = root;
  880. root.eachBefore(function(node) {
  881. if (node.x < left.x) left = node;
  882. if (node.x > right.x) right = node;
  883. if (node.depth > bottom.depth) bottom = node;
  884. });
  885. var s = left === right ? 1 : separation(left, right) / 2,
  886. tx = s - left.x,
  887. kx = dx / (right.x + s + tx),
  888. ky = dy / (bottom.depth || 1);
  889. root.eachBefore(function(node) {
  890. node.x = (node.x + tx) * kx;
  891. node.y = node.depth * ky;
  892. });
  893. }
  894. return root;
  895. }
  896. // Computes a preliminary x-coordinate for v. Before that, FIRST WALK is
  897. // applied recursively to the children of v, as well as the function
  898. // APPORTION. After spacing out the children by calling EXECUTE SHIFTS, the
  899. // node v is placed to the midpoint of its outermost children.
  900. function firstWalk(v) {
  901. var children = v.children,
  902. siblings = v.parent.children,
  903. w = v.i ? siblings[v.i - 1] : null;
  904. if (children) {
  905. executeShifts(v);
  906. var midpoint = (children[0].z + children[children.length - 1].z) / 2;
  907. if (w) {
  908. v.z = w.z + separation(v._, w._);
  909. v.m = v.z - midpoint;
  910. } else {
  911. v.z = midpoint;
  912. }
  913. } else if (w) {
  914. v.z = w.z + separation(v._, w._);
  915. }
  916. v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
  917. }
  918. // Computes all real x-coordinates by summing up the modifiers recursively.
  919. function secondWalk(v) {
  920. v._.x = v.z + v.parent.m;
  921. v.m += v.parent.m;
  922. }
  923. // The core of the algorithm. Here, a new subtree is combined with the
  924. // previous subtrees. Threads are used to traverse the inside and outside
  925. // contours of the left and right subtree up to the highest common level. The
  926. // vertices used for the traversals are vi+, vi-, vo-, and vo+, where the
  927. // superscript o means outside and i means inside, the subscript - means left
  928. // subtree and + means right subtree. For summing up the modifiers along the
  929. // contour, we use respective variables si+, si-, so-, and so+. Whenever two
  930. // nodes of the inside contours conflict, we compute the left one of the
  931. // greatest uncommon ancestors using the function ANCESTOR and call MOVE
  932. // SUBTREE to shift the subtree and prepare the shifts of smaller subtrees.
  933. // Finally, we add a new thread (if necessary).
  934. function apportion(v, w, ancestor) {
  935. if (w) {
  936. var vip = v,
  937. vop = v,
  938. vim = w,
  939. vom = vip.parent.children[0],
  940. sip = vip.m,
  941. sop = vop.m,
  942. sim = vim.m,
  943. som = vom.m,
  944. shift;
  945. while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {
  946. vom = nextLeft(vom);
  947. vop = nextRight(vop);
  948. vop.a = v;
  949. shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
  950. if (shift > 0) {
  951. moveSubtree(nextAncestor(vim, v, ancestor), v, shift);
  952. sip += shift;
  953. sop += shift;
  954. }
  955. sim += vim.m;
  956. sip += vip.m;
  957. som += vom.m;
  958. sop += vop.m;
  959. }
  960. if (vim && !nextRight(vop)) {
  961. vop.t = vim;
  962. vop.m += sim - sop;
  963. }
  964. if (vip && !nextLeft(vom)) {
  965. vom.t = vip;
  966. vom.m += sip - som;
  967. ancestor = v;
  968. }
  969. }
  970. return ancestor;
  971. }
  972. function sizeNode(node) {
  973. node.x *= dx;
  974. node.y = node.depth * dy;
  975. }
  976. tree.separation = function(x) {
  977. return arguments.length ? (separation = x, tree) : separation;
  978. };
  979. tree.size = function(x) {
  980. return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]);
  981. };
  982. tree.nodeSize = function(x) {
  983. return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null);
  984. };
  985. return tree;
  986. }
  987. function treemapSlice(parent, x0, y0, x1, y1) {
  988. var nodes = parent.children,
  989. node,
  990. i = -1,
  991. n = nodes.length,
  992. k = parent.value && (y1 - y0) / parent.value;
  993. while (++i < n) {
  994. node = nodes[i], node.x0 = x0, node.x1 = x1;
  995. node.y0 = y0, node.y1 = y0 += node.value * k;
  996. }
  997. }
  998. var phi = (1 + Math.sqrt(5)) / 2;
  999. function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
  1000. var rows = [],
  1001. nodes = parent.children,
  1002. row,
  1003. nodeValue,
  1004. i0 = 0,
  1005. i1 = 0,
  1006. n = nodes.length,
  1007. dx, dy,
  1008. value = parent.value,
  1009. sumValue,
  1010. minValue,
  1011. maxValue,
  1012. newRatio,
  1013. minRatio,
  1014. alpha,
  1015. beta;
  1016. while (i0 < n) {
  1017. dx = x1 - x0, dy = y1 - y0;
  1018. // Find the next non-empty node.
  1019. do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);
  1020. minValue = maxValue = sumValue;
  1021. alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
  1022. beta = sumValue * sumValue * alpha;
  1023. minRatio = Math.max(maxValue / beta, beta / minValue);
  1024. // Keep adding nodes while the aspect ratio maintains or improves.
  1025. for (; i1 < n; ++i1) {
  1026. sumValue += nodeValue = nodes[i1].value;
  1027. if (nodeValue < minValue) minValue = nodeValue;
  1028. if (nodeValue > maxValue) maxValue = nodeValue;
  1029. beta = sumValue * sumValue * alpha;
  1030. newRatio = Math.max(maxValue / beta, beta / minValue);
  1031. if (newRatio > minRatio) { sumValue -= nodeValue; break; }
  1032. minRatio = newRatio;
  1033. }
  1034. // Position and record the row orientation.
  1035. rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
  1036. if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
  1037. else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
  1038. value -= sumValue, i0 = i1;
  1039. }
  1040. return rows;
  1041. }
  1042. var squarify = (function custom(ratio) {
  1043. function squarify(parent, x0, y0, x1, y1) {
  1044. squarifyRatio(ratio, parent, x0, y0, x1, y1);
  1045. }
  1046. squarify.ratio = function(x) {
  1047. return custom((x = +x) > 1 ? x : 1);
  1048. };
  1049. return squarify;
  1050. })(phi);
  1051. function index() {
  1052. var tile = squarify,
  1053. round = false,
  1054. dx = 1,
  1055. dy = 1,
  1056. paddingStack = [0],
  1057. paddingInner = constantZero,
  1058. paddingTop = constantZero,
  1059. paddingRight = constantZero,
  1060. paddingBottom = constantZero,
  1061. paddingLeft = constantZero;
  1062. function treemap(root) {
  1063. root.x0 =
  1064. root.y0 = 0;
  1065. root.x1 = dx;
  1066. root.y1 = dy;
  1067. root.eachBefore(positionNode);
  1068. paddingStack = [0];
  1069. if (round) root.eachBefore(roundNode);
  1070. return root;
  1071. }
  1072. function positionNode(node) {
  1073. var p = paddingStack[node.depth],
  1074. x0 = node.x0 + p,
  1075. y0 = node.y0 + p,
  1076. x1 = node.x1 - p,
  1077. y1 = node.y1 - p;
  1078. if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
  1079. if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
  1080. node.x0 = x0;
  1081. node.y0 = y0;
  1082. node.x1 = x1;
  1083. node.y1 = y1;
  1084. if (node.children) {
  1085. p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
  1086. x0 += paddingLeft(node) - p;
  1087. y0 += paddingTop(node) - p;
  1088. x1 -= paddingRight(node) - p;
  1089. y1 -= paddingBottom(node) - p;
  1090. if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
  1091. if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
  1092. tile(node, x0, y0, x1, y1);
  1093. }
  1094. }
  1095. treemap.round = function(x) {
  1096. return arguments.length ? (round = !!x, treemap) : round;
  1097. };
  1098. treemap.size = function(x) {
  1099. return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
  1100. };
  1101. treemap.tile = function(x) {
  1102. return arguments.length ? (tile = required(x), treemap) : tile;
  1103. };
  1104. treemap.padding = function(x) {
  1105. return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
  1106. };
  1107. treemap.paddingInner = function(x) {
  1108. return arguments.length ? (paddingInner = typeof x === "function" ? x : constant(+x), treemap) : paddingInner;
  1109. };
  1110. treemap.paddingOuter = function(x) {
  1111. return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
  1112. };
  1113. treemap.paddingTop = function(x) {
  1114. return arguments.length ? (paddingTop = typeof x === "function" ? x : constant(+x), treemap) : paddingTop;
  1115. };
  1116. treemap.paddingRight = function(x) {
  1117. return arguments.length ? (paddingRight = typeof x === "function" ? x : constant(+x), treemap) : paddingRight;
  1118. };
  1119. treemap.paddingBottom = function(x) {
  1120. return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant(+x), treemap) : paddingBottom;
  1121. };
  1122. treemap.paddingLeft = function(x) {
  1123. return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant(+x), treemap) : paddingLeft;
  1124. };
  1125. return treemap;
  1126. }
  1127. function binary(parent, x0, y0, x1, y1) {
  1128. var nodes = parent.children,
  1129. i, n = nodes.length,
  1130. sum, sums = new Array(n + 1);
  1131. for (sums[0] = sum = i = 0; i < n; ++i) {
  1132. sums[i + 1] = sum += nodes[i].value;
  1133. }
  1134. partition(0, n, parent.value, x0, y0, x1, y1);
  1135. function partition(i, j, value, x0, y0, x1, y1) {
  1136. if (i >= j - 1) {
  1137. var node = nodes[i];
  1138. node.x0 = x0, node.y0 = y0;
  1139. node.x1 = x1, node.y1 = y1;
  1140. return;
  1141. }
  1142. var valueOffset = sums[i],
  1143. valueTarget = (value / 2) + valueOffset,
  1144. k = i + 1,
  1145. hi = j - 1;
  1146. while (k < hi) {
  1147. var mid = k + hi >>> 1;
  1148. if (sums[mid] < valueTarget) k = mid + 1;
  1149. else hi = mid;
  1150. }
  1151. if ((valueTarget - sums[k - 1]) < (sums[k] - valueTarget) && i + 1 < k) --k;
  1152. var valueLeft = sums[k] - valueOffset,
  1153. valueRight = value - valueLeft;
  1154. if ((x1 - x0) > (y1 - y0)) {
  1155. var xk = value ? (x0 * valueRight + x1 * valueLeft) / value : x1;
  1156. partition(i, k, valueLeft, x0, y0, xk, y1);
  1157. partition(k, j, valueRight, xk, y0, x1, y1);
  1158. } else {
  1159. var yk = value ? (y0 * valueRight + y1 * valueLeft) / value : y1;
  1160. partition(i, k, valueLeft, x0, y0, x1, yk);
  1161. partition(k, j, valueRight, x0, yk, x1, y1);
  1162. }
  1163. }
  1164. }
  1165. function sliceDice(parent, x0, y0, x1, y1) {
  1166. (parent.depth & 1 ? treemapSlice : treemapDice)(parent, x0, y0, x1, y1);
  1167. }
  1168. var resquarify = (function custom(ratio) {
  1169. function resquarify(parent, x0, y0, x1, y1) {
  1170. if ((rows = parent._squarify) && (rows.ratio === ratio)) {
  1171. var rows,
  1172. row,
  1173. nodes,
  1174. i,
  1175. j = -1,
  1176. n,
  1177. m = rows.length,
  1178. value = parent.value;
  1179. while (++j < m) {
  1180. row = rows[j], nodes = row.children;
  1181. for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
  1182. if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += (y1 - y0) * row.value / value : y1);
  1183. else treemapSlice(row, x0, y0, value ? x0 += (x1 - x0) * row.value / value : x1, y1);
  1184. value -= row.value;
  1185. }
  1186. } else {
  1187. parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
  1188. rows.ratio = ratio;
  1189. }
  1190. }
  1191. resquarify.ratio = function(x) {
  1192. return custom((x = +x) > 1 ? x : 1);
  1193. };
  1194. return resquarify;
  1195. })(phi);
  1196. exports.Node = Node$1;
  1197. exports.cluster = cluster;
  1198. exports.hierarchy = hierarchy;
  1199. exports.pack = index$1;
  1200. exports.packEnclose = enclose;
  1201. exports.packSiblings = siblings;
  1202. exports.partition = partition;
  1203. exports.stratify = stratify;
  1204. exports.tree = tree;
  1205. exports.treemap = index;
  1206. exports.treemapBinary = binary;
  1207. exports.treemapDice = treemapDice;
  1208. exports.treemapResquarify = resquarify;
  1209. exports.treemapSlice = treemapSlice;
  1210. exports.treemapSliceDice = sliceDice;
  1211. exports.treemapSquarify = squarify;
  1212. Object.defineProperty(exports, '__esModule', { value: true });
  1213. }));