@jbrowse/plugin-wiggle 4.1.3 → 4.1.4

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,15 @@
1
+ export default function (x) {
2
+ return typeof x === "object" && "length" in x
3
+ ? x
4
+ : Array.from(x);
5
+ }
6
+ export function shuffle(array, random) {
7
+ let m = array.length, t, i;
8
+ while (m) {
9
+ i = random() * m-- | 0;
10
+ t = array[m];
11
+ array[m] = array[i];
12
+ array[i] = t;
13
+ }
14
+ return array;
15
+ }
@@ -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,63 @@
1
+ function defaultSeparation(a, b) {
2
+ return a.parent === b.parent ? 1 : 2;
3
+ }
4
+ function meanX(children) {
5
+ return children.reduce(meanXReduce, 0) / children.length;
6
+ }
7
+ function meanXReduce(x, c) {
8
+ return x + c.x;
9
+ }
10
+ function maxY(children) {
11
+ return 1 + children.reduce(maxYReduce, 0);
12
+ }
13
+ function maxYReduce(y, c) {
14
+ return Math.max(y, c.y);
15
+ }
16
+ function leafLeft(node) {
17
+ var children;
18
+ while (children = node.children)
19
+ node = children[0];
20
+ return node;
21
+ }
22
+ function leafRight(node) {
23
+ var children;
24
+ while (children = node.children)
25
+ node = children[children.length - 1];
26
+ return node;
27
+ }
28
+ export default function () {
29
+ var separation = defaultSeparation, dx = 1, dy = 1, nodeSize = false;
30
+ function cluster(root) {
31
+ var previousNode, x = 0;
32
+ root.eachAfter(function (node) {
33
+ var children = node.children;
34
+ if (children) {
35
+ node.x = meanX(children);
36
+ node.y = maxY(children);
37
+ }
38
+ else {
39
+ node.x = previousNode ? x += separation(node, previousNode) : 0;
40
+ node.y = 0;
41
+ previousNode = node;
42
+ }
43
+ });
44
+ var left = leafLeft(root), right = leafRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2;
45
+ return root.eachAfter(nodeSize ? function (node) {
46
+ node.x = (node.x - root.x) * dx;
47
+ node.y = (root.y - node.y) * dy;
48
+ } : function (node) {
49
+ node.x = (node.x - x0) / (x1 - x0) * dx;
50
+ node.y = (1 - (root.y ? node.y / root.y : 1)) * dy;
51
+ });
52
+ }
53
+ cluster.separation = function (x) {
54
+ return arguments.length ? (separation = x, cluster) : separation;
55
+ };
56
+ cluster.size = function (x) {
57
+ return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? null : [dx, dy]);
58
+ };
59
+ cluster.nodeSize = function (x) {
60
+ return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? [dx, dy] : null);
61
+ };
62
+ return cluster;
63
+ }
@@ -0,0 +1,2 @@
1
+ export declare function constantZero(): number;
2
+ export default function (x: any): () => any;
@@ -0,0 +1,8 @@
1
+ export function constantZero() {
2
+ return 0;
3
+ }
4
+ export default function (x) {
5
+ return function () {
6
+ return x;
7
+ };
8
+ }
@@ -0,0 +1 @@
1
+ export default function (): any[];
@@ -0,0 +1,7 @@
1
+ export default function () {
2
+ var node = this, nodes = [node];
3
+ while (node = node.parent) {
4
+ nodes.push(node);
5
+ }
6
+ return nodes;
7
+ }
@@ -0,0 +1 @@
1
+ export default function (): any;
@@ -0,0 +1,12 @@
1
+ function count(node) {
2
+ var sum = 0, children = node.children, i = children && children.length;
3
+ if (!i)
4
+ sum = 1;
5
+ else
6
+ while (--i >= 0)
7
+ sum += children[i].value;
8
+ node.value = sum;
9
+ }
10
+ export default function () {
11
+ return this.eachAfter(count);
12
+ }
@@ -0,0 +1 @@
1
+ export default function (): unknown[];
@@ -0,0 +1,3 @@
1
+ export default function () {
2
+ return Array.from(this);
3
+ }
@@ -0,0 +1 @@
1
+ export default function (callback: any, that: any): any;
@@ -0,0 +1,7 @@
1
+ export default function (callback, that) {
2
+ let index = -1;
3
+ for (const node of this) {
4
+ callback.call(that, node, ++index, this);
5
+ }
6
+ return this;
7
+ }
@@ -0,0 +1 @@
1
+ export default function (callback: any, that: any): any;
@@ -0,0 +1,15 @@
1
+ export default function (callback, that) {
2
+ var node = this, nodes = [node], next = [], children, i, n, index = -1;
3
+ while (node = nodes.pop()) {
4
+ next.push(node);
5
+ if (children = node.children) {
6
+ for (i = 0, n = children.length; i < n; ++i) {
7
+ nodes.push(children[i]);
8
+ }
9
+ }
10
+ }
11
+ while (node = next.pop()) {
12
+ callback.call(that, node, ++index, this);
13
+ }
14
+ return this;
15
+ }
@@ -0,0 +1 @@
1
+ export default function (callback: any, that: any): any;
@@ -0,0 +1,12 @@
1
+ export default function (callback, that) {
2
+ var node = this, nodes = [node], children, i, index = -1;
3
+ while (node = nodes.pop()) {
4
+ callback.call(that, node, ++index, this);
5
+ if (children = node.children) {
6
+ for (i = children.length - 1; i >= 0; --i) {
7
+ nodes.push(children[i]);
8
+ }
9
+ }
10
+ }
11
+ return this;
12
+ }
@@ -0,0 +1 @@
1
+ export default function (callback: any, that: any): any;
@@ -0,0 +1,8 @@
1
+ export default function (callback, that) {
2
+ let index = -1;
3
+ for (const node of this) {
4
+ if (callback.call(that, node, ++index, this)) {
5
+ return node;
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,3 @@
1
+ export default function hierarchy(data: any, children: any): any;
2
+ export declare function computeHeight(node: any): void;
3
+ export declare function Node(data: any): void;
@@ -0,0 +1,78 @@
1
+ import node_count from "./count.js";
2
+ import node_each from "./each.js";
3
+ import node_eachBefore from "./eachBefore.js";
4
+ import node_eachAfter from "./eachAfter.js";
5
+ import node_find from "./find.js";
6
+ import node_sum from "./sum.js";
7
+ import node_sort from "./sort.js";
8
+ import node_path from "./path.js";
9
+ import node_ancestors from "./ancestors.js";
10
+ import node_descendants from "./descendants.js";
11
+ import node_leaves from "./leaves.js";
12
+ import node_links from "./links.js";
13
+ import node_iterator from "./iterator.js";
14
+ export default function hierarchy(data, children) {
15
+ if (data instanceof Map) {
16
+ data = [undefined, data];
17
+ if (children === undefined)
18
+ children = mapChildren;
19
+ }
20
+ else if (children === undefined) {
21
+ children = objectChildren;
22
+ }
23
+ var root = new Node(data), node, nodes = [root], child, childs, i, n;
24
+ while (node = nodes.pop()) {
25
+ if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
26
+ node.children = childs;
27
+ for (i = n - 1; i >= 0; --i) {
28
+ nodes.push(child = childs[i] = new Node(childs[i]));
29
+ child.parent = node;
30
+ child.depth = node.depth + 1;
31
+ }
32
+ }
33
+ }
34
+ return root.eachBefore(computeHeight);
35
+ }
36
+ function node_copy() {
37
+ return hierarchy(this).eachBefore(copyData);
38
+ }
39
+ function objectChildren(d) {
40
+ return d.children;
41
+ }
42
+ function mapChildren(d) {
43
+ return Array.isArray(d) ? d[1] : null;
44
+ }
45
+ function copyData(node) {
46
+ if (node.data.value !== undefined)
47
+ node.value = node.data.value;
48
+ node.data = node.data.data;
49
+ }
50
+ export function computeHeight(node) {
51
+ var height = 0;
52
+ do
53
+ node.height = height;
54
+ while ((node = node.parent) && (node.height < ++height));
55
+ }
56
+ export function Node(data) {
57
+ this.data = data;
58
+ this.depth =
59
+ this.height = 0;
60
+ this.parent = null;
61
+ }
62
+ Node.prototype = hierarchy.prototype = {
63
+ constructor: Node,
64
+ count: node_count,
65
+ each: node_each,
66
+ eachAfter: node_eachAfter,
67
+ eachBefore: node_eachBefore,
68
+ find: node_find,
69
+ sum: node_sum,
70
+ sort: node_sort,
71
+ path: node_path,
72
+ ancestors: node_ancestors,
73
+ descendants: node_descendants,
74
+ leaves: node_leaves,
75
+ links: node_links,
76
+ copy: node_copy,
77
+ [Symbol.iterator]: node_iterator
78
+ };
@@ -0,0 +1 @@
1
+ export default function (): Generator<any, void, unknown>;
@@ -0,0 +1,14 @@
1
+ export default function* () {
2
+ var node = this, current, next = [node], children, i, n;
3
+ do {
4
+ current = next.reverse(), next = [];
5
+ while (node = current.pop()) {
6
+ yield node;
7
+ if (children = node.children) {
8
+ for (i = 0, n = children.length; i < n; ++i) {
9
+ next.push(children[i]);
10
+ }
11
+ }
12
+ }
13
+ } while (next.length);
14
+ }
@@ -0,0 +1 @@
1
+ export default function (): any[];
@@ -0,0 +1,9 @@
1
+ export default function () {
2
+ var leaves = [];
3
+ this.eachBefore(function (node) {
4
+ if (!node.children) {
5
+ leaves.push(node);
6
+ }
7
+ });
8
+ return leaves;
9
+ }
@@ -0,0 +1 @@
1
+ export default function (): any[];
@@ -0,0 +1,9 @@
1
+ export default function () {
2
+ var root = this, links = [];
3
+ root.each(function (node) {
4
+ if (node !== root) {
5
+ links.push({ source: node.parent, target: node });
6
+ }
7
+ });
8
+ return links;
9
+ }
@@ -0,0 +1 @@
1
+ export default function (end: any): any[];
@@ -0,0 +1,26 @@
1
+ export default function (end) {
2
+ var start = this, ancestor = leastCommonAncestor(start, end), nodes = [start];
3
+ while (start !== ancestor) {
4
+ start = start.parent;
5
+ nodes.push(start);
6
+ }
7
+ var k = nodes.length;
8
+ while (end !== ancestor) {
9
+ nodes.splice(k, 0, end);
10
+ end = end.parent;
11
+ }
12
+ return nodes;
13
+ }
14
+ function leastCommonAncestor(a, b) {
15
+ if (a === b)
16
+ return a;
17
+ var aNodes = a.ancestors(), bNodes = b.ancestors(), c = null;
18
+ a = aNodes.pop();
19
+ b = bNodes.pop();
20
+ while (a === b) {
21
+ c = a;
22
+ a = aNodes.pop();
23
+ b = bNodes.pop();
24
+ }
25
+ return c;
26
+ }
@@ -0,0 +1 @@
1
+ export default function (compare: any): any;
@@ -0,0 +1,7 @@
1
+ export default function (compare) {
2
+ return this.eachBefore(function (node) {
3
+ if (node.children) {
4
+ node.children.sort(compare);
5
+ }
6
+ });
7
+ }
@@ -0,0 +1 @@
1
+ export default function (value: any): any;
@@ -0,0 +1,8 @@
1
+ export default function (value) {
2
+ return this.eachAfter(function (node) {
3
+ var sum = +value(node.data) || 0, children = node.children, i = children && children.length;
4
+ while (--i >= 0)
5
+ sum += children[i].value;
6
+ node.value = sum;
7
+ });
8
+ }
@@ -0,0 +1,15 @@
1
+ export { default as cluster } from "./cluster.ts";
2
+ export { default as hierarchy, Node } from "./hierarchy/index.ts";
3
+ export { default as pack } from "./pack/index.ts";
4
+ export { default as packSiblings } from "./pack/siblings.ts";
5
+ export { default as packEnclose } from "./pack/enclose.ts";
6
+ export { default as partition } from "./partition.ts";
7
+ export { default as stratify } from "./stratify.ts";
8
+ export { default as tree } from "./tree.ts";
9
+ export { default as treemap } from "./treemap/index.ts";
10
+ export { default as treemapBinary } from "./treemap/binary.ts";
11
+ export { default as treemapDice } from "./treemap/dice.ts";
12
+ export { default as treemapSlice } from "./treemap/slice.ts";
13
+ export { default as treemapSliceDice } from "./treemap/sliceDice.ts";
14
+ export { default as treemapSquarify } from "./treemap/squarify.ts";
15
+ export { default as treemapResquarify } from "./treemap/resquarify.ts";
@@ -0,0 +1,15 @@
1
+ export { default as cluster } from "./cluster.js";
2
+ export { default as hierarchy, Node } from "./hierarchy/index.js";
3
+ export { default as pack } from "./pack/index.js";
4
+ export { default as packSiblings } from "./pack/siblings.js";
5
+ export { default as packEnclose } from "./pack/enclose.js";
6
+ export { default as partition } from "./partition.js";
7
+ export { default as stratify } from "./stratify.js";
8
+ export { default as tree } from "./tree.js";
9
+ export { default as treemap } from "./treemap/index.js";
10
+ export { default as treemapBinary } from "./treemap/binary.js";
11
+ export { default as treemapDice } from "./treemap/dice.js";
12
+ export { default as treemapSlice } from "./treemap/slice.js";
13
+ export { default as treemapSliceDice } from "./treemap/sliceDice.js";
14
+ export { default as treemapSquarify } from "./treemap/squarify.js";
15
+ export { default as treemapResquarify } from "./treemap/resquarify.js";
@@ -0,0 +1 @@
1
+ export default function (): () => number;
@@ -0,0 +1,7 @@
1
+ const a = 1664525;
2
+ const c = 1013904223;
3
+ const m = 4294967296;
4
+ export default function () {
5
+ let s = 1;
6
+ return () => (s = (a * s + c) % m) / m;
7
+ }
@@ -0,0 +1,10 @@
1
+ export default function (circles: any): {
2
+ x: any;
3
+ y: any;
4
+ r: any;
5
+ } | undefined;
6
+ export declare function packEncloseRandom(circles: any, random: any): {
7
+ x: any;
8
+ y: any;
9
+ r: any;
10
+ } | undefined;
@@ -0,0 +1,84 @@
1
+ import { shuffle } from "../array.js";
2
+ import lcg from "../lcg.js";
3
+ export default function (circles) {
4
+ return packEncloseRandom(circles, lcg());
5
+ }
6
+ export function packEncloseRandom(circles, random) {
7
+ var i = 0, n = (circles = shuffle(Array.from(circles), random)).length, B = [], p, e;
8
+ while (i < n) {
9
+ p = circles[i];
10
+ if (e && enclosesWeak(e, p))
11
+ ++i;
12
+ else
13
+ e = encloseBasis(B = extendBasis(B, p)), i = 0;
14
+ }
15
+ return e;
16
+ }
17
+ function extendBasis(B, p) {
18
+ var i, j;
19
+ if (enclosesWeakAll(p, B))
20
+ return [p];
21
+ for (i = 0; i < B.length; ++i) {
22
+ if (enclosesNot(p, B[i])
23
+ && enclosesWeakAll(encloseBasis2(B[i], p), B)) {
24
+ return [B[i], p];
25
+ }
26
+ }
27
+ for (i = 0; i < B.length - 1; ++i) {
28
+ for (j = i + 1; j < B.length; ++j) {
29
+ if (enclosesNot(encloseBasis2(B[i], B[j]), p)
30
+ && enclosesNot(encloseBasis2(B[i], p), B[j])
31
+ && enclosesNot(encloseBasis2(B[j], p), B[i])
32
+ && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
33
+ return [B[i], B[j], p];
34
+ }
35
+ }
36
+ }
37
+ throw new Error;
38
+ }
39
+ function enclosesNot(a, b) {
40
+ var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
41
+ return dr < 0 || dr * dr < dx * dx + dy * dy;
42
+ }
43
+ function enclosesWeak(a, b) {
44
+ 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;
45
+ return dr > 0 && dr * dr > dx * dx + dy * dy;
46
+ }
47
+ function enclosesWeakAll(a, B) {
48
+ for (var i = 0; i < B.length; ++i) {
49
+ if (!enclosesWeak(a, B[i])) {
50
+ return false;
51
+ }
52
+ }
53
+ return true;
54
+ }
55
+ function encloseBasis(B) {
56
+ switch (B.length) {
57
+ case 1: return encloseBasis1(B[0]);
58
+ case 2: return encloseBasis2(B[0], B[1]);
59
+ case 3: return encloseBasis3(B[0], B[1], B[2]);
60
+ }
61
+ }
62
+ function encloseBasis1(a) {
63
+ return {
64
+ x: a.x,
65
+ y: a.y,
66
+ r: a.r
67
+ };
68
+ }
69
+ function encloseBasis2(a, b) {
70
+ var x1 = a.x, y1 = a.y, r1 = a.r, x2 = b.x, y2 = b.y, r2 = b.r, x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1, l = Math.sqrt(x21 * x21 + y21 * y21);
71
+ return {
72
+ x: (x1 + x2 + x21 / l * r21) / 2,
73
+ y: (y1 + y2 + y21 / l * r21) / 2,
74
+ r: (l + r1 + r2) / 2
75
+ };
76
+ }
77
+ function encloseBasis3(a, b, c) {
78
+ var x1 = a.x, y1 = a.y, r1 = a.r, x2 = b.x, y2 = b.y, r2 = b.r, x3 = c.x, y3 = c.y, r3 = c.r, a2 = x1 - x2, a3 = x1 - x3, b2 = y1 - y2, b3 = y1 - y3, c2 = r2 - r1, c3 = r3 - r1, d1 = x1 * x1 + y1 * y1 - r1 * r1, d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2, d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3, ab = a3 * b2 - a2 * b3, xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1, xb = (b3 * c2 - b2 * c3) / ab, ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1, yb = (a2 * c3 - a3 * c2) / ab, A = xb * xb + yb * yb - 1, B = 2 * (r1 + xa * xb + ya * yb), C = xa * xa + ya * ya - r1 * r1, r = -(Math.abs(A) > 1e-6 ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
79
+ return {
80
+ x: x1 + xa + xb * r,
81
+ y: y1 + ya + yb * r,
82
+ r: r
83
+ };
84
+ }
@@ -0,0 +1,7 @@
1
+ import { constantZero } from "../constant.ts";
2
+ export default function (): {
3
+ (root: any): any;
4
+ radius(x: any): any;
5
+ size(x: any): number[] | any;
6
+ padding(x: any): any | typeof constantZero;
7
+ };
@@ -0,0 +1,68 @@
1
+ import { optional } from "../accessors.js";
2
+ import constant, { constantZero } from "../constant.js";
3
+ import lcg from "../lcg.js";
4
+ import { packSiblingsRandom } from "./siblings.js";
5
+ function defaultRadius(d) {
6
+ return Math.sqrt(d.value);
7
+ }
8
+ export default function () {
9
+ var radius = null, dx = 1, dy = 1, padding = constantZero;
10
+ function pack(root) {
11
+ const random = lcg();
12
+ root.x = dx / 2, root.y = dy / 2;
13
+ if (radius) {
14
+ root.eachBefore(radiusLeaf(radius))
15
+ .eachAfter(packChildrenRandom(padding, 0.5, random))
16
+ .eachBefore(translateChild(1));
17
+ }
18
+ else {
19
+ root.eachBefore(radiusLeaf(defaultRadius))
20
+ .eachAfter(packChildrenRandom(constantZero, 1, random))
21
+ .eachAfter(packChildrenRandom(padding, root.r / Math.min(dx, dy), random))
22
+ .eachBefore(translateChild(Math.min(dx, dy) / (2 * root.r)));
23
+ }
24
+ return root;
25
+ }
26
+ pack.radius = function (x) {
27
+ return arguments.length ? (radius = optional(x), pack) : radius;
28
+ };
29
+ pack.size = function (x) {
30
+ return arguments.length ? (dx = +x[0], dy = +x[1], pack) : [dx, dy];
31
+ };
32
+ pack.padding = function (x) {
33
+ return arguments.length ? (padding = typeof x === "function" ? x : constant(+x), pack) : padding;
34
+ };
35
+ return pack;
36
+ }
37
+ function radiusLeaf(radius) {
38
+ return function (node) {
39
+ if (!node.children) {
40
+ node.r = Math.max(0, +radius(node) || 0);
41
+ }
42
+ };
43
+ }
44
+ function packChildrenRandom(padding, k, random) {
45
+ return function (node) {
46
+ if (children = node.children) {
47
+ var children, i, n = children.length, r = padding(node) * k || 0, e;
48
+ if (r)
49
+ for (i = 0; i < n; ++i)
50
+ children[i].r += r;
51
+ e = packSiblingsRandom(children, random);
52
+ if (r)
53
+ for (i = 0; i < n; ++i)
54
+ children[i].r -= r;
55
+ node.r = e + r;
56
+ }
57
+ };
58
+ }
59
+ function translateChild(k) {
60
+ return function (node) {
61
+ var parent = node.parent;
62
+ node.r *= k;
63
+ if (parent) {
64
+ node.x = parent.x + k * node.x;
65
+ node.y = parent.y + k * node.y;
66
+ }
67
+ };
68
+ }
@@ -0,0 +1,2 @@
1
+ export declare function packSiblingsRandom(circles: any, random: any): any;
2
+ export default function (circles: any): any;