@jbrowse/plugin-wiggle 4.1.3 → 4.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/esm/BigWigAdapter/BigWigAdapter.d.ts +14 -0
  2. package/esm/BigWigAdapter/BigWigAdapter.js +6 -0
  3. package/esm/BigWigAdapter/configSchema.d.ts +2 -2
  4. package/esm/DensityRenderer/configSchema.d.ts +2 -2
  5. package/esm/LinePlotRenderer/configSchema.d.ts +3 -3
  6. package/esm/LinearWiggleDisplay/configSchema.d.ts +6 -6
  7. package/esm/LinearWiggleDisplay/model.d.ts +24 -8
  8. package/esm/MultiDensityRenderer/configSchema.d.ts +2 -2
  9. package/esm/MultiLineRenderer/configSchema.d.ts +3 -3
  10. package/esm/MultiLinearWiggleDisplay/components/IndividualScaleBars.js +3 -2
  11. package/esm/MultiLinearWiggleDisplay/components/MultiWiggleColorLegend.d.ts +10 -0
  12. package/esm/MultiLinearWiggleDisplay/components/MultiWiggleColorLegend.js +29 -0
  13. package/esm/MultiLinearWiggleDisplay/components/MultiWiggleLegendBar.d.ts +7 -0
  14. package/esm/MultiLinearWiggleDisplay/components/MultiWiggleLegendBar.js +28 -0
  15. package/esm/MultiLinearWiggleDisplay/components/MultiWiggleLegendBarWrapper.d.ts +7 -0
  16. package/esm/MultiLinearWiggleDisplay/components/MultiWiggleLegendBarWrapper.js +18 -0
  17. package/esm/MultiLinearWiggleDisplay/components/RectBg.js +3 -1
  18. package/esm/MultiLinearWiggleDisplay/components/SvgTree.d.ts +5 -0
  19. package/esm/MultiLinearWiggleDisplay/components/SvgTree.js +19 -0
  20. package/esm/MultiLinearWiggleDisplay/components/TreeSidebar.d.ts +5 -0
  21. package/esm/MultiLinearWiggleDisplay/components/TreeSidebar.js +165 -0
  22. package/esm/MultiLinearWiggleDisplay/components/WiggleClusterDialog/WiggleClusterDialogAuto.js +2 -1
  23. package/esm/MultiLinearWiggleDisplay/components/WiggleClusterDialog/types.d.ts +2 -1
  24. package/esm/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.js +5 -2
  25. package/esm/MultiLinearWiggleDisplay/components/constants.d.ts +1 -0
  26. package/esm/MultiLinearWiggleDisplay/components/constants.js +1 -0
  27. package/esm/MultiLinearWiggleDisplay/components/treeTypes.d.ts +39 -0
  28. package/esm/MultiLinearWiggleDisplay/components/treeTypes.js +1 -0
  29. package/esm/MultiLinearWiggleDisplay/configSchema.d.ts +6 -6
  30. package/esm/MultiLinearWiggleDisplay/makeSidebarSvg.d.ts +9 -0
  31. package/esm/MultiLinearWiggleDisplay/makeSidebarSvg.js +13 -0
  32. package/esm/MultiLinearWiggleDisplay/model.d.ts +146 -25
  33. package/esm/MultiLinearWiggleDisplay/model.js +137 -5
  34. package/esm/MultiLinearWiggleDisplay/renderSvg.js +3 -1
  35. package/esm/MultiLinearWiggleDisplay/treeDrawingAutorun.d.ts +17 -0
  36. package/esm/MultiLinearWiggleDisplay/treeDrawingAutorun.js +77 -0
  37. package/esm/MultiQuantitativeTrack/configSchema.d.ts +8 -8
  38. package/esm/MultiRowLineRenderer/configSchema.d.ts +3 -3
  39. package/esm/MultiRowXYPlotRenderer/configSchema.d.ts +3 -3
  40. package/esm/MultiWiggleAdapter/MultiWiggleAdapter.d.ts +3 -0
  41. package/esm/MultiWiggleAdapter/MultiWiggleAdapter.js +5 -1
  42. package/esm/MultiWiggleAdapter/configSchema.d.ts +2 -2
  43. package/esm/MultiXYPlotRenderer/configSchema.d.ts +3 -3
  44. package/esm/QuantitativeTrack/configSchema.d.ts +8 -8
  45. package/esm/WiggleRPC/MultiWiggleClusterScoreMatrix.d.ts +4 -1
  46. package/esm/WiggleRPC/executeClusterScoreMatrix.d.ts +4 -1
  47. package/esm/WiggleRPC/executeClusterScoreMatrix.js +8 -2
  48. package/esm/XYPlotRenderer/configSchema.d.ts +3 -3
  49. package/esm/configSchema.d.ts +2 -2
  50. package/esm/d3-hierarchy2/accessors.d.ts +2 -0
  51. package/esm/d3-hierarchy2/accessors.js +8 -0
  52. package/esm/d3-hierarchy2/array.d.ts +2 -0
  53. package/esm/d3-hierarchy2/array.js +15 -0
  54. package/esm/d3-hierarchy2/cluster.d.ts +8 -0
  55. package/esm/d3-hierarchy2/cluster.js +63 -0
  56. package/esm/d3-hierarchy2/constant.d.ts +2 -0
  57. package/esm/d3-hierarchy2/constant.js +8 -0
  58. package/esm/d3-hierarchy2/hierarchy/ancestors.d.ts +1 -0
  59. package/esm/d3-hierarchy2/hierarchy/ancestors.js +7 -0
  60. package/esm/d3-hierarchy2/hierarchy/count.d.ts +1 -0
  61. package/esm/d3-hierarchy2/hierarchy/count.js +12 -0
  62. package/esm/d3-hierarchy2/hierarchy/descendants.d.ts +1 -0
  63. package/esm/d3-hierarchy2/hierarchy/descendants.js +3 -0
  64. package/esm/d3-hierarchy2/hierarchy/each.d.ts +1 -0
  65. package/esm/d3-hierarchy2/hierarchy/each.js +7 -0
  66. package/esm/d3-hierarchy2/hierarchy/eachAfter.d.ts +1 -0
  67. package/esm/d3-hierarchy2/hierarchy/eachAfter.js +15 -0
  68. package/esm/d3-hierarchy2/hierarchy/eachBefore.d.ts +1 -0
  69. package/esm/d3-hierarchy2/hierarchy/eachBefore.js +12 -0
  70. package/esm/d3-hierarchy2/hierarchy/find.d.ts +1 -0
  71. package/esm/d3-hierarchy2/hierarchy/find.js +8 -0
  72. package/esm/d3-hierarchy2/hierarchy/index.d.ts +3 -0
  73. package/esm/d3-hierarchy2/hierarchy/index.js +78 -0
  74. package/esm/d3-hierarchy2/hierarchy/iterator.d.ts +1 -0
  75. package/esm/d3-hierarchy2/hierarchy/iterator.js +14 -0
  76. package/esm/d3-hierarchy2/hierarchy/leaves.d.ts +1 -0
  77. package/esm/d3-hierarchy2/hierarchy/leaves.js +9 -0
  78. package/esm/d3-hierarchy2/hierarchy/links.d.ts +1 -0
  79. package/esm/d3-hierarchy2/hierarchy/links.js +9 -0
  80. package/esm/d3-hierarchy2/hierarchy/path.d.ts +1 -0
  81. package/esm/d3-hierarchy2/hierarchy/path.js +26 -0
  82. package/esm/d3-hierarchy2/hierarchy/sort.d.ts +1 -0
  83. package/esm/d3-hierarchy2/hierarchy/sort.js +7 -0
  84. package/esm/d3-hierarchy2/hierarchy/sum.d.ts +1 -0
  85. package/esm/d3-hierarchy2/hierarchy/sum.js +8 -0
  86. package/esm/d3-hierarchy2/index.d.ts +15 -0
  87. package/esm/d3-hierarchy2/index.js +15 -0
  88. package/esm/d3-hierarchy2/lcg.d.ts +1 -0
  89. package/esm/d3-hierarchy2/lcg.js +7 -0
  90. package/esm/d3-hierarchy2/pack/enclose.d.ts +10 -0
  91. package/esm/d3-hierarchy2/pack/enclose.js +84 -0
  92. package/esm/d3-hierarchy2/pack/index.d.ts +7 -0
  93. package/esm/d3-hierarchy2/pack/index.js +68 -0
  94. package/esm/d3-hierarchy2/pack/siblings.d.ts +2 -0
  95. package/esm/d3-hierarchy2/pack/siblings.js +94 -0
  96. package/esm/d3-hierarchy2/partition.d.ts +6 -0
  97. package/esm/d3-hierarchy2/partition.js +42 -0
  98. package/esm/d3-hierarchy2/stratify.d.ts +9 -0
  99. package/esm/d3-hierarchy2/stratify.js +115 -0
  100. package/esm/d3-hierarchy2/tree.d.ts +8 -0
  101. package/esm/d3-hierarchy2/tree.js +153 -0
  102. package/esm/d3-hierarchy2/treemap/binary.d.ts +1 -0
  103. package/esm/d3-hierarchy2/treemap/binary.js +36 -0
  104. package/esm/d3-hierarchy2/treemap/dice.d.ts +1 -0
  105. package/esm/d3-hierarchy2/treemap/dice.js +7 -0
  106. package/esm/d3-hierarchy2/treemap/index.d.ts +17 -0
  107. package/esm/d3-hierarchy2/treemap/index.js +72 -0
  108. package/esm/d3-hierarchy2/treemap/resquarify.d.ts +5 -0
  109. package/esm/d3-hierarchy2/treemap/resquarify.js +28 -0
  110. package/esm/d3-hierarchy2/treemap/round.d.ts +1 -0
  111. package/esm/d3-hierarchy2/treemap/round.js +6 -0
  112. package/esm/d3-hierarchy2/treemap/slice.d.ts +1 -0
  113. package/esm/d3-hierarchy2/treemap/slice.js +7 -0
  114. package/esm/d3-hierarchy2/treemap/sliceDice.d.ts +1 -0
  115. package/esm/d3-hierarchy2/treemap/sliceDice.js +5 -0
  116. package/esm/d3-hierarchy2/treemap/squarify.d.ts +11 -0
  117. package/esm/d3-hierarchy2/treemap/squarify.js +46 -0
  118. package/esm/index.d.ts +3 -3
  119. package/esm/shared/SharedWiggleConfigSchema.d.ts +3 -3
  120. package/esm/shared/SharedWiggleMixin.d.ts +28 -10
  121. package/esm/shared/SharedWiggleMixin.js +13 -3
  122. package/package.json +7 -7
@@ -0,0 +1,94 @@
1
+ import array from "../array.js";
2
+ import lcg from "../lcg.js";
3
+ import { packEncloseRandom } from "./enclose.js";
4
+ function place(b, a, c) {
5
+ var dx = b.x - a.x, x, a2, dy = b.y - a.y, y, b2, d2 = dx * dx + dy * dy;
6
+ if (d2) {
7
+ a2 = a.r + c.r, a2 *= a2;
8
+ b2 = b.r + c.r, b2 *= b2;
9
+ if (a2 > b2) {
10
+ x = (d2 + b2 - a2) / (2 * d2);
11
+ y = Math.sqrt(Math.max(0, b2 / d2 - x * x));
12
+ c.x = b.x - x * dx - y * dy;
13
+ c.y = b.y - x * dy + y * dx;
14
+ }
15
+ else {
16
+ x = (d2 + a2 - b2) / (2 * d2);
17
+ y = Math.sqrt(Math.max(0, a2 / d2 - x * x));
18
+ c.x = a.x + x * dx - y * dy;
19
+ c.y = a.y + x * dy + y * dx;
20
+ }
21
+ }
22
+ else {
23
+ c.x = a.x + c.r;
24
+ c.y = a.y;
25
+ }
26
+ }
27
+ function intersects(a, b) {
28
+ var dr = a.r + b.r - 1e-6, dx = b.x - a.x, dy = b.y - a.y;
29
+ return dr > 0 && dr * dr > dx * dx + dy * dy;
30
+ }
31
+ function score(node) {
32
+ var a = node._, b = node.next._, ab = a.r + b.r, dx = (a.x * b.r + b.x * a.r) / ab, dy = (a.y * b.r + b.y * a.r) / ab;
33
+ return dx * dx + dy * dy;
34
+ }
35
+ function Node(circle) {
36
+ this._ = circle;
37
+ this.next = null;
38
+ this.previous = null;
39
+ }
40
+ export function packSiblingsRandom(circles, random) {
41
+ if (!(n = (circles = array(circles)).length))
42
+ return 0;
43
+ var a, b, c, n, aa, ca, i, j, k, sj, sk;
44
+ a = circles[0], a.x = 0, a.y = 0;
45
+ if (!(n > 1))
46
+ return a.r;
47
+ b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0;
48
+ if (!(n > 2))
49
+ return a.r + b.r;
50
+ place(b, a, c = circles[2]);
51
+ a = new Node(a), b = new Node(b), c = new Node(c);
52
+ a.next = c.previous = b;
53
+ b.next = a.previous = c;
54
+ c.next = b.previous = a;
55
+ pack: for (i = 3; i < n; ++i) {
56
+ place(a._, b._, c = circles[i]), c = new Node(c);
57
+ j = b.next, k = a.previous, sj = b._.r, sk = a._.r;
58
+ do {
59
+ if (sj <= sk) {
60
+ if (intersects(j._, c._)) {
61
+ b = j, a.next = b, b.previous = a, --i;
62
+ continue pack;
63
+ }
64
+ sj += j._.r, j = j.next;
65
+ }
66
+ else {
67
+ if (intersects(k._, c._)) {
68
+ a = k, a.next = b, b.previous = a, --i;
69
+ continue pack;
70
+ }
71
+ sk += k._.r, k = k.previous;
72
+ }
73
+ } while (j !== k.next);
74
+ c.previous = a, c.next = b, a.next = b.previous = b = c;
75
+ aa = score(a);
76
+ while ((c = c.next) !== b) {
77
+ if ((ca = score(c)) < aa) {
78
+ a = c, aa = ca;
79
+ }
80
+ }
81
+ b = a.next;
82
+ }
83
+ a = [b._], c = b;
84
+ while ((c = c.next) !== b)
85
+ a.push(c._);
86
+ c = packEncloseRandom(a, random);
87
+ for (i = 0; i < n; ++i)
88
+ a = circles[i], a.x -= c.x, a.y -= c.y;
89
+ return c.r;
90
+ }
91
+ export default function (circles) {
92
+ packSiblingsRandom(circles, lcg());
93
+ return circles;
94
+ }
@@ -0,0 +1,6 @@
1
+ export default function (): {
2
+ (root: any): any;
3
+ round(x: any): boolean | any;
4
+ size(x: any): number[] | any;
5
+ padding(x: any): number | any;
6
+ };
@@ -0,0 +1,42 @@
1
+ import roundNode from "./treemap/round.js";
2
+ import treemapDice from "./treemap/dice.js";
3
+ export default function () {
4
+ var dx = 1, dy = 1, padding = 0, round = false;
5
+ function partition(root) {
6
+ var n = root.height + 1;
7
+ root.x0 =
8
+ root.y0 = padding;
9
+ root.x1 = dx;
10
+ root.y1 = dy / n;
11
+ root.eachBefore(positionNode(dy, n));
12
+ if (round)
13
+ root.eachBefore(roundNode);
14
+ return root;
15
+ }
16
+ function positionNode(dy, n) {
17
+ return function (node) {
18
+ if (node.children) {
19
+ treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n);
20
+ }
21
+ var x0 = node.x0, y0 = node.y0, x1 = node.x1 - padding, y1 = node.y1 - padding;
22
+ if (x1 < x0)
23
+ x0 = x1 = (x0 + x1) / 2;
24
+ if (y1 < y0)
25
+ y0 = y1 = (y0 + y1) / 2;
26
+ node.x0 = x0;
27
+ node.y0 = y0;
28
+ node.x1 = x1;
29
+ node.y1 = y1;
30
+ };
31
+ }
32
+ partition.round = function (x) {
33
+ return arguments.length ? (round = !!x, partition) : round;
34
+ };
35
+ partition.size = function (x) {
36
+ return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy];
37
+ };
38
+ partition.padding = function (x) {
39
+ return arguments.length ? (padding = +x, partition) : padding;
40
+ };
41
+ return partition;
42
+ }
@@ -0,0 +1,9 @@
1
+ declare function defaultId(d: any): any;
2
+ declare function defaultParentId(d: any): any;
3
+ export default function (): {
4
+ (data: any): any;
5
+ id(x: any): typeof defaultId;
6
+ parentId(x: any): typeof defaultParentId;
7
+ path(x: any): any;
8
+ };
9
+ export {};
@@ -0,0 +1,115 @@
1
+ import { optional } from "./accessors.js";
2
+ import { Node, computeHeight } from "./hierarchy/index.js";
3
+ var preroot = { depth: -1 }, ambiguous = {}, imputed = {};
4
+ function defaultId(d) {
5
+ return d.id;
6
+ }
7
+ function defaultParentId(d) {
8
+ return d.parentId;
9
+ }
10
+ export default function () {
11
+ var id = defaultId, parentId = defaultParentId, path;
12
+ function stratify(data) {
13
+ var nodes = Array.from(data), currentId = id, currentParentId = parentId, n, d, i, root, parent, node, nodeId, nodeKey, nodeByKey = new Map;
14
+ if (path != null) {
15
+ const I = nodes.map((d, i) => normalize(path(d, i, data)));
16
+ const P = I.map(parentof);
17
+ const S = new Set(I).add("");
18
+ for (const i of P) {
19
+ if (!S.has(i)) {
20
+ S.add(i);
21
+ I.push(i);
22
+ P.push(parentof(i));
23
+ nodes.push(imputed);
24
+ }
25
+ }
26
+ currentId = (_, i) => I[i];
27
+ currentParentId = (_, i) => P[i];
28
+ }
29
+ for (i = 0, n = nodes.length; i < n; ++i) {
30
+ d = nodes[i], node = nodes[i] = new Node(d);
31
+ if ((nodeId = currentId(d, i, data)) != null && (nodeId += "")) {
32
+ nodeKey = node.id = nodeId;
33
+ nodeByKey.set(nodeKey, nodeByKey.has(nodeKey) ? ambiguous : node);
34
+ }
35
+ if ((nodeId = currentParentId(d, i, data)) != null && (nodeId += "")) {
36
+ node.parent = nodeId;
37
+ }
38
+ }
39
+ for (i = 0; i < n; ++i) {
40
+ node = nodes[i];
41
+ if (nodeId = node.parent) {
42
+ parent = nodeByKey.get(nodeId);
43
+ if (!parent)
44
+ throw new Error("missing: " + nodeId);
45
+ if (parent === ambiguous)
46
+ throw new Error("ambiguous: " + nodeId);
47
+ if (parent.children)
48
+ parent.children.push(node);
49
+ else
50
+ parent.children = [node];
51
+ node.parent = parent;
52
+ }
53
+ else {
54
+ if (root)
55
+ throw new Error("multiple roots");
56
+ root = node;
57
+ }
58
+ }
59
+ if (!root)
60
+ throw new Error("no root");
61
+ if (path != null) {
62
+ while (root.data === imputed && root.children.length === 1) {
63
+ root = root.children[0], --n;
64
+ }
65
+ for (let i = nodes.length - 1; i >= 0; --i) {
66
+ node = nodes[i];
67
+ if (node.data !== imputed)
68
+ break;
69
+ node.data = null;
70
+ }
71
+ }
72
+ root.parent = preroot;
73
+ root.eachBefore(function (node) { node.depth = node.parent.depth + 1; --n; }).eachBefore(computeHeight);
74
+ root.parent = null;
75
+ if (n > 0)
76
+ throw new Error("cycle");
77
+ return root;
78
+ }
79
+ stratify.id = function (x) {
80
+ return arguments.length ? (id = optional(x), stratify) : id;
81
+ };
82
+ stratify.parentId = function (x) {
83
+ return arguments.length ? (parentId = optional(x), stratify) : parentId;
84
+ };
85
+ stratify.path = function (x) {
86
+ return arguments.length ? (path = optional(x), stratify) : path;
87
+ };
88
+ return stratify;
89
+ }
90
+ function normalize(path) {
91
+ path = `${path}`;
92
+ let i = path.length;
93
+ if (slash(path, i - 1) && !slash(path, i - 2))
94
+ path = path.slice(0, -1);
95
+ return path[0] === "/" ? path : `/${path}`;
96
+ }
97
+ function parentof(path) {
98
+ let i = path.length;
99
+ if (i < 2)
100
+ return "";
101
+ while (--i > 1)
102
+ if (slash(path, i))
103
+ break;
104
+ return path.slice(0, i);
105
+ }
106
+ function slash(path, i) {
107
+ if (path[i] === "/") {
108
+ let k = 0;
109
+ while (i > 0 && path[--i] === "\\")
110
+ ++k;
111
+ if ((k & 1) === 0)
112
+ return true;
113
+ }
114
+ return false;
115
+ }
@@ -0,0 +1,8 @@
1
+ declare function defaultSeparation(a: any, b: any): 1 | 2;
2
+ export default function (): {
3
+ (root: any): any;
4
+ separation(x: any): any | typeof defaultSeparation;
5
+ size(x: any): number[] | any | null;
6
+ nodeSize(x: any): number[] | any | null;
7
+ };
8
+ export {};
@@ -0,0 +1,153 @@
1
+ import { Node } from "./hierarchy/index.js";
2
+ function defaultSeparation(a, b) {
3
+ return a.parent === b.parent ? 1 : 2;
4
+ }
5
+ function nextLeft(v) {
6
+ var children = v.children;
7
+ return children ? children[0] : v.t;
8
+ }
9
+ function nextRight(v) {
10
+ var children = v.children;
11
+ return children ? children[children.length - 1] : v.t;
12
+ }
13
+ function moveSubtree(wm, wp, shift) {
14
+ var change = shift / (wp.i - wm.i);
15
+ wp.c -= change;
16
+ wp.s += shift;
17
+ wm.c += change;
18
+ wp.z += shift;
19
+ wp.m += shift;
20
+ }
21
+ function executeShifts(v) {
22
+ var shift = 0, change = 0, children = v.children, i = children.length, w;
23
+ while (--i >= 0) {
24
+ w = children[i];
25
+ w.z += shift;
26
+ w.m += shift;
27
+ shift += w.s + (change += w.c);
28
+ }
29
+ }
30
+ function nextAncestor(vim, v, ancestor) {
31
+ return vim.a.parent === v.parent ? vim.a : ancestor;
32
+ }
33
+ function TreeNode(node, i) {
34
+ this._ = node;
35
+ this.parent = null;
36
+ this.children = null;
37
+ this.A = null;
38
+ this.a = this;
39
+ this.z = 0;
40
+ this.m = 0;
41
+ this.c = 0;
42
+ this.s = 0;
43
+ this.t = null;
44
+ this.i = i;
45
+ }
46
+ TreeNode.prototype = Object.create(Node.prototype);
47
+ function treeRoot(root) {
48
+ var tree = new TreeNode(root, 0), node, nodes = [tree], child, children, i, n;
49
+ while (node = nodes.pop()) {
50
+ if (children = node._.children) {
51
+ node.children = new Array(n = children.length);
52
+ for (i = n - 1; i >= 0; --i) {
53
+ nodes.push(child = node.children[i] = new TreeNode(children[i], i));
54
+ child.parent = node;
55
+ }
56
+ }
57
+ }
58
+ (tree.parent = new TreeNode(null, 0)).children = [tree];
59
+ return tree;
60
+ }
61
+ export default function () {
62
+ var separation = defaultSeparation, dx = 1, dy = 1, nodeSize = null;
63
+ function tree(root) {
64
+ var t = treeRoot(root);
65
+ t.eachAfter(firstWalk), t.parent.m = -t.z;
66
+ t.eachBefore(secondWalk);
67
+ if (nodeSize)
68
+ root.eachBefore(sizeNode);
69
+ else {
70
+ var left = root, right = root, bottom = root;
71
+ root.eachBefore(function (node) {
72
+ if (node.x < left.x)
73
+ left = node;
74
+ if (node.x > right.x)
75
+ right = node;
76
+ if (node.depth > bottom.depth)
77
+ bottom = node;
78
+ });
79
+ var s = left === right ? 1 : separation(left, right) / 2, tx = s - left.x, kx = dx / (right.x + s + tx), ky = dy / (bottom.depth || 1);
80
+ root.eachBefore(function (node) {
81
+ node.x = (node.x + tx) * kx;
82
+ node.y = node.depth * ky;
83
+ });
84
+ }
85
+ return root;
86
+ }
87
+ function firstWalk(v) {
88
+ var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;
89
+ if (children) {
90
+ executeShifts(v);
91
+ var midpoint = (children[0].z + children[children.length - 1].z) / 2;
92
+ if (w) {
93
+ v.z = w.z + separation(v._, w._);
94
+ v.m = v.z - midpoint;
95
+ }
96
+ else {
97
+ v.z = midpoint;
98
+ }
99
+ }
100
+ else if (w) {
101
+ v.z = w.z + separation(v._, w._);
102
+ }
103
+ v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
104
+ }
105
+ function secondWalk(v) {
106
+ v._.x = v.z + v.parent.m;
107
+ v.m += v.parent.m;
108
+ }
109
+ function apportion(v, w, ancestor) {
110
+ if (w) {
111
+ var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift;
112
+ while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {
113
+ vom = nextLeft(vom);
114
+ vop = nextRight(vop);
115
+ vop.a = v;
116
+ shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
117
+ if (shift > 0) {
118
+ moveSubtree(nextAncestor(vim, v, ancestor), v, shift);
119
+ sip += shift;
120
+ sop += shift;
121
+ }
122
+ sim += vim.m;
123
+ sip += vip.m;
124
+ som += vom.m;
125
+ sop += vop.m;
126
+ }
127
+ if (vim && !nextRight(vop)) {
128
+ vop.t = vim;
129
+ vop.m += sim - sop;
130
+ }
131
+ if (vip && !nextLeft(vom)) {
132
+ vom.t = vip;
133
+ vom.m += sip - som;
134
+ ancestor = v;
135
+ }
136
+ }
137
+ return ancestor;
138
+ }
139
+ function sizeNode(node) {
140
+ node.x *= dx;
141
+ node.y = node.depth * dy;
142
+ }
143
+ tree.separation = function (x) {
144
+ return arguments.length ? (separation = x, tree) : separation;
145
+ };
146
+ tree.size = function (x) {
147
+ return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]);
148
+ };
149
+ tree.nodeSize = function (x) {
150
+ return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null);
151
+ };
152
+ return tree;
153
+ }
@@ -0,0 +1 @@
1
+ export default function (parent: any, x0: any, y0: any, x1: any, y1: any): void;
@@ -0,0 +1,36 @@
1
+ export default function (parent, x0, y0, x1, y1) {
2
+ var nodes = parent.children, i, n = nodes.length, sum, sums = new Array(n + 1);
3
+ for (sums[0] = sum = i = 0; i < n; ++i) {
4
+ sums[i + 1] = sum += nodes[i].value;
5
+ }
6
+ partition(0, n, parent.value, x0, y0, x1, y1);
7
+ function partition(i, j, value, x0, y0, x1, y1) {
8
+ if (i >= j - 1) {
9
+ var node = nodes[i];
10
+ node.x0 = x0, node.y0 = y0;
11
+ node.x1 = x1, node.y1 = y1;
12
+ return;
13
+ }
14
+ var valueOffset = sums[i], valueTarget = (value / 2) + valueOffset, k = i + 1, hi = j - 1;
15
+ while (k < hi) {
16
+ var mid = k + hi >>> 1;
17
+ if (sums[mid] < valueTarget)
18
+ k = mid + 1;
19
+ else
20
+ hi = mid;
21
+ }
22
+ if ((valueTarget - sums[k - 1]) < (sums[k] - valueTarget) && i + 1 < k)
23
+ --k;
24
+ var valueLeft = sums[k] - valueOffset, valueRight = value - valueLeft;
25
+ if ((x1 - x0) > (y1 - y0)) {
26
+ var xk = value ? (x0 * valueRight + x1 * valueLeft) / value : x1;
27
+ partition(i, k, valueLeft, x0, y0, xk, y1);
28
+ partition(k, j, valueRight, xk, y0, x1, y1);
29
+ }
30
+ else {
31
+ var yk = value ? (y0 * valueRight + y1 * valueLeft) / value : y1;
32
+ partition(i, k, valueLeft, x0, y0, x1, yk);
33
+ partition(k, j, valueRight, x0, yk, x1, y1);
34
+ }
35
+ }
36
+ }
@@ -0,0 +1 @@
1
+ export default function (parent: any, x0: any, y0: any, x1: any, y1: any): void;
@@ -0,0 +1,7 @@
1
+ export default function (parent, x0, y0, x1, y1) {
2
+ var nodes = parent.children, node, i = -1, n = nodes.length, k = parent.value && (x1 - x0) / parent.value;
3
+ while (++i < n) {
4
+ node = nodes[i], node.y0 = y0, node.y1 = y1;
5
+ node.x0 = x0, node.x1 = x0 += node.value * k;
6
+ }
7
+ }
@@ -0,0 +1,17 @@
1
+ import { constantZero } from "../constant.ts";
2
+ export default function (): {
3
+ (root: any): any;
4
+ round(x: any): boolean | any;
5
+ size(x: any): number[] | any;
6
+ tile(x: any): {
7
+ (parent: any, x0: any, y0: any, x1: any, y1: any): void;
8
+ ratio(x: any): any;
9
+ } | any;
10
+ padding(x: any): any;
11
+ paddingInner(x: any): typeof constantZero | any;
12
+ paddingOuter(x: any): any;
13
+ paddingTop(x: any): typeof constantZero | any;
14
+ paddingRight(x: any): typeof constantZero | any;
15
+ paddingBottom(x: any): typeof constantZero | any;
16
+ paddingLeft(x: any): typeof constantZero | any;
17
+ };
@@ -0,0 +1,72 @@
1
+ import roundNode from "./round.js";
2
+ import squarify from "./squarify.js";
3
+ import { required } from "../accessors.js";
4
+ import constant, { constantZero } from "../constant.js";
5
+ export default function () {
6
+ var tile = squarify, round = false, dx = 1, dy = 1, paddingStack = [0], paddingInner = constantZero, paddingTop = constantZero, paddingRight = constantZero, paddingBottom = constantZero, paddingLeft = constantZero;
7
+ function treemap(root) {
8
+ root.x0 =
9
+ root.y0 = 0;
10
+ root.x1 = dx;
11
+ root.y1 = dy;
12
+ root.eachBefore(positionNode);
13
+ paddingStack = [0];
14
+ if (round)
15
+ root.eachBefore(roundNode);
16
+ return root;
17
+ }
18
+ function positionNode(node) {
19
+ var p = paddingStack[node.depth], x0 = node.x0 + p, y0 = node.y0 + p, x1 = node.x1 - p, y1 = node.y1 - p;
20
+ if (x1 < x0)
21
+ x0 = x1 = (x0 + x1) / 2;
22
+ if (y1 < y0)
23
+ y0 = y1 = (y0 + y1) / 2;
24
+ node.x0 = x0;
25
+ node.y0 = y0;
26
+ node.x1 = x1;
27
+ node.y1 = y1;
28
+ if (node.children) {
29
+ p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
30
+ x0 += paddingLeft(node) - p;
31
+ y0 += paddingTop(node) - p;
32
+ x1 -= paddingRight(node) - p;
33
+ y1 -= paddingBottom(node) - p;
34
+ if (x1 < x0)
35
+ x0 = x1 = (x0 + x1) / 2;
36
+ if (y1 < y0)
37
+ y0 = y1 = (y0 + y1) / 2;
38
+ tile(node, x0, y0, x1, y1);
39
+ }
40
+ }
41
+ treemap.round = function (x) {
42
+ return arguments.length ? (round = !!x, treemap) : round;
43
+ };
44
+ treemap.size = function (x) {
45
+ return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
46
+ };
47
+ treemap.tile = function (x) {
48
+ return arguments.length ? (tile = required(x), treemap) : tile;
49
+ };
50
+ treemap.padding = function (x) {
51
+ return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
52
+ };
53
+ treemap.paddingInner = function (x) {
54
+ return arguments.length ? (paddingInner = typeof x === "function" ? x : constant(+x), treemap) : paddingInner;
55
+ };
56
+ treemap.paddingOuter = function (x) {
57
+ return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
58
+ };
59
+ treemap.paddingTop = function (x) {
60
+ return arguments.length ? (paddingTop = typeof x === "function" ? x : constant(+x), treemap) : paddingTop;
61
+ };
62
+ treemap.paddingRight = function (x) {
63
+ return arguments.length ? (paddingRight = typeof x === "function" ? x : constant(+x), treemap) : paddingRight;
64
+ };
65
+ treemap.paddingBottom = function (x) {
66
+ return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant(+x), treemap) : paddingBottom;
67
+ };
68
+ treemap.paddingLeft = function (x) {
69
+ return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant(+x), treemap) : paddingLeft;
70
+ };
71
+ return treemap;
72
+ }
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ (parent: any, x0: any, y0: any, x1: any, y1: any): void;
3
+ ratio(x: any): any;
4
+ };
5
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import treemapDice from "./dice.js";
2
+ import treemapSlice from "./slice.js";
3
+ import { phi, squarifyRatio } from "./squarify.js";
4
+ export default (function custom(ratio) {
5
+ function resquarify(parent, x0, y0, x1, y1) {
6
+ if ((rows = parent._squarify) && (rows.ratio === ratio)) {
7
+ var rows, row, nodes, i, j = -1, n, m = rows.length, value = parent.value;
8
+ while (++j < m) {
9
+ row = rows[j], nodes = row.children;
10
+ for (i = row.value = 0, n = nodes.length; i < n; ++i)
11
+ row.value += nodes[i].value;
12
+ if (row.dice)
13
+ treemapDice(row, x0, y0, x1, value ? y0 += (y1 - y0) * row.value / value : y1);
14
+ else
15
+ treemapSlice(row, x0, y0, value ? x0 += (x1 - x0) * row.value / value : x1, y1);
16
+ value -= row.value;
17
+ }
18
+ }
19
+ else {
20
+ parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
21
+ rows.ratio = ratio;
22
+ }
23
+ }
24
+ resquarify.ratio = function (x) {
25
+ return custom((x = +x) > 1 ? x : 1);
26
+ };
27
+ return resquarify;
28
+ })(phi);
@@ -0,0 +1 @@
1
+ export default function (node: any): void;
@@ -0,0 +1,6 @@
1
+ export default function (node) {
2
+ node.x0 = Math.round(node.x0);
3
+ node.y0 = Math.round(node.y0);
4
+ node.x1 = Math.round(node.x1);
5
+ node.y1 = Math.round(node.y1);
6
+ }
@@ -0,0 +1 @@
1
+ export default function (parent: any, x0: any, y0: any, x1: any, y1: any): void;
@@ -0,0 +1,7 @@
1
+ export default function (parent, x0, y0, x1, y1) {
2
+ var nodes = parent.children, node, i = -1, n = nodes.length, k = parent.value && (y1 - y0) / parent.value;
3
+ while (++i < n) {
4
+ node = nodes[i], node.x0 = x0, node.x1 = x1;
5
+ node.y0 = y0, node.y1 = y0 += node.value * k;
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ export default function (parent: any, x0: any, y0: any, x1: any, y1: any): void;
@@ -0,0 +1,5 @@
1
+ import dice from "./dice.js";
2
+ import slice from "./slice.js";
3
+ export default function (parent, x0, y0, x1, y1) {
4
+ (parent.depth & 1 ? slice : dice)(parent, x0, y0, x1, y1);
5
+ }
@@ -0,0 +1,11 @@
1
+ export declare var phi: number;
2
+ export declare function squarifyRatio(ratio: any, parent: any, x0: any, y0: any, x1: any, y1: any): {
3
+ value: any;
4
+ dice: boolean;
5
+ children: any;
6
+ }[];
7
+ declare const _default: {
8
+ (parent: any, x0: any, y0: any, x1: any, y1: any): void;
9
+ ratio(x: any): any;
10
+ };
11
+ export default _default;