@hpcc-js/tree 3.1.0 → 3.2.1
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.
- package/dist/index.js +2021 -1828
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +3 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +5 -5
- package/src/__package__.ts +3 -3
- package/types/__package__.d.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -1,1136 +1,1216 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
3
|
import { ITree } from "@hpcc-js/api";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/__package__.ts
|
|
4
|
+
import { SVGWidget, rgb, d3Event, interpolateZoom, Utility, PropertyExt, SVGZoomWidget, select, Palette, HTMLWidget, Platform, max as max$1, scaleLinear, scaleSqrt, interpolate } from "@hpcc-js/common";
|
|
5
5
|
const PKG_NAME = "@hpcc-js/tree";
|
|
6
|
-
const PKG_VERSION = "3.
|
|
7
|
-
const BUILD_VERSION = "3.
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region node_modules/d3-hierarchy/src/cluster.js
|
|
6
|
+
const PKG_VERSION = "3.2.1";
|
|
7
|
+
const BUILD_VERSION = "3.15.1";
|
|
11
8
|
function defaultSeparation$1(a, b) {
|
|
12
|
-
|
|
9
|
+
return a.parent === b.parent ? 1 : 2;
|
|
13
10
|
}
|
|
11
|
+
__name(defaultSeparation$1, "defaultSeparation$1");
|
|
14
12
|
function meanX(children) {
|
|
15
|
-
|
|
13
|
+
return children.reduce(meanXReduce, 0) / children.length;
|
|
16
14
|
}
|
|
15
|
+
__name(meanX, "meanX");
|
|
17
16
|
function meanXReduce(x, c) {
|
|
18
|
-
|
|
17
|
+
return x + c.x;
|
|
19
18
|
}
|
|
19
|
+
__name(meanXReduce, "meanXReduce");
|
|
20
20
|
function maxY(children) {
|
|
21
|
-
|
|
21
|
+
return 1 + children.reduce(maxYReduce, 0);
|
|
22
22
|
}
|
|
23
|
+
__name(maxY, "maxY");
|
|
23
24
|
function maxYReduce(y, c) {
|
|
24
|
-
|
|
25
|
+
return Math.max(y, c.y);
|
|
25
26
|
}
|
|
27
|
+
__name(maxYReduce, "maxYReduce");
|
|
26
28
|
function leafLeft(node) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
var children;
|
|
30
|
+
while (children = node.children) node = children[0];
|
|
31
|
+
return node;
|
|
30
32
|
}
|
|
33
|
+
__name(leafLeft, "leafLeft");
|
|
31
34
|
function leafRight(node) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
35
|
+
var children;
|
|
36
|
+
while (children = node.children) node = children[children.length - 1];
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
__name(leafRight, "leafRight");
|
|
40
|
+
function d3Cluster() {
|
|
41
|
+
var separation = defaultSeparation$1, dx = 1, dy = 1, nodeSize = false;
|
|
42
|
+
function cluster(root) {
|
|
43
|
+
var previousNode, x = 0;
|
|
44
|
+
root.eachAfter(function(node) {
|
|
45
|
+
var children = node.children;
|
|
46
|
+
if (children) {
|
|
47
|
+
node.x = meanX(children);
|
|
48
|
+
node.y = maxY(children);
|
|
49
|
+
} else {
|
|
50
|
+
node.x = previousNode ? x += separation(node, previousNode) : 0;
|
|
51
|
+
node.y = 0;
|
|
52
|
+
previousNode = node;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
var left = leafLeft(root), right = leafRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2;
|
|
56
|
+
return root.eachAfter(nodeSize ? function(node) {
|
|
57
|
+
node.x = (node.x - root.x) * dx;
|
|
58
|
+
node.y = (root.y - node.y) * dy;
|
|
59
|
+
} : function(node) {
|
|
60
|
+
node.x = (node.x - x0) / (x1 - x0) * dx;
|
|
61
|
+
node.y = (1 - (root.y ? node.y / root.y : 1)) * dy;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
__name(cluster, "cluster");
|
|
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
|
+
__name(d3Cluster, "d3Cluster");
|
|
74
77
|
function count(node) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
78
|
+
var sum = 0, children = node.children, i = children && children.length;
|
|
79
|
+
if (!i) sum = 1;
|
|
80
|
+
else while (--i >= 0) sum += children[i].value;
|
|
81
|
+
node.value = sum;
|
|
82
|
+
}
|
|
83
|
+
__name(count, "count");
|
|
84
|
+
function node_count() {
|
|
85
|
+
return this.eachAfter(count);
|
|
86
|
+
}
|
|
87
|
+
__name(node_count, "node_count");
|
|
88
|
+
function node_each(callback) {
|
|
89
|
+
var node = this, current, next = [node], children, i, n;
|
|
90
|
+
do {
|
|
91
|
+
current = next.reverse(), next = [];
|
|
92
|
+
while (node = current.pop()) {
|
|
93
|
+
callback(node), children = node.children;
|
|
94
|
+
if (children) for (i = 0, n = children.length; i < n; ++i) {
|
|
95
|
+
next.push(children[i]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} while (next.length);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
__name(node_each, "node_each");
|
|
102
|
+
function node_eachBefore(callback) {
|
|
103
|
+
var node = this, nodes = [node], children, i;
|
|
104
|
+
while (node = nodes.pop()) {
|
|
105
|
+
callback(node), children = node.children;
|
|
106
|
+
if (children) for (i = children.length - 1; i >= 0; --i) {
|
|
107
|
+
nodes.push(children[i]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
__name(node_eachBefore, "node_eachBefore");
|
|
113
|
+
function node_eachAfter(callback) {
|
|
114
|
+
var node = this, nodes = [node], next = [], children, i, n;
|
|
115
|
+
while (node = nodes.pop()) {
|
|
116
|
+
next.push(node), children = node.children;
|
|
117
|
+
if (children) for (i = 0, n = children.length; i < n; ++i) {
|
|
118
|
+
nodes.push(children[i]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
while (node = next.pop()) {
|
|
122
|
+
callback(node);
|
|
123
|
+
}
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
__name(node_eachAfter, "node_eachAfter");
|
|
127
|
+
function node_sum(value) {
|
|
128
|
+
return this.eachAfter(function(node) {
|
|
129
|
+
var sum = +value(node.data) || 0, children = node.children, i = children && children.length;
|
|
130
|
+
while (--i >= 0) sum += children[i].value;
|
|
131
|
+
node.value = sum;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
__name(node_sum, "node_sum");
|
|
135
|
+
function node_sort(compare) {
|
|
136
|
+
return this.eachBefore(function(node) {
|
|
137
|
+
if (node.children) {
|
|
138
|
+
node.children.sort(compare);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
__name(node_sort, "node_sort");
|
|
143
|
+
function node_path(end) {
|
|
144
|
+
var start = this, ancestor = leastCommonAncestor(start, end), nodes = [start];
|
|
145
|
+
while (start !== ancestor) {
|
|
146
|
+
start = start.parent;
|
|
147
|
+
nodes.push(start);
|
|
148
|
+
}
|
|
149
|
+
var k = nodes.length;
|
|
150
|
+
while (end !== ancestor) {
|
|
151
|
+
nodes.splice(k, 0, end);
|
|
152
|
+
end = end.parent;
|
|
153
|
+
}
|
|
154
|
+
return nodes;
|
|
155
|
+
}
|
|
156
|
+
__name(node_path, "node_path");
|
|
154
157
|
function leastCommonAncestor(a, b) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
return links;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
//#endregion
|
|
209
|
-
//#region node_modules/d3-hierarchy/src/hierarchy/index.js
|
|
158
|
+
if (a === b) return a;
|
|
159
|
+
var aNodes = a.ancestors(), bNodes = b.ancestors(), c = null;
|
|
160
|
+
a = aNodes.pop();
|
|
161
|
+
b = bNodes.pop();
|
|
162
|
+
while (a === b) {
|
|
163
|
+
c = a;
|
|
164
|
+
a = aNodes.pop();
|
|
165
|
+
b = bNodes.pop();
|
|
166
|
+
}
|
|
167
|
+
return c;
|
|
168
|
+
}
|
|
169
|
+
__name(leastCommonAncestor, "leastCommonAncestor");
|
|
170
|
+
function node_ancestors() {
|
|
171
|
+
var node = this, nodes = [node];
|
|
172
|
+
while (node = node.parent) {
|
|
173
|
+
nodes.push(node);
|
|
174
|
+
}
|
|
175
|
+
return nodes;
|
|
176
|
+
}
|
|
177
|
+
__name(node_ancestors, "node_ancestors");
|
|
178
|
+
function node_descendants() {
|
|
179
|
+
var nodes = [];
|
|
180
|
+
this.each(function(node) {
|
|
181
|
+
nodes.push(node);
|
|
182
|
+
});
|
|
183
|
+
return nodes;
|
|
184
|
+
}
|
|
185
|
+
__name(node_descendants, "node_descendants");
|
|
186
|
+
function node_leaves() {
|
|
187
|
+
var leaves = [];
|
|
188
|
+
this.eachBefore(function(node) {
|
|
189
|
+
if (!node.children) {
|
|
190
|
+
leaves.push(node);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
return leaves;
|
|
194
|
+
}
|
|
195
|
+
__name(node_leaves, "node_leaves");
|
|
196
|
+
function node_links() {
|
|
197
|
+
var root = this, links = [];
|
|
198
|
+
root.each(function(node) {
|
|
199
|
+
if (node !== root) {
|
|
200
|
+
links.push({ source: node.parent, target: node });
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return links;
|
|
204
|
+
}
|
|
205
|
+
__name(node_links, "node_links");
|
|
210
206
|
function hierarchy(data, children) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
207
|
+
var root = new Node$1(data), valued = +data.value && (root.value = data.value), node, nodes = [root], child, childs, i, n;
|
|
208
|
+
if (children == null) children = defaultChildren;
|
|
209
|
+
while (node = nodes.pop()) {
|
|
210
|
+
if (valued) node.value = +node.data.value;
|
|
211
|
+
if ((childs = children(node.data)) && (n = childs.length)) {
|
|
212
|
+
node.children = new Array(n);
|
|
213
|
+
for (i = n - 1; i >= 0; --i) {
|
|
214
|
+
nodes.push(child = node.children[i] = new Node$1(childs[i]));
|
|
215
|
+
child.parent = node;
|
|
216
|
+
child.depth = node.depth + 1;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return root.eachBefore(computeHeight);
|
|
221
|
+
}
|
|
222
|
+
__name(hierarchy, "hierarchy");
|
|
226
223
|
function node_copy() {
|
|
227
|
-
|
|
224
|
+
return hierarchy(this).eachBefore(copyData);
|
|
228
225
|
}
|
|
226
|
+
__name(node_copy, "node_copy");
|
|
229
227
|
function defaultChildren(d) {
|
|
230
|
-
|
|
228
|
+
return d.children;
|
|
231
229
|
}
|
|
230
|
+
__name(defaultChildren, "defaultChildren");
|
|
232
231
|
function copyData(node) {
|
|
233
|
-
|
|
232
|
+
node.data = node.data.data;
|
|
234
233
|
}
|
|
234
|
+
__name(copyData, "copyData");
|
|
235
235
|
function computeHeight(node) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
236
|
+
var height = 0;
|
|
237
|
+
do
|
|
238
|
+
node.height = height;
|
|
239
|
+
while ((node = node.parent) && node.height < ++height);
|
|
240
|
+
}
|
|
241
|
+
__name(computeHeight, "computeHeight");
|
|
242
|
+
function Node$1(data) {
|
|
243
|
+
this.data = data;
|
|
244
|
+
this.depth = this.height = 0;
|
|
245
|
+
this.parent = null;
|
|
246
|
+
}
|
|
247
|
+
__name(Node$1, "Node$1");
|
|
248
|
+
Node$1.prototype = hierarchy.prototype = {
|
|
249
|
+
constructor: Node$1,
|
|
250
|
+
count: node_count,
|
|
251
|
+
each: node_each,
|
|
252
|
+
eachAfter: node_eachAfter,
|
|
253
|
+
eachBefore: node_eachBefore,
|
|
254
|
+
sum: node_sum,
|
|
255
|
+
sort: node_sort,
|
|
256
|
+
path: node_path,
|
|
257
|
+
ancestors: node_ancestors,
|
|
258
|
+
descendants: node_descendants,
|
|
259
|
+
leaves: node_leaves,
|
|
260
|
+
links: node_links,
|
|
261
|
+
copy: node_copy
|
|
260
262
|
};
|
|
261
|
-
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region node_modules/d3-hierarchy/src/array.js
|
|
264
263
|
var slice = Array.prototype.slice;
|
|
265
264
|
function shuffle(array) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
265
|
+
var m = array.length, t, i;
|
|
266
|
+
while (m) {
|
|
267
|
+
i = Math.random() * m-- | 0;
|
|
268
|
+
t = array[m];
|
|
269
|
+
array[m] = array[i];
|
|
270
|
+
array[i] = t;
|
|
271
|
+
}
|
|
272
|
+
return array;
|
|
273
|
+
}
|
|
274
|
+
__name(shuffle, "shuffle");
|
|
275
|
+
function enclose(circles) {
|
|
276
|
+
var i = 0, n = (circles = shuffle(slice.call(circles))).length, B = [], p, e;
|
|
277
|
+
while (i < n) {
|
|
278
|
+
p = circles[i];
|
|
279
|
+
if (e && enclosesWeak(e, p)) ++i;
|
|
280
|
+
else e = encloseBasis(B = extendBasis(B, p)), i = 0;
|
|
281
|
+
}
|
|
282
|
+
return e;
|
|
283
|
+
}
|
|
284
|
+
__name(enclose, "enclose");
|
|
287
285
|
function extendBasis(B, p) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
286
|
+
var i, j;
|
|
287
|
+
if (enclosesWeakAll(p, B)) return [p];
|
|
288
|
+
for (i = 0; i < B.length; ++i) {
|
|
289
|
+
if (enclosesNot(p, B[i]) && enclosesWeakAll(encloseBasis2(B[i], p), B)) {
|
|
290
|
+
return [B[i], p];
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
for (i = 0; i < B.length - 1; ++i) {
|
|
294
|
+
for (j = i + 1; j < B.length; ++j) {
|
|
295
|
+
if (enclosesNot(encloseBasis2(B[i], B[j]), p) && enclosesNot(encloseBasis2(B[i], p), B[j]) && enclosesNot(encloseBasis2(B[j], p), B[i]) && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
|
|
296
|
+
return [B[i], B[j], p];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
throw new Error();
|
|
301
|
+
}
|
|
302
|
+
__name(extendBasis, "extendBasis");
|
|
298
303
|
function enclosesNot(a, b) {
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
|
|
305
|
+
return dr < 0 || dr * dr < dx * dx + dy * dy;
|
|
301
306
|
}
|
|
307
|
+
__name(enclosesNot, "enclosesNot");
|
|
302
308
|
function enclosesWeak(a, b) {
|
|
303
|
-
|
|
304
|
-
|
|
309
|
+
var dr = a.r - b.r + 1e-6, dx = b.x - a.x, dy = b.y - a.y;
|
|
310
|
+
return dr > 0 && dr * dr > dx * dx + dy * dy;
|
|
305
311
|
}
|
|
312
|
+
__name(enclosesWeak, "enclosesWeak");
|
|
306
313
|
function enclosesWeakAll(a, B) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
314
|
+
for (var i = 0; i < B.length; ++i) {
|
|
315
|
+
if (!enclosesWeak(a, B[i])) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
__name(enclosesWeakAll, "enclosesWeakAll");
|
|
310
322
|
function encloseBasis(B) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
323
|
+
switch (B.length) {
|
|
324
|
+
case 1:
|
|
325
|
+
return encloseBasis1(B[0]);
|
|
326
|
+
case 2:
|
|
327
|
+
return encloseBasis2(B[0], B[1]);
|
|
328
|
+
case 3:
|
|
329
|
+
return encloseBasis3(B[0], B[1], B[2]);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
__name(encloseBasis, "encloseBasis");
|
|
317
333
|
function encloseBasis1(a) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
334
|
+
return {
|
|
335
|
+
x: a.x,
|
|
336
|
+
y: a.y,
|
|
337
|
+
r: a.r
|
|
338
|
+
};
|
|
323
339
|
}
|
|
340
|
+
__name(encloseBasis1, "encloseBasis1");
|
|
324
341
|
function encloseBasis2(a, b) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
342
|
+
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);
|
|
343
|
+
return {
|
|
344
|
+
x: (x1 + x2 + x21 / l * r21) / 2,
|
|
345
|
+
y: (y1 + y2 + y21 / l * r21) / 2,
|
|
346
|
+
r: (l + r1 + r2) / 2
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
__name(encloseBasis2, "encloseBasis2");
|
|
332
350
|
function encloseBasis3(a, b, c) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
//#endregion
|
|
342
|
-
//#region node_modules/d3-hierarchy/src/pack/siblings.js
|
|
351
|
+
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 = -(A ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
|
|
352
|
+
return {
|
|
353
|
+
x: x1 + xa + xb * r,
|
|
354
|
+
y: y1 + ya + yb * r,
|
|
355
|
+
r
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
__name(encloseBasis3, "encloseBasis3");
|
|
343
359
|
function place(b, a, c) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
360
|
+
var dx = b.x - a.x, x, a2, dy = b.y - a.y, y, b2, d2 = dx * dx + dy * dy;
|
|
361
|
+
if (d2) {
|
|
362
|
+
a2 = a.r + c.r, a2 *= a2;
|
|
363
|
+
b2 = b.r + c.r, b2 *= b2;
|
|
364
|
+
if (a2 > b2) {
|
|
365
|
+
x = (d2 + b2 - a2) / (2 * d2);
|
|
366
|
+
y = Math.sqrt(Math.max(0, b2 / d2 - x * x));
|
|
367
|
+
c.x = b.x - x * dx - y * dy;
|
|
368
|
+
c.y = b.y - x * dy + y * dx;
|
|
369
|
+
} else {
|
|
370
|
+
x = (d2 + a2 - b2) / (2 * d2);
|
|
371
|
+
y = Math.sqrt(Math.max(0, a2 / d2 - x * x));
|
|
372
|
+
c.x = a.x + x * dx - y * dy;
|
|
373
|
+
c.y = a.y + x * dy + y * dx;
|
|
374
|
+
}
|
|
375
|
+
} else {
|
|
376
|
+
c.x = a.x + c.r;
|
|
377
|
+
c.y = a.y;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
__name(place, "place");
|
|
364
381
|
function intersects(a, b) {
|
|
365
|
-
|
|
366
|
-
|
|
382
|
+
var dr = a.r + b.r - 1e-6, dx = b.x - a.x, dy = b.y - a.y;
|
|
383
|
+
return dr > 0 && dr * dr > dx * dx + dy * dy;
|
|
367
384
|
}
|
|
385
|
+
__name(intersects, "intersects");
|
|
368
386
|
function score(node) {
|
|
369
|
-
|
|
370
|
-
|
|
387
|
+
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;
|
|
388
|
+
return dx * dx + dy * dy;
|
|
371
389
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
390
|
+
__name(score, "score");
|
|
391
|
+
function Node(circle) {
|
|
392
|
+
this._ = circle;
|
|
393
|
+
this.next = null;
|
|
394
|
+
this.previous = null;
|
|
376
395
|
}
|
|
396
|
+
__name(Node, "Node");
|
|
377
397
|
function packEnclose(circles) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
398
|
+
if (!(n = circles.length)) return 0;
|
|
399
|
+
var a, b, c, n, aa, ca, i, j, k, sj, sk;
|
|
400
|
+
a = circles[0], a.x = 0, a.y = 0;
|
|
401
|
+
if (!(n > 1)) return a.r;
|
|
402
|
+
b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0;
|
|
403
|
+
if (!(n > 2)) return a.r + b.r;
|
|
404
|
+
place(b, a, c = circles[2]);
|
|
405
|
+
a = new Node(a), b = new Node(b), c = new Node(c);
|
|
406
|
+
a.next = c.previous = b;
|
|
407
|
+
b.next = a.previous = c;
|
|
408
|
+
c.next = b.previous = a;
|
|
409
|
+
pack: for (i = 3; i < n; ++i) {
|
|
410
|
+
place(a._, b._, c = circles[i]), c = new Node(c);
|
|
411
|
+
j = b.next, k = a.previous, sj = b._.r, sk = a._.r;
|
|
412
|
+
do {
|
|
413
|
+
if (sj <= sk) {
|
|
414
|
+
if (intersects(j._, c._)) {
|
|
415
|
+
b = j, a.next = b, b.previous = a, --i;
|
|
416
|
+
continue pack;
|
|
417
|
+
}
|
|
418
|
+
sj += j._.r, j = j.next;
|
|
419
|
+
} else {
|
|
420
|
+
if (intersects(k._, c._)) {
|
|
421
|
+
a = k, a.next = b, b.previous = a, --i;
|
|
422
|
+
continue pack;
|
|
423
|
+
}
|
|
424
|
+
sk += k._.r, k = k.previous;
|
|
425
|
+
}
|
|
426
|
+
} while (j !== k.next);
|
|
427
|
+
c.previous = a, c.next = b, a.next = b.previous = b = c;
|
|
428
|
+
aa = score(a);
|
|
429
|
+
while ((c = c.next) !== b) {
|
|
430
|
+
if ((ca = score(c)) < aa) {
|
|
431
|
+
a = c, aa = ca;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
b = a.next;
|
|
435
|
+
}
|
|
436
|
+
a = [b._], c = b;
|
|
437
|
+
while ((c = c.next) !== b) a.push(c._);
|
|
438
|
+
c = enclose(a);
|
|
439
|
+
for (i = 0; i < n; ++i) a = circles[i], a.x -= c.x, a.y -= c.y;
|
|
440
|
+
return c.r;
|
|
441
|
+
}
|
|
442
|
+
__name(packEnclose, "packEnclose");
|
|
421
443
|
function optional(f) {
|
|
422
|
-
|
|
444
|
+
return f == null ? null : required(f);
|
|
423
445
|
}
|
|
446
|
+
__name(optional, "optional");
|
|
424
447
|
function required(f) {
|
|
425
|
-
|
|
426
|
-
|
|
448
|
+
if (typeof f !== "function") throw new Error();
|
|
449
|
+
return f;
|
|
427
450
|
}
|
|
428
|
-
|
|
429
|
-
//#endregion
|
|
430
|
-
//#region node_modules/d3-hierarchy/src/constant.js
|
|
451
|
+
__name(required, "required");
|
|
431
452
|
function constantZero() {
|
|
432
|
-
|
|
453
|
+
return 0;
|
|
433
454
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
455
|
+
__name(constantZero, "constantZero");
|
|
456
|
+
function constant$1(x) {
|
|
457
|
+
return function() {
|
|
458
|
+
return x;
|
|
459
|
+
};
|
|
438
460
|
}
|
|
439
|
-
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region node_modules/d3-hierarchy/src/pack/index.js
|
|
461
|
+
__name(constant$1, "constant$1");
|
|
442
462
|
function defaultRadius(d) {
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
463
|
+
return Math.sqrt(d.value);
|
|
464
|
+
}
|
|
465
|
+
__name(defaultRadius, "defaultRadius");
|
|
466
|
+
function d3Pack() {
|
|
467
|
+
var radius = null, dx = 1, dy = 1, padding = constantZero;
|
|
468
|
+
function pack(root) {
|
|
469
|
+
root.x = dx / 2, root.y = dy / 2;
|
|
470
|
+
if (radius) {
|
|
471
|
+
root.eachBefore(radiusLeaf(radius)).eachAfter(packChildren(padding, 0.5)).eachBefore(translateChild(1));
|
|
472
|
+
} else {
|
|
473
|
+
root.eachBefore(radiusLeaf(defaultRadius)).eachAfter(packChildren(constantZero, 1)).eachAfter(packChildren(padding, root.r / Math.min(dx, dy))).eachBefore(translateChild(Math.min(dx, dy) / (2 * root.r)));
|
|
474
|
+
}
|
|
475
|
+
return root;
|
|
476
|
+
}
|
|
477
|
+
__name(pack, "pack");
|
|
478
|
+
pack.radius = function(x) {
|
|
479
|
+
return arguments.length ? (radius = optional(x), pack) : radius;
|
|
480
|
+
};
|
|
481
|
+
pack.size = function(x) {
|
|
482
|
+
return arguments.length ? (dx = +x[0], dy = +x[1], pack) : [dx, dy];
|
|
483
|
+
};
|
|
484
|
+
pack.padding = function(x) {
|
|
485
|
+
return arguments.length ? (padding = typeof x === "function" ? x : constant$1(+x), pack) : padding;
|
|
486
|
+
};
|
|
487
|
+
return pack;
|
|
488
|
+
}
|
|
489
|
+
__name(d3Pack, "d3Pack");
|
|
464
490
|
function radiusLeaf(radius) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
491
|
+
return function(node) {
|
|
492
|
+
if (!node.children) {
|
|
493
|
+
node.r = Math.max(0, +radius(node) || 0);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
468
496
|
}
|
|
497
|
+
__name(radiusLeaf, "radiusLeaf");
|
|
469
498
|
function packChildren(padding, k) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
}
|
|
499
|
+
return function(node) {
|
|
500
|
+
if (children = node.children) {
|
|
501
|
+
var children, i, n = children.length, r = padding(node) * k || 0, e;
|
|
502
|
+
if (r) for (i = 0; i < n; ++i) children[i].r += r;
|
|
503
|
+
e = packEnclose(children);
|
|
504
|
+
if (r) for (i = 0; i < n; ++i) children[i].r -= r;
|
|
505
|
+
node.r = e + r;
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
__name(packChildren, "packChildren");
|
|
480
510
|
function translateChild(k) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
//#endregion
|
|
548
|
-
//#region node_modules/d3-hierarchy/src/tree.js
|
|
511
|
+
return function(node) {
|
|
512
|
+
var parent = node.parent;
|
|
513
|
+
node.r *= k;
|
|
514
|
+
if (parent) {
|
|
515
|
+
node.x = parent.x + k * node.x;
|
|
516
|
+
node.y = parent.y + k * node.y;
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
__name(translateChild, "translateChild");
|
|
521
|
+
function roundNode(node) {
|
|
522
|
+
node.x0 = Math.round(node.x0);
|
|
523
|
+
node.y0 = Math.round(node.y0);
|
|
524
|
+
node.x1 = Math.round(node.x1);
|
|
525
|
+
node.y1 = Math.round(node.y1);
|
|
526
|
+
}
|
|
527
|
+
__name(roundNode, "roundNode");
|
|
528
|
+
function d3treemapDice(parent, x0, y0, x1, y1) {
|
|
529
|
+
var nodes = parent.children, node, i = -1, n = nodes.length, k = parent.value && (x1 - x0) / parent.value;
|
|
530
|
+
while (++i < n) {
|
|
531
|
+
node = nodes[i], node.y0 = y0, node.y1 = y1;
|
|
532
|
+
node.x0 = x0, node.x1 = x0 += node.value * k;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
__name(d3treemapDice, "d3treemapDice");
|
|
536
|
+
function d3Parition() {
|
|
537
|
+
var dx = 1, dy = 1, padding = 0, round = false;
|
|
538
|
+
function partition(root) {
|
|
539
|
+
var n = root.height + 1;
|
|
540
|
+
root.x0 = root.y0 = padding;
|
|
541
|
+
root.x1 = dx;
|
|
542
|
+
root.y1 = dy / n;
|
|
543
|
+
root.eachBefore(positionNode(dy, n));
|
|
544
|
+
if (round) root.eachBefore(roundNode);
|
|
545
|
+
return root;
|
|
546
|
+
}
|
|
547
|
+
__name(partition, "partition");
|
|
548
|
+
function positionNode(dy2, n) {
|
|
549
|
+
return function(node) {
|
|
550
|
+
if (node.children) {
|
|
551
|
+
d3treemapDice(node, node.x0, dy2 * (node.depth + 1) / n, node.x1, dy2 * (node.depth + 2) / n);
|
|
552
|
+
}
|
|
553
|
+
var x0 = node.x0, y0 = node.y0, x1 = node.x1 - padding, y1 = node.y1 - padding;
|
|
554
|
+
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
555
|
+
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
556
|
+
node.x0 = x0;
|
|
557
|
+
node.y0 = y0;
|
|
558
|
+
node.x1 = x1;
|
|
559
|
+
node.y1 = y1;
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
__name(positionNode, "positionNode");
|
|
563
|
+
partition.round = function(x) {
|
|
564
|
+
return arguments.length ? (round = !!x, partition) : round;
|
|
565
|
+
};
|
|
566
|
+
partition.size = function(x) {
|
|
567
|
+
return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy];
|
|
568
|
+
};
|
|
569
|
+
partition.padding = function(x) {
|
|
570
|
+
return arguments.length ? (padding = +x, partition) : padding;
|
|
571
|
+
};
|
|
572
|
+
return partition;
|
|
573
|
+
}
|
|
574
|
+
__name(d3Parition, "d3Parition");
|
|
549
575
|
function defaultSeparation(a, b) {
|
|
550
|
-
|
|
576
|
+
return a.parent === b.parent ? 1 : 2;
|
|
551
577
|
}
|
|
578
|
+
__name(defaultSeparation, "defaultSeparation");
|
|
552
579
|
function nextLeft(v) {
|
|
553
|
-
|
|
554
|
-
|
|
580
|
+
var children = v.children;
|
|
581
|
+
return children ? children[0] : v.t;
|
|
555
582
|
}
|
|
583
|
+
__name(nextLeft, "nextLeft");
|
|
556
584
|
function nextRight(v) {
|
|
557
|
-
|
|
558
|
-
|
|
585
|
+
var children = v.children;
|
|
586
|
+
return children ? children[children.length - 1] : v.t;
|
|
559
587
|
}
|
|
588
|
+
__name(nextRight, "nextRight");
|
|
560
589
|
function moveSubtree(wm, wp, shift) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
590
|
+
var change = shift / (wp.i - wm.i);
|
|
591
|
+
wp.c -= change;
|
|
592
|
+
wp.s += shift;
|
|
593
|
+
wm.c += change;
|
|
594
|
+
wp.z += shift;
|
|
595
|
+
wp.m += shift;
|
|
596
|
+
}
|
|
597
|
+
__name(moveSubtree, "moveSubtree");
|
|
568
598
|
function executeShifts(v) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
599
|
+
var shift = 0, change = 0, children = v.children, i = children.length, w;
|
|
600
|
+
while (--i >= 0) {
|
|
601
|
+
w = children[i];
|
|
602
|
+
w.z += shift;
|
|
603
|
+
w.m += shift;
|
|
604
|
+
shift += w.s + (change += w.c);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
__name(executeShifts, "executeShifts");
|
|
577
608
|
function nextAncestor(vim, v, ancestor) {
|
|
578
|
-
|
|
609
|
+
return vim.a.parent === v.parent ? vim.a : ancestor;
|
|
579
610
|
}
|
|
611
|
+
__name(nextAncestor, "nextAncestor");
|
|
580
612
|
function TreeNode(node, i) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}
|
|
593
|
-
TreeNode
|
|
613
|
+
this._ = node;
|
|
614
|
+
this.parent = null;
|
|
615
|
+
this.children = null;
|
|
616
|
+
this.A = null;
|
|
617
|
+
this.a = this;
|
|
618
|
+
this.z = 0;
|
|
619
|
+
this.m = 0;
|
|
620
|
+
this.c = 0;
|
|
621
|
+
this.s = 0;
|
|
622
|
+
this.t = null;
|
|
623
|
+
this.i = i;
|
|
624
|
+
}
|
|
625
|
+
__name(TreeNode, "TreeNode");
|
|
626
|
+
TreeNode.prototype = Object.create(Node$1.prototype);
|
|
594
627
|
function treeRoot(root) {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
628
|
+
var tree = new TreeNode(root, 0), node, nodes = [tree], child, children, i, n;
|
|
629
|
+
while (node = nodes.pop()) {
|
|
630
|
+
if (children = node._.children) {
|
|
631
|
+
node.children = new Array(n = children.length);
|
|
632
|
+
for (i = n - 1; i >= 0; --i) {
|
|
633
|
+
nodes.push(child = node.children[i] = new TreeNode(children[i], i));
|
|
634
|
+
child.parent = node;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
(tree.parent = new TreeNode(null, 0)).children = [tree];
|
|
639
|
+
return tree;
|
|
640
|
+
}
|
|
641
|
+
__name(treeRoot, "treeRoot");
|
|
642
|
+
function d3Tree() {
|
|
643
|
+
var separation = defaultSeparation, dx = 1, dy = 1, nodeSize = null;
|
|
644
|
+
function tree(root) {
|
|
645
|
+
var t = treeRoot(root);
|
|
646
|
+
t.eachAfter(firstWalk), t.parent.m = -t.z;
|
|
647
|
+
t.eachBefore(secondWalk);
|
|
648
|
+
if (nodeSize) root.eachBefore(sizeNode);
|
|
649
|
+
else {
|
|
650
|
+
var left = root, right = root, bottom = root;
|
|
651
|
+
root.eachBefore(function(node) {
|
|
652
|
+
if (node.x < left.x) left = node;
|
|
653
|
+
if (node.x > right.x) right = node;
|
|
654
|
+
if (node.depth > bottom.depth) bottom = node;
|
|
655
|
+
});
|
|
656
|
+
var s = left === right ? 1 : separation(left, right) / 2, tx = s - left.x, kx = dx / (right.x + s + tx), ky = dy / (bottom.depth || 1);
|
|
657
|
+
root.eachBefore(function(node) {
|
|
658
|
+
node.x = (node.x + tx) * kx;
|
|
659
|
+
node.y = node.depth * ky;
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
return root;
|
|
663
|
+
}
|
|
664
|
+
__name(tree, "tree");
|
|
665
|
+
function firstWalk(v) {
|
|
666
|
+
var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;
|
|
667
|
+
if (children) {
|
|
668
|
+
executeShifts(v);
|
|
669
|
+
var midpoint = (children[0].z + children[children.length - 1].z) / 2;
|
|
670
|
+
if (w) {
|
|
671
|
+
v.z = w.z + separation(v._, w._);
|
|
672
|
+
v.m = v.z - midpoint;
|
|
673
|
+
} else {
|
|
674
|
+
v.z = midpoint;
|
|
675
|
+
}
|
|
676
|
+
} else if (w) {
|
|
677
|
+
v.z = w.z + separation(v._, w._);
|
|
678
|
+
}
|
|
679
|
+
v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
|
|
680
|
+
}
|
|
681
|
+
__name(firstWalk, "firstWalk");
|
|
682
|
+
function secondWalk(v) {
|
|
683
|
+
v._.x = v.z + v.parent.m;
|
|
684
|
+
v.m += v.parent.m;
|
|
685
|
+
}
|
|
686
|
+
__name(secondWalk, "secondWalk");
|
|
687
|
+
function apportion(v, w, ancestor) {
|
|
688
|
+
if (w) {
|
|
689
|
+
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;
|
|
690
|
+
while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {
|
|
691
|
+
vom = nextLeft(vom);
|
|
692
|
+
vop = nextRight(vop);
|
|
693
|
+
vop.a = v;
|
|
694
|
+
shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
|
|
695
|
+
if (shift > 0) {
|
|
696
|
+
moveSubtree(nextAncestor(vim, v, ancestor), v, shift);
|
|
697
|
+
sip += shift;
|
|
698
|
+
sop += shift;
|
|
699
|
+
}
|
|
700
|
+
sim += vim.m;
|
|
701
|
+
sip += vip.m;
|
|
702
|
+
som += vom.m;
|
|
703
|
+
sop += vop.m;
|
|
704
|
+
}
|
|
705
|
+
if (vim && !nextRight(vop)) {
|
|
706
|
+
vop.t = vim;
|
|
707
|
+
vop.m += sim - sop;
|
|
708
|
+
}
|
|
709
|
+
if (vip && !nextLeft(vom)) {
|
|
710
|
+
vom.t = vip;
|
|
711
|
+
vom.m += sip - som;
|
|
712
|
+
ancestor = v;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return ancestor;
|
|
716
|
+
}
|
|
717
|
+
__name(apportion, "apportion");
|
|
718
|
+
function sizeNode(node) {
|
|
719
|
+
node.x *= dx;
|
|
720
|
+
node.y = node.depth * dy;
|
|
721
|
+
}
|
|
722
|
+
__name(sizeNode, "sizeNode");
|
|
723
|
+
tree.separation = function(x) {
|
|
724
|
+
return arguments.length ? (separation = x, tree) : separation;
|
|
725
|
+
};
|
|
726
|
+
tree.size = function(x) {
|
|
727
|
+
return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : nodeSize ? null : [dx, dy];
|
|
728
|
+
};
|
|
729
|
+
tree.nodeSize = function(x) {
|
|
730
|
+
return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : nodeSize ? [dx, dy] : null;
|
|
731
|
+
};
|
|
732
|
+
return tree;
|
|
733
|
+
}
|
|
734
|
+
__name(d3Tree, "d3Tree");
|
|
735
|
+
function d3treemapSlice(parent, x0, y0, x1, y1) {
|
|
736
|
+
var nodes = parent.children, node, i = -1, n = nodes.length, k = parent.value && (y1 - y0) / parent.value;
|
|
737
|
+
while (++i < n) {
|
|
738
|
+
node = nodes[i], node.x0 = x0, node.x1 = x1;
|
|
739
|
+
node.y0 = y0, node.y1 = y0 += node.value * k;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
__name(d3treemapSlice, "d3treemapSlice");
|
|
702
743
|
var phi = (1 + Math.sqrt(5)) / 2;
|
|
703
744
|
function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
}
|
|
963
|
-
zoomTo(v) {
|
|
964
|
-
const k = this.diameter / v[2];
|
|
965
|
-
this.view = v;
|
|
966
|
-
this._node.attr("transform", function(d) {
|
|
967
|
-
return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")";
|
|
968
|
-
});
|
|
969
|
-
this.circle.attr("r", function(d) {
|
|
970
|
-
return d.r * k;
|
|
971
|
-
});
|
|
972
|
-
}
|
|
745
|
+
var rows = [], nodes = parent.children, row, nodeValue, i0 = 0, i1 = 0, n = nodes.length, dx, dy, value = parent.value, sumValue, minValue, maxValue, newRatio, minRatio, alpha, beta;
|
|
746
|
+
while (i0 < n) {
|
|
747
|
+
dx = x1 - x0, dy = y1 - y0;
|
|
748
|
+
do
|
|
749
|
+
sumValue = nodes[i1++].value;
|
|
750
|
+
while (!sumValue && i1 < n);
|
|
751
|
+
minValue = maxValue = sumValue;
|
|
752
|
+
alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
|
|
753
|
+
beta = sumValue * sumValue * alpha;
|
|
754
|
+
minRatio = Math.max(maxValue / beta, beta / minValue);
|
|
755
|
+
for (; i1 < n; ++i1) {
|
|
756
|
+
sumValue += nodeValue = nodes[i1].value;
|
|
757
|
+
if (nodeValue < minValue) minValue = nodeValue;
|
|
758
|
+
if (nodeValue > maxValue) maxValue = nodeValue;
|
|
759
|
+
beta = sumValue * sumValue * alpha;
|
|
760
|
+
newRatio = Math.max(maxValue / beta, beta / minValue);
|
|
761
|
+
if (newRatio > minRatio) {
|
|
762
|
+
sumValue -= nodeValue;
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
minRatio = newRatio;
|
|
766
|
+
}
|
|
767
|
+
rows.push(row = { value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1) });
|
|
768
|
+
if (row.dice) d3treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
|
|
769
|
+
else d3treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
|
|
770
|
+
value -= sumValue, i0 = i1;
|
|
771
|
+
}
|
|
772
|
+
return rows;
|
|
773
|
+
}
|
|
774
|
+
__name(squarifyRatio, "squarifyRatio");
|
|
775
|
+
const d3treemapSquarify = (/* @__PURE__ */ __name((function custom(ratio) {
|
|
776
|
+
function squarify(parent, x0, y0, x1, y1) {
|
|
777
|
+
squarifyRatio(ratio, parent, x0, y0, x1, y1);
|
|
778
|
+
}
|
|
779
|
+
__name(squarify, "squarify");
|
|
780
|
+
squarify.ratio = function(x) {
|
|
781
|
+
return custom((x = +x) > 1 ? x : 1);
|
|
782
|
+
};
|
|
783
|
+
return squarify;
|
|
784
|
+
}), "custom"))(phi);
|
|
785
|
+
function d3Treemap() {
|
|
786
|
+
var tile = d3treemapSquarify, round = false, dx = 1, dy = 1, paddingStack = [0], paddingInner = constantZero, paddingTop = constantZero, paddingRight = constantZero, paddingBottom = constantZero, paddingLeft = constantZero;
|
|
787
|
+
function treemap(root) {
|
|
788
|
+
root.x0 = root.y0 = 0;
|
|
789
|
+
root.x1 = dx;
|
|
790
|
+
root.y1 = dy;
|
|
791
|
+
root.eachBefore(positionNode);
|
|
792
|
+
paddingStack = [0];
|
|
793
|
+
if (round) root.eachBefore(roundNode);
|
|
794
|
+
return root;
|
|
795
|
+
}
|
|
796
|
+
__name(treemap, "treemap");
|
|
797
|
+
function positionNode(node) {
|
|
798
|
+
var p = paddingStack[node.depth], x0 = node.x0 + p, y0 = node.y0 + p, x1 = node.x1 - p, y1 = node.y1 - p;
|
|
799
|
+
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
800
|
+
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
801
|
+
node.x0 = x0;
|
|
802
|
+
node.y0 = y0;
|
|
803
|
+
node.x1 = x1;
|
|
804
|
+
node.y1 = y1;
|
|
805
|
+
if (node.children) {
|
|
806
|
+
p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
|
|
807
|
+
x0 += paddingLeft(node) - p;
|
|
808
|
+
y0 += paddingTop(node) - p;
|
|
809
|
+
x1 -= paddingRight(node) - p;
|
|
810
|
+
y1 -= paddingBottom(node) - p;
|
|
811
|
+
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
812
|
+
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
813
|
+
tile(node, x0, y0, x1, y1);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
__name(positionNode, "positionNode");
|
|
817
|
+
treemap.round = function(x) {
|
|
818
|
+
return arguments.length ? (round = !!x, treemap) : round;
|
|
819
|
+
};
|
|
820
|
+
treemap.size = function(x) {
|
|
821
|
+
return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
|
|
822
|
+
};
|
|
823
|
+
treemap.tile = function(x) {
|
|
824
|
+
return arguments.length ? (tile = required(x), treemap) : tile;
|
|
825
|
+
};
|
|
826
|
+
treemap.padding = function(x) {
|
|
827
|
+
return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
|
|
828
|
+
};
|
|
829
|
+
treemap.paddingInner = function(x) {
|
|
830
|
+
return arguments.length ? (paddingInner = typeof x === "function" ? x : constant$1(+x), treemap) : paddingInner;
|
|
831
|
+
};
|
|
832
|
+
treemap.paddingOuter = function(x) {
|
|
833
|
+
return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
|
|
834
|
+
};
|
|
835
|
+
treemap.paddingTop = function(x) {
|
|
836
|
+
return arguments.length ? (paddingTop = typeof x === "function" ? x : constant$1(+x), treemap) : paddingTop;
|
|
837
|
+
};
|
|
838
|
+
treemap.paddingRight = function(x) {
|
|
839
|
+
return arguments.length ? (paddingRight = typeof x === "function" ? x : constant$1(+x), treemap) : paddingRight;
|
|
840
|
+
};
|
|
841
|
+
treemap.paddingBottom = function(x) {
|
|
842
|
+
return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant$1(+x), treemap) : paddingBottom;
|
|
843
|
+
};
|
|
844
|
+
treemap.paddingLeft = function(x) {
|
|
845
|
+
return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant$1(+x), treemap) : paddingLeft;
|
|
846
|
+
};
|
|
847
|
+
return treemap;
|
|
848
|
+
}
|
|
849
|
+
__name(d3Treemap, "d3Treemap");
|
|
850
|
+
function d3treemapBinary(parent, x0, y0, x1, y1) {
|
|
851
|
+
var nodes = parent.children, i, n = nodes.length, sum, sums = new Array(n + 1);
|
|
852
|
+
for (sums[0] = sum = i = 0; i < n; ++i) {
|
|
853
|
+
sums[i + 1] = sum += nodes[i].value;
|
|
854
|
+
}
|
|
855
|
+
partition(0, n, parent.value, x0, y0, x1, y1);
|
|
856
|
+
function partition(i2, j, value, x02, y02, x12, y12) {
|
|
857
|
+
if (i2 >= j - 1) {
|
|
858
|
+
var node = nodes[i2];
|
|
859
|
+
node.x0 = x02, node.y0 = y02;
|
|
860
|
+
node.x1 = x12, node.y1 = y12;
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
var valueOffset = sums[i2], valueTarget = value / 2 + valueOffset, k = i2 + 1, hi = j - 1;
|
|
864
|
+
while (k < hi) {
|
|
865
|
+
var mid = k + hi >>> 1;
|
|
866
|
+
if (sums[mid] < valueTarget) k = mid + 1;
|
|
867
|
+
else hi = mid;
|
|
868
|
+
}
|
|
869
|
+
if (valueTarget - sums[k - 1] < sums[k] - valueTarget && i2 + 1 < k) --k;
|
|
870
|
+
var valueLeft = sums[k] - valueOffset, valueRight = value - valueLeft;
|
|
871
|
+
if (x12 - x02 > y12 - y02) {
|
|
872
|
+
var xk = (x02 * valueRight + x12 * valueLeft) / value;
|
|
873
|
+
partition(i2, k, valueLeft, x02, y02, xk, y12);
|
|
874
|
+
partition(k, j, valueRight, xk, y02, x12, y12);
|
|
875
|
+
} else {
|
|
876
|
+
var yk = (y02 * valueRight + y12 * valueLeft) / value;
|
|
877
|
+
partition(i2, k, valueLeft, x02, y02, x12, yk);
|
|
878
|
+
partition(k, j, valueRight, x02, yk, x12, y12);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
__name(partition, "partition");
|
|
882
|
+
}
|
|
883
|
+
__name(d3treemapBinary, "d3treemapBinary");
|
|
884
|
+
function d3treemapSliceDice(parent, x0, y0, x1, y1) {
|
|
885
|
+
(parent.depth & 1 ? d3treemapSlice : d3treemapDice)(parent, x0, y0, x1, y1);
|
|
886
|
+
}
|
|
887
|
+
__name(d3treemapSliceDice, "d3treemapSliceDice");
|
|
888
|
+
const d3treemapResquarify = (/* @__PURE__ */ __name((function custom2(ratio) {
|
|
889
|
+
function resquarify(parent, x0, y0, x1, y1) {
|
|
890
|
+
if ((rows = parent._squarify) && rows.ratio === ratio) {
|
|
891
|
+
var rows, row, nodes, i, j = -1, n, m = rows.length, value = parent.value;
|
|
892
|
+
while (++j < m) {
|
|
893
|
+
row = rows[j], nodes = row.children;
|
|
894
|
+
for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
|
|
895
|
+
if (row.dice) d3treemapDice(row, x0, y0, x1, y0 += (y1 - y0) * row.value / value);
|
|
896
|
+
else d3treemapSlice(row, x0, y0, x0 += (x1 - x0) * row.value / value, y1);
|
|
897
|
+
value -= row.value;
|
|
898
|
+
}
|
|
899
|
+
} else {
|
|
900
|
+
parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
|
|
901
|
+
rows.ratio = ratio;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
__name(resquarify, "resquarify");
|
|
905
|
+
resquarify.ratio = function(x) {
|
|
906
|
+
return custom2((x = +x) > 1 ? x : 1);
|
|
907
|
+
};
|
|
908
|
+
return resquarify;
|
|
909
|
+
}), "custom"))(phi);
|
|
910
|
+
const _CirclePacking = class _CirclePacking extends SVGWidget {
|
|
911
|
+
diameter;
|
|
912
|
+
pack;
|
|
913
|
+
svg;
|
|
914
|
+
_focus;
|
|
915
|
+
circle;
|
|
916
|
+
view;
|
|
917
|
+
_node;
|
|
918
|
+
constructor() {
|
|
919
|
+
super();
|
|
920
|
+
ITree.call(this);
|
|
921
|
+
}
|
|
922
|
+
enter(_domNode, element) {
|
|
923
|
+
this.diameter = Math.min(this.width(), this.height());
|
|
924
|
+
this.pack = d3Pack().size([this.diameter - 4, this.diameter - 4]).padding(1.5);
|
|
925
|
+
this.svg = element.append("g");
|
|
926
|
+
}
|
|
927
|
+
update(_domNode, _element) {
|
|
928
|
+
const context = this;
|
|
929
|
+
this.diameter = Math.min(this.width(), this.height());
|
|
930
|
+
this.pack.size([this.diameter - 4, this.diameter - 4]).padding(1.5);
|
|
931
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
932
|
+
if (this.useClonedPalette()) {
|
|
933
|
+
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
934
|
+
}
|
|
935
|
+
this.svg.selectAll("circle").remove();
|
|
936
|
+
this.svg.selectAll("text").remove();
|
|
937
|
+
const root = hierarchy(this.data()).sum(function(d) {
|
|
938
|
+
return d && d.size ? d.size : 1;
|
|
939
|
+
}).sort(function(a, b) {
|
|
940
|
+
return a.value < b.value ? -1 : a.value > b.value ? 1 : 0;
|
|
941
|
+
});
|
|
942
|
+
this._focus = root;
|
|
943
|
+
this.pack(root);
|
|
944
|
+
this.circle = this.svg.selectAll("circle").data(root.descendants()).enter().append("circle").attr("class", function(d) {
|
|
945
|
+
return d.parent ? d.children ? "node" : "node leaf" : "node root";
|
|
946
|
+
}).style("fill", function(d) {
|
|
947
|
+
d.color = context.paletteDepthLevel_exists() && d.depth > context.paletteDepthLevel() ? rgb(d.parent.color)[context.paletteDepthVariant()](1) : context._palette(d.data.label);
|
|
948
|
+
return d.color;
|
|
949
|
+
}).on("click", function(d) {
|
|
950
|
+
context.click(d.data, null, null);
|
|
951
|
+
}).on("dblclick", function(d) {
|
|
952
|
+
if (this._focus !== d) {
|
|
953
|
+
context.zoom(d);
|
|
954
|
+
}
|
|
955
|
+
d3Event().stopPropagation();
|
|
956
|
+
});
|
|
957
|
+
this.circle.append("title").text(function(d) {
|
|
958
|
+
return d.data.label;
|
|
959
|
+
});
|
|
960
|
+
this.svg.selectAll("text").data(root.descendants()).enter().append("text").attr("class", "label").style("fill-opacity", function(d) {
|
|
961
|
+
return d.parent === root ? 1 : 0;
|
|
962
|
+
}).style("display", function(d) {
|
|
963
|
+
return d.parent === root ? null : "none";
|
|
964
|
+
}).text(function(d) {
|
|
965
|
+
return d.data.label + (context.showSize() && typeof d.data.size !== "undefined" ? " " + d.data.size : "");
|
|
966
|
+
});
|
|
967
|
+
this._node = this.svg.selectAll("circle,text");
|
|
968
|
+
this.zoomTo([root.x, root.y, root.r * 2]);
|
|
969
|
+
}
|
|
970
|
+
zoom(newFocus) {
|
|
971
|
+
this._focus = newFocus;
|
|
972
|
+
const context = this;
|
|
973
|
+
const transition = this.svg.transition().duration(d3Event().altKey ? 7500 : 750).tween("zoom", function() {
|
|
974
|
+
const i = interpolateZoom(context.view, [context._focus.x, context._focus.y, context._focus.r * 2]);
|
|
975
|
+
return function(t) {
|
|
976
|
+
context.zoomTo(i(t));
|
|
977
|
+
};
|
|
978
|
+
});
|
|
979
|
+
function showText(d) {
|
|
980
|
+
return d === context._focus && !d.children || d.parent === context._focus;
|
|
981
|
+
}
|
|
982
|
+
__name(showText, "showText");
|
|
983
|
+
transition.selectAll("text").filter(function(d) {
|
|
984
|
+
return showText(d) || this.style.display === "inline";
|
|
985
|
+
}).style("fill-opacity", function(d) {
|
|
986
|
+
return showText(d) ? 1 : 0;
|
|
987
|
+
}).on("start", function(d) {
|
|
988
|
+
if (showText(d)) this.style.display = "inline";
|
|
989
|
+
}).on("end", function(d) {
|
|
990
|
+
if (!showText(d)) this.style.display = "none";
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
zoomTo(v) {
|
|
994
|
+
const k = this.diameter / v[2];
|
|
995
|
+
this.view = v;
|
|
996
|
+
this._node.attr("transform", function(d) {
|
|
997
|
+
return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")";
|
|
998
|
+
});
|
|
999
|
+
this.circle.attr("r", function(d) {
|
|
1000
|
+
return d.r * k;
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
973
1003
|
};
|
|
1004
|
+
__name(_CirclePacking, "CirclePacking");
|
|
1005
|
+
let CirclePacking = _CirclePacking;
|
|
974
1006
|
CirclePacking.prototype._class += " tree_CirclePacking";
|
|
975
1007
|
CirclePacking.prototype.implements(ITree.prototype);
|
|
976
1008
|
CirclePacking.prototype.publish("showSize", true, "boolean", "Show size along with label");
|
|
977
1009
|
CirclePacking.prototype.publish("paletteDepthLevel", null, "number", "If not null then beyond this depth number the child node colors are based on parent", null, { optional: true });
|
|
978
|
-
CirclePacking.prototype.publish("paletteDepthVariant", "brighter", "set", "Determines paletteDepthLevel decendant color shade variant", ["brighter", "darker"], { disable: (w) => w.paletteDepthLevel_exists() });
|
|
1010
|
+
CirclePacking.prototype.publish("paletteDepthVariant", "brighter", "set", "Determines paletteDepthLevel decendant color shade variant", ["brighter", "darker"], { disable: /* @__PURE__ */ __name((w) => w.paletteDepthLevel_exists(), "disable") });
|
|
979
1011
|
CirclePacking.prototype.publish("paletteID", "default", "set", "Color palette for this widget", CirclePacking.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
980
1012
|
CirclePacking.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
return !!this.column();
|
|
996
|
-
}
|
|
997
|
-
column;
|
|
1013
|
+
const _DendrogramColumn = class _DendrogramColumn extends PropertyExt {
|
|
1014
|
+
_owner;
|
|
1015
|
+
constructor() {
|
|
1016
|
+
super();
|
|
1017
|
+
}
|
|
1018
|
+
owner(_) {
|
|
1019
|
+
if (!arguments.length) return this._owner;
|
|
1020
|
+
this._owner = _;
|
|
1021
|
+
return this;
|
|
1022
|
+
}
|
|
1023
|
+
valid() {
|
|
1024
|
+
return !!this.column();
|
|
1025
|
+
}
|
|
1026
|
+
column;
|
|
998
1027
|
};
|
|
1028
|
+
__name(_DendrogramColumn, "DendrogramColumn");
|
|
1029
|
+
let DendrogramColumn = _DendrogramColumn;
|
|
999
1030
|
DendrogramColumn.prototype._class += " tree_Dendrogram.DendrogramColumn";
|
|
1000
1031
|
DendrogramColumn.prototype.publish("column", null, "set", "Field", function() {
|
|
1001
|
-
|
|
1032
|
+
return this._owner ? this._owner.columns() : [];
|
|
1002
1033
|
}, { optional: true });
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1034
|
+
const _Dendrogram = class _Dendrogram extends SVGZoomWidget {
|
|
1035
|
+
Column;
|
|
1036
|
+
_d3LayoutCluster;
|
|
1037
|
+
_d3LayoutTree;
|
|
1038
|
+
_d3Layout;
|
|
1039
|
+
constructor() {
|
|
1040
|
+
super();
|
|
1041
|
+
ITree.call(this);
|
|
1042
|
+
Utility.SimpleSelectionMixin.call(this);
|
|
1043
|
+
this._drawStartPos = "origin";
|
|
1044
|
+
this._d3LayoutCluster = d3Cluster();
|
|
1045
|
+
this._d3LayoutTree = d3Tree();
|
|
1046
|
+
}
|
|
1047
|
+
dendrogramData() {
|
|
1048
|
+
if (this.data().length === 0) return [];
|
|
1049
|
+
if (!this.mappings().filter((mapping) => mapping.valid()).length) {
|
|
1050
|
+
return this.data();
|
|
1051
|
+
}
|
|
1052
|
+
const view = this._db.rollupView(this.mappings().map(function(mapping) {
|
|
1053
|
+
return mapping.column();
|
|
1054
|
+
}));
|
|
1055
|
+
const retVal = {
|
|
1056
|
+
key: "root",
|
|
1057
|
+
values: view.entries()
|
|
1058
|
+
};
|
|
1059
|
+
return formatData(retVal);
|
|
1060
|
+
function formatData(node) {
|
|
1061
|
+
return {
|
|
1062
|
+
label: node.key,
|
|
1063
|
+
children: node.values.filter(function(value) {
|
|
1064
|
+
return !(value instanceof Array);
|
|
1065
|
+
}).map(function(value) {
|
|
1066
|
+
return formatData(value);
|
|
1067
|
+
}),
|
|
1068
|
+
origRows: node.values
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
__name(formatData, "formatData");
|
|
1072
|
+
}
|
|
1073
|
+
enter(domNode, element) {
|
|
1074
|
+
super.enter(domNode, element);
|
|
1075
|
+
this._renderElement.attr("opacity", 0).transition().duration(500).attr("opacity", 1);
|
|
1076
|
+
this._selection.widgetElement(this._renderElement);
|
|
1077
|
+
}
|
|
1078
|
+
update(domNode, element) {
|
|
1079
|
+
super.update(domNode, element);
|
|
1080
|
+
const context = this;
|
|
1081
|
+
const isVertical = this.orientation() === "vertical";
|
|
1082
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
1083
|
+
if (this.useClonedPalette()) {
|
|
1084
|
+
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
1085
|
+
}
|
|
1086
|
+
this._d3Layout = this.dendrogram() ? this._d3LayoutCluster : this._d3LayoutTree;
|
|
1087
|
+
if (this.radial()) {
|
|
1088
|
+
this._d3Layout.size([360, this.separation() * 2]);
|
|
1089
|
+
this._d3Layout.separation(/* @__PURE__ */ __name(function separation(a, b) {
|
|
1090
|
+
return (a.parent === b.parent ? 1 : 2) / a.depth;
|
|
1091
|
+
}, "separation"));
|
|
1092
|
+
} else {
|
|
1093
|
+
this._d3Layout.nodeSize([14, this.separation()]);
|
|
1094
|
+
this._d3Layout.separation(/* @__PURE__ */ __name(function separation(a, b) {
|
|
1095
|
+
return a.parent === b.parent ? 1 : 2;
|
|
1096
|
+
}, "separation"));
|
|
1097
|
+
}
|
|
1098
|
+
const data = this.dendrogramData();
|
|
1099
|
+
const root = hierarchy(data);
|
|
1100
|
+
this._d3Layout(root);
|
|
1101
|
+
const dataNodes = root.descendants();
|
|
1102
|
+
const links = root.descendants().slice(1);
|
|
1103
|
+
function linkVertical(d) {
|
|
1104
|
+
return "M" + d.parent.x + "," + d.parent.y + "C" + d.parent.x + "," + (d.parent.y + d.y) / 2 + " " + d.x + "," + (d.parent.y + d.y) / 2 + " " + d.x + "," + d.y;
|
|
1105
|
+
}
|
|
1106
|
+
__name(linkVertical, "linkVertical");
|
|
1107
|
+
function linkHorizontal(d) {
|
|
1108
|
+
return "M" + d.y + "," + d.x + "C" + (d.y + d.parent.y) / 2 + "," + d.x + " " + (d.y + d.parent.y) / 2 + "," + d.parent.x + " " + d.parent.y + "," + d.parent.x;
|
|
1109
|
+
}
|
|
1110
|
+
__name(linkHorizontal, "linkHorizontal");
|
|
1111
|
+
function diagonal(d) {
|
|
1112
|
+
return isVertical ? linkVertical(d) : linkHorizontal(d);
|
|
1113
|
+
}
|
|
1114
|
+
__name(diagonal, "diagonal");
|
|
1115
|
+
function project(x, y) {
|
|
1116
|
+
const angle = (x - 90) / 180 * Math.PI;
|
|
1117
|
+
const radius = y;
|
|
1118
|
+
return [radius * Math.cos(angle), radius * Math.sin(angle)];
|
|
1119
|
+
}
|
|
1120
|
+
__name(project, "project");
|
|
1121
|
+
function radialDiagonal(d) {
|
|
1122
|
+
return "M" + project(d.x, d.y) + "C" + project(d.x, (d.y + d.parent.y) / 2) + " " + project(d.parent.x, (d.y + d.parent.y) / 2) + " " + project(d.parent.x, d.parent.y);
|
|
1123
|
+
}
|
|
1124
|
+
__name(radialDiagonal, "radialDiagonal");
|
|
1125
|
+
const transitionDuration = this._renderCount ? 500 : 0;
|
|
1126
|
+
const lines = this._renderElement.selectAll(".link").data(links);
|
|
1127
|
+
lines.enter().append("path").attr("class", "link").attr("d", this.radial() ? radialDiagonal : diagonal);
|
|
1128
|
+
lines.transition().duration(transitionDuration).attr("d", this.radial() ? radialDiagonal : diagonal);
|
|
1129
|
+
lines.exit().remove();
|
|
1130
|
+
const textOffsetX = this.circleRadius() + 2;
|
|
1131
|
+
function nodeTransform(d) {
|
|
1132
|
+
if (context.radial()) {
|
|
1133
|
+
return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")";
|
|
1134
|
+
}
|
|
1135
|
+
return context.orientation() === "horizontal" ? "translate(" + d.y + "," + d.x + ")" : "translate(" + d.x + "," + d.y + ")";
|
|
1136
|
+
}
|
|
1137
|
+
__name(nodeTransform, "nodeTransform");
|
|
1138
|
+
const nodes = this._renderElement.selectAll(".node").data(dataNodes);
|
|
1139
|
+
nodes.transition().duration(transitionDuration).attr("transform", nodeTransform);
|
|
1140
|
+
const enterNodes = nodes.enter().append("g").attr("class", "node").attr("transform", nodeTransform).call(this._selection.enter.bind(this._selection)).on("click", function(d) {
|
|
1141
|
+
let tmp = d;
|
|
1142
|
+
while (tmp.children) {
|
|
1143
|
+
tmp = tmp.children[0];
|
|
1144
|
+
}
|
|
1145
|
+
if (d.depth > 0) {
|
|
1146
|
+
if (tmp.origRows) {
|
|
1147
|
+
context.click(context.rowToObj(tmp.origRows[0]), context.mappings()[d.depth - 1].column(), true);
|
|
1148
|
+
} else {
|
|
1149
|
+
context.click(tmp.data, context.mappings()[d.depth - 1].column(), true);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}).on("dblclick", function(d) {
|
|
1153
|
+
let tmp = d;
|
|
1154
|
+
while (tmp.children) {
|
|
1155
|
+
tmp = tmp.children[0];
|
|
1156
|
+
}
|
|
1157
|
+
if (d.depth > 0) {
|
|
1158
|
+
if (tmp.origRows) {
|
|
1159
|
+
context.dblclick(context.rowToObj(tmp.origRows[0]), context.mappings()[d.depth - 1].column(), true);
|
|
1160
|
+
} else {
|
|
1161
|
+
context.dblclick(tmp.data, context.mappings()[d.depth - 1].column(), true);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}).each(function() {
|
|
1165
|
+
const e = select(this);
|
|
1166
|
+
e.append("circle");
|
|
1167
|
+
e.append("text");
|
|
1168
|
+
});
|
|
1169
|
+
enterNodes.merge(nodes).select("circle").attr("r", this.circleRadius()).style("fill", function(d) {
|
|
1170
|
+
return context._palette(d.data.label);
|
|
1171
|
+
}).append("title").text(function(d) {
|
|
1172
|
+
return d.data.label;
|
|
1173
|
+
});
|
|
1174
|
+
enterNodes.merge(nodes).select("text").attr("dx", function(d) {
|
|
1175
|
+
if (context.radial()) {
|
|
1176
|
+
if (d.children) {
|
|
1177
|
+
return d.x < 180 ? -textOffsetX : textOffsetX;
|
|
1178
|
+
} else {
|
|
1179
|
+
return d.x < 180 ? textOffsetX : -textOffsetX;
|
|
1180
|
+
}
|
|
1181
|
+
} else if (isVertical) {
|
|
1182
|
+
return d.children ? textOffsetX : -textOffsetX;
|
|
1183
|
+
}
|
|
1184
|
+
return d.children ? -textOffsetX : textOffsetX;
|
|
1185
|
+
}).attr("dy", "0.25em").style("text-anchor", function(d) {
|
|
1186
|
+
if (context.radial()) {
|
|
1187
|
+
if (d.children) {
|
|
1188
|
+
return d.x < 180 ? "end" : "start";
|
|
1189
|
+
} else {
|
|
1190
|
+
return d.x < 180 ? "start" : "end";
|
|
1191
|
+
}
|
|
1192
|
+
} else if (isVertical) {
|
|
1193
|
+
return d.children ? "start" : "end";
|
|
1194
|
+
}
|
|
1195
|
+
return d.children ? "end" : "start";
|
|
1196
|
+
}).attr("transform", function(d) {
|
|
1197
|
+
if (context.radial()) {
|
|
1198
|
+
return d.x < 180 ? null : "rotate(180)";
|
|
1199
|
+
} else if (isVertical) {
|
|
1200
|
+
return "rotate(-66)";
|
|
1201
|
+
}
|
|
1202
|
+
return null;
|
|
1203
|
+
}).text(function(d) {
|
|
1204
|
+
return d.data.label;
|
|
1205
|
+
});
|
|
1206
|
+
nodes.exit().remove();
|
|
1207
|
+
if (!this._renderCount) {
|
|
1208
|
+
context.zoomToFit();
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1133
1211
|
};
|
|
1212
|
+
__name(_Dendrogram, "Dendrogram");
|
|
1213
|
+
let Dendrogram = _Dendrogram;
|
|
1134
1214
|
Dendrogram.prototype._class += " tree_Dendrogram";
|
|
1135
1215
|
Dendrogram.prototype.implements(ITree.prototype);
|
|
1136
1216
|
Dendrogram.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
@@ -1142,133 +1222,162 @@ Dendrogram.prototype.publish("circleRadius", 4.5, "number", "Text offset from ci
|
|
|
1142
1222
|
Dendrogram.prototype.publish("separation", 240, "number", "Leaf Separation");
|
|
1143
1223
|
Dendrogram.prototype.publish("dendrogram", true, "boolean", "Dendrogram");
|
|
1144
1224
|
Dendrogram.prototype.publish("radial", false, "boolean", "Radial");
|
|
1145
|
-
Dendrogram.prototype.publish("orientation", "horizontal", "set", "Orientation", ["horizontal", "vertical"], {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1225
|
+
Dendrogram.prototype.publish("orientation", "horizontal", "set", "Orientation", ["horizontal", "vertical"], { tags: ["Private"], disable: /* @__PURE__ */ __name((w) => w.radial(), "disable") });
|
|
1226
|
+
const _DirectoryTree = class _DirectoryTree extends HTMLWidget {
|
|
1227
|
+
constructor() {
|
|
1228
|
+
super();
|
|
1229
|
+
}
|
|
1230
|
+
flattenData(json) {
|
|
1231
|
+
const context = this;
|
|
1232
|
+
const root = hierarchy(json);
|
|
1233
|
+
const ret = [];
|
|
1234
|
+
if (!this.omitRoot()) {
|
|
1235
|
+
visitNode(root);
|
|
1236
|
+
} else if (root.children) {
|
|
1237
|
+
root.children.forEach(visitNode);
|
|
1238
|
+
}
|
|
1239
|
+
return ret;
|
|
1240
|
+
function visitNode(node) {
|
|
1241
|
+
const weightValue = node.data.markers && node.data.markers.length ? node.data.markers.length : "";
|
|
1242
|
+
ret.push({
|
|
1243
|
+
label: node.data.label,
|
|
1244
|
+
depth: node.depth - (context.omitRoot() ? 1 : 0),
|
|
1245
|
+
content: node.data.content,
|
|
1246
|
+
isFolder: !!node.data.children,
|
|
1247
|
+
iconClass: node.data.iconClass,
|
|
1248
|
+
color: node.data.color,
|
|
1249
|
+
bold: node.data.bold,
|
|
1250
|
+
weightValue,
|
|
1251
|
+
markers: node.data.markers,
|
|
1252
|
+
selected: node.data.selected
|
|
1253
|
+
});
|
|
1254
|
+
if (node.children) {
|
|
1255
|
+
node.children.forEach(visitNode);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
__name(visitNode, "visitNode");
|
|
1259
|
+
}
|
|
1260
|
+
iconClass(d) {
|
|
1261
|
+
if (d.label === "error") {
|
|
1262
|
+
return "fa fa-exclamation";
|
|
1263
|
+
}
|
|
1264
|
+
if (d.isFolder) {
|
|
1265
|
+
return this.folderIconOpen();
|
|
1266
|
+
}
|
|
1267
|
+
return this.textFileIcon();
|
|
1268
|
+
}
|
|
1269
|
+
calcRequiredWidth() {
|
|
1270
|
+
const flatData = this.flattenData(this.data());
|
|
1271
|
+
let widest = 0;
|
|
1272
|
+
const padding = this.rowItemPadding();
|
|
1273
|
+
const iconWidth = this.iconSize() + padding * 2;
|
|
1274
|
+
const scrollbarWidth = Platform.getScrollbarWidth();
|
|
1275
|
+
flatData.forEach((row) => {
|
|
1276
|
+
const offsetWidth = row.depth * iconWidth + padding * 2;
|
|
1277
|
+
const textWidth = Utility.textSize(
|
|
1278
|
+
row.label,
|
|
1279
|
+
this.fontFamily(),
|
|
1280
|
+
this.fontSize(),
|
|
1281
|
+
!!row.bold
|
|
1282
|
+
).width + padding * 2;
|
|
1283
|
+
const totalWidth = textWidth + iconWidth + offsetWidth + scrollbarWidth;
|
|
1284
|
+
if (widest < totalWidth) {
|
|
1285
|
+
widest = totalWidth;
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
return widest;
|
|
1289
|
+
}
|
|
1290
|
+
rowClick(str, markers) {
|
|
1291
|
+
}
|
|
1292
|
+
enter(domNode, element) {
|
|
1293
|
+
super.enter(domNode, element);
|
|
1294
|
+
element.style("width", "100%").style("height", "100%");
|
|
1295
|
+
}
|
|
1296
|
+
update(domNode, element) {
|
|
1297
|
+
super.update(domNode, element);
|
|
1298
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
1299
|
+
element.style("overflow-y", this.verticalScroll() ? "scroll" : null);
|
|
1300
|
+
const flatData = this.flattenData(this.data());
|
|
1301
|
+
const maxWeightValue = max$1(flatData, (n) => Number(n.weightValue));
|
|
1302
|
+
flatData.forEach((d) => {
|
|
1303
|
+
if (!d.weightValue) {
|
|
1304
|
+
d.weightColor = "transparent";
|
|
1305
|
+
} else {
|
|
1306
|
+
d.weightColor = this._palette(d.weightValue, 1, maxWeightValue);
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
const context = this;
|
|
1310
|
+
const padding = this.rowItemPadding();
|
|
1311
|
+
const iconWidth = this.iconSize() + padding;
|
|
1312
|
+
const lineHeight = Math.max(context.iconSize(), context.fontSize());
|
|
1313
|
+
const rowSelection = element.selectAll(".directory-row").data(flatData);
|
|
1314
|
+
const fontFamily = this.fontFamily();
|
|
1315
|
+
const fontSize = this.fontSize();
|
|
1316
|
+
const maxWeightWidth = max$1(flatData, (d) => this.textSize(d.weightValue, fontFamily, fontSize).width);
|
|
1317
|
+
const rowItemPadding = `${padding}px ${padding}px ${padding / 2}px ${padding}px`;
|
|
1318
|
+
const rowEnter = rowSelection.enter().append("div").attr("class", (d) => `directory-row directory-row-depth-${d.depth}`).style("display", "flex").style("cursor", "pointer").each(function(d) {
|
|
1319
|
+
const rowDiv = select(this);
|
|
1320
|
+
const fontColor = d.color ? d.color : context.fontColor();
|
|
1321
|
+
const weightColor = d.weightColor ? d.weightColor : "transparent";
|
|
1322
|
+
const weightFontColor = Palette.textColor(weightColor);
|
|
1323
|
+
const weightDiv = rowDiv.append("div").attr("class", "row-weight").style("padding", rowItemPadding).style("color", weightFontColor).style("box-shadow", `inset 0 0 100px ${weightColor}`).style("font-weight", d.bold ? "bold" : "normal").style("font-family", fontFamily).style("font-size", fontSize + "px").text(d.weightValue).attr("title", d.weightValue).style("overflow", "hidden").style("width", maxWeightWidth + padding * 2 + "px").style("text-overflow", "ellipsis").style("text-align", "right").style("line-height", lineHeight + "px");
|
|
1324
|
+
rowDiv.append("div").attr("class", "row-depth").style("width", context.depthSize() * d.depth + "px").style("opacity", 1).style("line-height", lineHeight + "px");
|
|
1325
|
+
const iconDiv = rowDiv.append("div").attr("class", "row-icon " + (d.iconClass ? d.iconClass : context.iconClass(d))).style("width", iconWidth + "px").style("height", lineHeight + "px").style("color", fontColor).style("background-color", d.selected ? context.selectionBackgroundColor() : "transparent").style("font-size", context.iconSize() + "px").style("padding", rowItemPadding).style("line-height", lineHeight + "px");
|
|
1326
|
+
const labelDiv = rowDiv.append("div").attr("class", "row-label").style("padding", rowItemPadding).style("color", fontColor).style("background-color", d.selected ? context.selectionBackgroundColor() : "transparent").style("font-weight", d.bold ? "bold" : "normal").style("font-family", context.fontFamily()).style("font-size", context.fontSize() + "px").text(d.label).attr("title", d.label).style("flex", 1).style("overflow", "hidden").style("text-overflow", "ellipsis").style("line-height", lineHeight + "px");
|
|
1327
|
+
rowDiv.on("mouseenter", () => {
|
|
1328
|
+
labelDiv.style("font-weight", "bold");
|
|
1329
|
+
}).on("mouseleave", () => {
|
|
1330
|
+
labelDiv.style("font-weight", d.bold ? "bold" : "normal");
|
|
1331
|
+
});
|
|
1332
|
+
weightDiv.on("mouseenter", () => {
|
|
1333
|
+
context.weight_mouseenter(d);
|
|
1334
|
+
}).on("mouseleave", () => {
|
|
1335
|
+
context.weight_mouseleave(d);
|
|
1336
|
+
});
|
|
1337
|
+
if (d.isFolder) {
|
|
1338
|
+
rowDiv.on("click", function(d2) {
|
|
1339
|
+
let next = this.nextSibling;
|
|
1340
|
+
const wasClosed = rowDiv.classed("folder-closed");
|
|
1341
|
+
if (wasClosed) {
|
|
1342
|
+
rowDiv.classed("folder-closed", false);
|
|
1343
|
+
rowDiv.classed("folder-open", true);
|
|
1344
|
+
iconDiv.attr("class", "row-icon " + context.folderIconOpen());
|
|
1345
|
+
} else {
|
|
1346
|
+
rowDiv.classed("folder-closed", true);
|
|
1347
|
+
rowDiv.classed("folder-open", false);
|
|
1348
|
+
iconDiv.attr("class", "row-icon " + context.folderIconClosed());
|
|
1349
|
+
}
|
|
1350
|
+
while (next !== null) {
|
|
1351
|
+
const nextDepth = select(next).datum().depth;
|
|
1352
|
+
if (nextDepth > d2.depth) {
|
|
1353
|
+
next.style.display = wasClosed ? "flex" : "none";
|
|
1354
|
+
next = next.nextSibling;
|
|
1355
|
+
} else {
|
|
1356
|
+
next = null;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
} else {
|
|
1361
|
+
rowDiv.on("click", () => {
|
|
1362
|
+
element.selectAll(".row-label").style("background-color", "transparent");
|
|
1363
|
+
element.selectAll(".row-icon").style("background-color", "transparent");
|
|
1364
|
+
iconDiv.style("background-color", context.selectionBackgroundColor());
|
|
1365
|
+
labelDiv.style("background-color", context.selectionBackgroundColor());
|
|
1366
|
+
const ext = d.label.split(".").pop().toLowerCase();
|
|
1367
|
+
context.rowClick(ext === "json" ? JSON.stringify(JSON.parse(d.content), null, 4) : d.content, d.markers);
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
rowEnter.merge(rowSelection).style("background-color", context.backgroundColor());
|
|
1372
|
+
rowSelection.exit().remove();
|
|
1373
|
+
}
|
|
1374
|
+
weight_mouseenter(d) {
|
|
1375
|
+
}
|
|
1376
|
+
weight_mouseleave(d) {
|
|
1377
|
+
}
|
|
1271
1378
|
};
|
|
1379
|
+
__name(_DirectoryTree, "DirectoryTree");
|
|
1380
|
+
let DirectoryTree = _DirectoryTree;
|
|
1272
1381
|
DirectoryTree.prototype._class += " tree_DirectoryTree";
|
|
1273
1382
|
DirectoryTree.prototype._palette = Palette.rainbow("Blues");
|
|
1274
1383
|
DirectoryTree.prototype.publish("depthSize", 14, "number", "Width of indentation per file or folder depth (pixels)");
|
|
@@ -1285,273 +1394,307 @@ DirectoryTree.prototype.publish("folderIconOpen", "fa fa-folder-open", "string",
|
|
|
1285
1394
|
DirectoryTree.prototype.publish("folderIconClosed", "fa fa-folder", "string", "Closed folder icon class");
|
|
1286
1395
|
DirectoryTree.prototype.publish("textFileIcon", "fa fa-file-text-o", "string", "Text file icon class");
|
|
1287
1396
|
DirectoryTree.prototype.publish("verticalScroll", true, "boolean", "If true, vertical scroll bar will be shown");
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
return !!this.column();
|
|
1303
|
-
}
|
|
1304
|
-
column;
|
|
1397
|
+
const _IndentedColumn = class _IndentedColumn extends PropertyExt {
|
|
1398
|
+
_owner;
|
|
1399
|
+
constructor() {
|
|
1400
|
+
super();
|
|
1401
|
+
}
|
|
1402
|
+
owner(_) {
|
|
1403
|
+
if (!arguments.length) return this._owner;
|
|
1404
|
+
this._owner = _;
|
|
1405
|
+
return this;
|
|
1406
|
+
}
|
|
1407
|
+
valid() {
|
|
1408
|
+
return !!this.column();
|
|
1409
|
+
}
|
|
1410
|
+
column;
|
|
1305
1411
|
};
|
|
1412
|
+
__name(_IndentedColumn, "IndentedColumn");
|
|
1413
|
+
let IndentedColumn = _IndentedColumn;
|
|
1306
1414
|
IndentedColumn.prototype._class += " tree_Dendrogram.IndentedColumn";
|
|
1307
1415
|
IndentedColumn.prototype.publish("column", null, "set", "Field", function() {
|
|
1308
|
-
|
|
1416
|
+
return this._owner ? this._owner.columns() : [];
|
|
1309
1417
|
}, { optional: true });
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1418
|
+
const _Indented = class _Indented extends SVGZoomWidget {
|
|
1419
|
+
Column;
|
|
1420
|
+
_d3Tree;
|
|
1421
|
+
_xml;
|
|
1422
|
+
_svgLinks;
|
|
1423
|
+
_svgNodes;
|
|
1424
|
+
_treeData;
|
|
1425
|
+
_collapsed = {};
|
|
1426
|
+
constructor() {
|
|
1427
|
+
super();
|
|
1428
|
+
ITree.call(this);
|
|
1429
|
+
Utility.SimpleSelectionMixin.call(this);
|
|
1430
|
+
this._drawStartPos = "origin";
|
|
1431
|
+
this._d3Tree = d3Tree();
|
|
1432
|
+
}
|
|
1433
|
+
xmlToData(xml, id = "") {
|
|
1434
|
+
if (DOMParser) {
|
|
1435
|
+
const parser = new DOMParser();
|
|
1436
|
+
const doc = parser.parseFromString(xml, "text/xml");
|
|
1437
|
+
return xmlToJson(doc, id).children[0];
|
|
1438
|
+
}
|
|
1439
|
+
return [];
|
|
1440
|
+
}
|
|
1441
|
+
xml(_) {
|
|
1442
|
+
if (!arguments.length) return this._xml;
|
|
1443
|
+
this._xml = _;
|
|
1444
|
+
this.data(this.xmlToData(this._xml));
|
|
1445
|
+
return this;
|
|
1446
|
+
}
|
|
1447
|
+
IndentedData() {
|
|
1448
|
+
if (this.data().length === 0) return [];
|
|
1449
|
+
if (this.xmlColumn_exists()) {
|
|
1450
|
+
const cellIdx = this.columns().indexOf(this.xmlColumn());
|
|
1451
|
+
const retVal = {
|
|
1452
|
+
label: this.xmlColumn(),
|
|
1453
|
+
children: this.data().map(function(row, idx) {
|
|
1454
|
+
return this.xmlToData(row[cellIdx], "[" + idx + "]");
|
|
1455
|
+
}, this)
|
|
1456
|
+
};
|
|
1457
|
+
return retVal.children.length === 1 ? retVal.children[0] : retVal;
|
|
1458
|
+
} else {
|
|
1459
|
+
if (!this.mappings().filter((mapping) => mapping.valid()).length) {
|
|
1460
|
+
return this.data();
|
|
1461
|
+
}
|
|
1462
|
+
const view = this._db.rollupView(this.mappings().map(function(mapping) {
|
|
1463
|
+
return mapping.column();
|
|
1464
|
+
}));
|
|
1465
|
+
const root = {
|
|
1466
|
+
key: "root",
|
|
1467
|
+
values: view.entries()
|
|
1468
|
+
};
|
|
1469
|
+
return formatData(root);
|
|
1470
|
+
}
|
|
1471
|
+
function formatData(node) {
|
|
1472
|
+
if (node.values instanceof Array) {
|
|
1473
|
+
const children = node.values.filter(function(value) {
|
|
1474
|
+
return !(value instanceof Array);
|
|
1475
|
+
}).map(function(value) {
|
|
1476
|
+
return formatData(value);
|
|
1477
|
+
});
|
|
1478
|
+
const retVal = {
|
|
1479
|
+
label: node.key
|
|
1480
|
+
};
|
|
1481
|
+
if (children.length) {
|
|
1482
|
+
retVal.children = children;
|
|
1483
|
+
} else {
|
|
1484
|
+
retVal.size = 22;
|
|
1485
|
+
}
|
|
1486
|
+
return retVal;
|
|
1487
|
+
}
|
|
1488
|
+
return {
|
|
1489
|
+
label: node.key,
|
|
1490
|
+
size: node.values.aggregate,
|
|
1491
|
+
origRows: node.values
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
__name(formatData, "formatData");
|
|
1495
|
+
}
|
|
1496
|
+
enter(domNode, element) {
|
|
1497
|
+
super.enter(domNode, element);
|
|
1498
|
+
this._svgLinks = this._renderElement.append("g");
|
|
1499
|
+
this._svgNodes = this._renderElement.append("g");
|
|
1500
|
+
this._selection.widgetElement(this._svgNodes);
|
|
1501
|
+
}
|
|
1502
|
+
_prevDataChecksum;
|
|
1503
|
+
update(domNode, _element) {
|
|
1504
|
+
super.update(domNode, _element);
|
|
1505
|
+
const context = this;
|
|
1506
|
+
this._d3Tree.nodeSize([0, this.barHeight()]);
|
|
1507
|
+
const dataChecksum = this._db.dataChecksum();
|
|
1508
|
+
if (this._prevDataChecksum !== dataChecksum) {
|
|
1509
|
+
this._treeData = this.IndentedData();
|
|
1510
|
+
this._prevDataChecksum = dataChecksum;
|
|
1511
|
+
}
|
|
1512
|
+
function getID(d) {
|
|
1513
|
+
return (d.parent ? getID(d.parent) + "." : "") + d.data.label;
|
|
1514
|
+
}
|
|
1515
|
+
__name(getID, "getID");
|
|
1516
|
+
const root = hierarchy(this.data()).sum(function(d) {
|
|
1517
|
+
return d.size || 50;
|
|
1518
|
+
}).each((d) => {
|
|
1519
|
+
if (this._collapsed[getID(d)]) {
|
|
1520
|
+
delete d.children;
|
|
1521
|
+
}
|
|
1522
|
+
});
|
|
1523
|
+
const dataNodes = this._d3Tree(root).descendants();
|
|
1524
|
+
const links = this._d3Tree(root).descendants().slice(1);
|
|
1525
|
+
let nodeIdx = 0;
|
|
1526
|
+
root.eachBefore((n) => {
|
|
1527
|
+
n.x = nodeIdx * context.barHeight();
|
|
1528
|
+
++nodeIdx;
|
|
1529
|
+
});
|
|
1530
|
+
const boxSize = this.barHeight() - 4;
|
|
1531
|
+
const transitionDuration = this._renderCount ? 500 : 0;
|
|
1532
|
+
const lines = this._svgLinks.selectAll(".link").data(links, function(d) {
|
|
1533
|
+
return getID(d);
|
|
1534
|
+
});
|
|
1535
|
+
lines.enter().append("path").attr("class", "link").attr("d", elbow);
|
|
1536
|
+
lines.transition().duration(transitionDuration).attr("d", elbow);
|
|
1537
|
+
lines.exit().remove();
|
|
1538
|
+
function elbow(d) {
|
|
1539
|
+
return "M" + d.parent.y + "," + d.parent.x + "V" + d.x + ", H" + d.y;
|
|
1540
|
+
}
|
|
1541
|
+
__name(elbow, "elbow");
|
|
1542
|
+
const nodes = this._svgNodes.selectAll(".node").data(dataNodes, function(d) {
|
|
1543
|
+
return getID(d);
|
|
1544
|
+
});
|
|
1545
|
+
nodes.transition().duration(transitionDuration).attr("transform", function(d) {
|
|
1546
|
+
return "translate(" + d.y + "," + d.x + ")";
|
|
1547
|
+
});
|
|
1548
|
+
const enterNodes = nodes.enter().append("g").attr("class", "node").attr("transform", function(d) {
|
|
1549
|
+
return "translate(" + d.y + "," + d.x + ")";
|
|
1550
|
+
}).call(this._selection.enter.bind(this._selection)).each(function() {
|
|
1551
|
+
const element = select(this);
|
|
1552
|
+
element.append("rect").attr("height", boxSize).attr("width", boxSize).on("click", function(d) {
|
|
1553
|
+
if (context._collapsed[getID(d)]) {
|
|
1554
|
+
delete context._collapsed[getID(d)];
|
|
1555
|
+
} else if (d.children) {
|
|
1556
|
+
context._collapsed[getID(d)] = true;
|
|
1557
|
+
}
|
|
1558
|
+
context.lazyRender();
|
|
1559
|
+
});
|
|
1560
|
+
element.append("text");
|
|
1561
|
+
}).style("opacity", 0);
|
|
1562
|
+
enterNodes.transition().style("opacity", 1);
|
|
1563
|
+
enterNodes.merge(nodes).select("rect").attr("x", -boxSize / 2).attr("y", -boxSize / 2).style("fill", color);
|
|
1564
|
+
enterNodes.merge(nodes).select("text").attr("dx", boxSize / 2 + 4 + "px").attr("dy", "0.33em").text(function(d) {
|
|
1565
|
+
return d.data.label;
|
|
1566
|
+
});
|
|
1567
|
+
nodes.exit().transition().style("opacity", 0).remove();
|
|
1568
|
+
if (!this._renderCount) {
|
|
1569
|
+
context.zoomToFit();
|
|
1570
|
+
}
|
|
1571
|
+
function color(d) {
|
|
1572
|
+
return context._collapsed[getID(d)] ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c";
|
|
1573
|
+
}
|
|
1574
|
+
__name(color, "color");
|
|
1575
|
+
}
|
|
1444
1576
|
};
|
|
1577
|
+
__name(_Indented, "Indented");
|
|
1578
|
+
let Indented = _Indented;
|
|
1445
1579
|
Indented.prototype._class += " tree_Indented";
|
|
1446
1580
|
Indented.prototype.implements(ITree.prototype);
|
|
1447
1581
|
Indented.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
1448
1582
|
Indented.prototype.Column = IndentedColumn;
|
|
1449
1583
|
Indented.prototype.publish("xmlColumn", null, "set", "Field", function() {
|
|
1450
|
-
|
|
1584
|
+
return this.columns();
|
|
1451
1585
|
}, { optional: true });
|
|
1452
|
-
Indented.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, {
|
|
1453
|
-
autoExpand: IndentedColumn,
|
|
1454
|
-
disable: (w) => w.xmlColumn_exists()
|
|
1455
|
-
});
|
|
1586
|
+
Indented.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: IndentedColumn, disable: /* @__PURE__ */ __name((w) => w.xmlColumn_exists(), "disable") });
|
|
1456
1587
|
Indented.prototype.publish("barHeight", 16, "number", "Bar height");
|
|
1457
1588
|
function xmlToJson(xml, id = "") {
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1589
|
+
const retVal = {
|
|
1590
|
+
id,
|
|
1591
|
+
label: "",
|
|
1592
|
+
attributes: {},
|
|
1593
|
+
children: []
|
|
1594
|
+
};
|
|
1595
|
+
retVal.label = xml.nodeName;
|
|
1596
|
+
if (xml.nodeType === 1) {
|
|
1597
|
+
if (xml.attributes.length > 0) {
|
|
1598
|
+
for (let j = 0; j < xml.attributes.length; j++) {
|
|
1599
|
+
const attribute = xml.attributes.item(j);
|
|
1600
|
+
retVal.attributes[attribute.nodeName] = attribute.nodeValue;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
} else if (xml.nodeType === 3) {
|
|
1604
|
+
retVal.label = xml.nodeValue;
|
|
1605
|
+
}
|
|
1606
|
+
if (xml.hasChildNodes()) {
|
|
1607
|
+
for (let i = 0; i < xml.childNodes.length; i++) {
|
|
1608
|
+
const item = xml.childNodes.item(i);
|
|
1609
|
+
const child = xmlToJson(item, id + "[" + retVal.children.length + "]");
|
|
1610
|
+
retVal.children.push(child);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
return retVal;
|
|
1614
|
+
}
|
|
1615
|
+
__name(xmlToJson, "xmlToJson");
|
|
1480
1616
|
var pi$1 = Math.PI, tau$1 = 2 * pi$1, epsilon$1 = 1e-6, tauEpsilon = tau$1 - epsilon$1;
|
|
1481
1617
|
function Path() {
|
|
1482
|
-
|
|
1483
|
-
|
|
1618
|
+
this._x0 = this._y0 = // start of current subpath
|
|
1619
|
+
this._x1 = this._y1 = null;
|
|
1620
|
+
this._ = "";
|
|
1484
1621
|
}
|
|
1622
|
+
__name(Path, "Path");
|
|
1485
1623
|
function path() {
|
|
1486
|
-
|
|
1624
|
+
return new Path();
|
|
1487
1625
|
}
|
|
1626
|
+
__name(path, "path");
|
|
1488
1627
|
Path.prototype = path.prototype = {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1628
|
+
constructor: Path,
|
|
1629
|
+
moveTo: /* @__PURE__ */ __name(function(x, y) {
|
|
1630
|
+
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
|
|
1631
|
+
}, "moveTo"),
|
|
1632
|
+
closePath: /* @__PURE__ */ __name(function() {
|
|
1633
|
+
if (this._x1 !== null) {
|
|
1634
|
+
this._x1 = this._x0, this._y1 = this._y0;
|
|
1635
|
+
this._ += "Z";
|
|
1636
|
+
}
|
|
1637
|
+
}, "closePath"),
|
|
1638
|
+
lineTo: /* @__PURE__ */ __name(function(x, y) {
|
|
1639
|
+
this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
1640
|
+
}, "lineTo"),
|
|
1641
|
+
quadraticCurveTo: /* @__PURE__ */ __name(function(x1, y1, x, y) {
|
|
1642
|
+
this._ += "Q" + +x1 + "," + +y1 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
1643
|
+
}, "quadraticCurveTo"),
|
|
1644
|
+
bezierCurveTo: /* @__PURE__ */ __name(function(x1, y1, x2, y2, x, y) {
|
|
1645
|
+
this._ += "C" + +x1 + "," + +y1 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
1646
|
+
}, "bezierCurveTo"),
|
|
1647
|
+
arcTo: /* @__PURE__ */ __name(function(x1, y1, x2, y2, r) {
|
|
1648
|
+
x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
|
|
1649
|
+
var x0 = this._x1, y0 = this._y1, x21 = x2 - x1, y21 = y2 - y1, x01 = x0 - x1, y01 = y0 - y1, l01_2 = x01 * x01 + y01 * y01;
|
|
1650
|
+
if (r < 0) throw new Error("negative radius: " + r);
|
|
1651
|
+
if (this._x1 === null) {
|
|
1652
|
+
this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
1653
|
+
} else if (!(l01_2 > epsilon$1)) ;
|
|
1654
|
+
else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon$1) || !r) {
|
|
1655
|
+
this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
1656
|
+
} else {
|
|
1657
|
+
var x20 = x2 - x0, y20 = y2 - y0, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi$1 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21;
|
|
1658
|
+
if (Math.abs(t01 - 1) > epsilon$1) {
|
|
1659
|
+
this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
|
|
1660
|
+
}
|
|
1661
|
+
this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
|
|
1662
|
+
}
|
|
1663
|
+
}, "arcTo"),
|
|
1664
|
+
arc: /* @__PURE__ */ __name(function(x, y, r, a0, a1, ccw) {
|
|
1665
|
+
x = +x, y = +y, r = +r, ccw = !!ccw;
|
|
1666
|
+
var dx = r * Math.cos(a0), dy = r * Math.sin(a0), x0 = x + dx, y0 = y + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0;
|
|
1667
|
+
if (r < 0) throw new Error("negative radius: " + r);
|
|
1668
|
+
if (this._x1 === null) {
|
|
1669
|
+
this._ += "M" + x0 + "," + y0;
|
|
1670
|
+
} else if (Math.abs(this._x1 - x0) > epsilon$1 || Math.abs(this._y1 - y0) > epsilon$1) {
|
|
1671
|
+
this._ += "L" + x0 + "," + y0;
|
|
1672
|
+
}
|
|
1673
|
+
if (!r) return;
|
|
1674
|
+
if (da < 0) da = da % tau$1 + tau$1;
|
|
1675
|
+
if (da > tauEpsilon) {
|
|
1676
|
+
this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
|
|
1677
|
+
} else if (da > epsilon$1) {
|
|
1678
|
+
this._ += "A" + r + "," + r + ",0," + +(da >= pi$1) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
|
|
1679
|
+
}
|
|
1680
|
+
}, "arc"),
|
|
1681
|
+
rect: /* @__PURE__ */ __name(function(x, y, w, h) {
|
|
1682
|
+
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + +w + "v" + +h + "h" + -w + "Z";
|
|
1683
|
+
}, "rect"),
|
|
1684
|
+
toString: /* @__PURE__ */ __name(function() {
|
|
1685
|
+
return this._;
|
|
1686
|
+
}, "toString")
|
|
1538
1687
|
};
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
return x;
|
|
1546
|
-
};
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
//#endregion
|
|
1550
|
-
//#region ../../node_modules/d3-shape/src/math.js
|
|
1688
|
+
function constant(x) {
|
|
1689
|
+
return /* @__PURE__ */ __name(function constant2() {
|
|
1690
|
+
return x;
|
|
1691
|
+
}, "constant");
|
|
1692
|
+
}
|
|
1693
|
+
__name(constant, "constant");
|
|
1551
1694
|
var abs = Math.abs;
|
|
1552
1695
|
var atan2 = Math.atan2;
|
|
1553
1696
|
var cos = Math.cos;
|
|
1554
|
-
var max
|
|
1697
|
+
var max = Math.max;
|
|
1555
1698
|
var min = Math.min;
|
|
1556
1699
|
var sin = Math.sin;
|
|
1557
1700
|
var sqrt = Math.sqrt;
|
|
@@ -1560,408 +1703,469 @@ var pi = Math.PI;
|
|
|
1560
1703
|
var halfPi = pi / 2;
|
|
1561
1704
|
var tau = 2 * pi;
|
|
1562
1705
|
function acos(x) {
|
|
1563
|
-
|
|
1706
|
+
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
|
|
1564
1707
|
}
|
|
1708
|
+
__name(acos, "acos");
|
|
1565
1709
|
function asin(x) {
|
|
1566
|
-
|
|
1710
|
+
return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);
|
|
1567
1711
|
}
|
|
1568
|
-
|
|
1569
|
-
//#endregion
|
|
1570
|
-
//#region ../../node_modules/d3-shape/src/arc.js
|
|
1712
|
+
__name(asin, "asin");
|
|
1571
1713
|
function arcInnerRadius(d) {
|
|
1572
|
-
|
|
1714
|
+
return d.innerRadius;
|
|
1573
1715
|
}
|
|
1716
|
+
__name(arcInnerRadius, "arcInnerRadius");
|
|
1574
1717
|
function arcOuterRadius(d) {
|
|
1575
|
-
|
|
1718
|
+
return d.outerRadius;
|
|
1576
1719
|
}
|
|
1720
|
+
__name(arcOuterRadius, "arcOuterRadius");
|
|
1577
1721
|
function arcStartAngle(d) {
|
|
1578
|
-
|
|
1722
|
+
return d.startAngle;
|
|
1579
1723
|
}
|
|
1724
|
+
__name(arcStartAngle, "arcStartAngle");
|
|
1580
1725
|
function arcEndAngle(d) {
|
|
1581
|
-
|
|
1726
|
+
return d.endAngle;
|
|
1582
1727
|
}
|
|
1728
|
+
__name(arcEndAngle, "arcEndAngle");
|
|
1583
1729
|
function arcPadAngle(d) {
|
|
1584
|
-
|
|
1730
|
+
return d && d.padAngle;
|
|
1585
1731
|
}
|
|
1732
|
+
__name(arcPadAngle, "arcPadAngle");
|
|
1586
1733
|
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1734
|
+
var x10 = x1 - x0, y10 = y1 - y0, x32 = x3 - x2, y32 = y3 - y2, t = y32 * x10 - x32 * y10;
|
|
1735
|
+
if (t * t < epsilon) return;
|
|
1736
|
+
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
1737
|
+
return [x0 + t * x10, y0 + t * y10];
|
|
1591
1738
|
}
|
|
1739
|
+
__name(intersect, "intersect");
|
|
1592
1740
|
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1741
|
+
var x01 = x0 - x1, y01 = y0 - y1, lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x11 = x0 + ox, y11 = y0 + oy, x10 = x1 + ox, y10 = y1 + oy, x00 = (x11 + x10) / 2, y00 = (y11 + y10) / 2, dx = x10 - x11, dy = y10 - y11, d2 = dx * dx + dy * dy, r = r1 - rc, D = x11 * y10 - x10 * y11, d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x00, dy0 = cy0 - y00, dx1 = cx1 - x00, dy1 = cy1 - y00;
|
|
1742
|
+
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
|
|
1743
|
+
return {
|
|
1744
|
+
cx: cx0,
|
|
1745
|
+
cy: cy0,
|
|
1746
|
+
x01: -ox,
|
|
1747
|
+
y01: -oy,
|
|
1748
|
+
x11: cx0 * (r1 / r - 1),
|
|
1749
|
+
y11: cy0 * (r1 / r - 1)
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
__name(cornerTangents, "cornerTangents");
|
|
1753
|
+
function d3Arc() {
|
|
1754
|
+
var innerRadius = arcInnerRadius, outerRadius = arcOuterRadius, cornerRadius = constant(0), padRadius = null, startAngle = arcStartAngle, endAngle = arcEndAngle, padAngle = arcPadAngle, context = null;
|
|
1755
|
+
function arc() {
|
|
1756
|
+
var buffer, r, r0 = +innerRadius.apply(this, arguments), r1 = +outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) - halfPi, a1 = endAngle.apply(this, arguments) - halfPi, da = abs(a1 - a0), cw = a1 > a0;
|
|
1757
|
+
if (!context) context = buffer = path();
|
|
1758
|
+
if (r1 < r0) r = r1, r1 = r0, r0 = r;
|
|
1759
|
+
if (!(r1 > epsilon)) context.moveTo(0, 0);
|
|
1760
|
+
else if (da > tau - epsilon) {
|
|
1761
|
+
context.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
1762
|
+
context.arc(0, 0, r1, a0, a1, !cw);
|
|
1763
|
+
if (r0 > epsilon) {
|
|
1764
|
+
context.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
1765
|
+
context.arc(0, 0, r0, a1, a0, cw);
|
|
1766
|
+
}
|
|
1767
|
+
} else {
|
|
1768
|
+
var a01 = a0, a11 = a1, a00 = a0, a10 = a1, da0 = da, da1 = da, ap = padAngle.apply(this, arguments) / 2, rp = ap > epsilon && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), rc0 = rc, rc1 = rc, t0, t1;
|
|
1769
|
+
if (rp > epsilon) {
|
|
1770
|
+
var p0 = asin(rp / r0 * sin(ap)), p1 = asin(rp / r1 * sin(ap));
|
|
1771
|
+
if ((da0 -= p0 * 2) > epsilon) p0 *= cw ? 1 : -1, a00 += p0, a10 -= p0;
|
|
1772
|
+
else da0 = 0, a00 = a10 = (a0 + a1) / 2;
|
|
1773
|
+
if ((da1 -= p1 * 2) > epsilon) p1 *= cw ? 1 : -1, a01 += p1, a11 -= p1;
|
|
1774
|
+
else da1 = 0, a01 = a11 = (a0 + a1) / 2;
|
|
1775
|
+
}
|
|
1776
|
+
var x01 = r1 * cos(a01), y01 = r1 * sin(a01), x10 = r0 * cos(a10), y10 = r0 * sin(a10);
|
|
1777
|
+
if (rc > epsilon) {
|
|
1778
|
+
var x11 = r1 * cos(a11), y11 = r1 * sin(a11), x00 = r0 * cos(a00), y00 = r0 * sin(a00), oc;
|
|
1779
|
+
if (da < pi && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) {
|
|
1780
|
+
var ax = x01 - oc[0], ay = y01 - oc[1], bx = x11 - oc[0], by = y11 - oc[1], kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
1781
|
+
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
1782
|
+
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
if (!(da1 > epsilon)) context.moveTo(x01, y01);
|
|
1786
|
+
else if (rc1 > epsilon) {
|
|
1787
|
+
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
1788
|
+
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
1789
|
+
context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
1790
|
+
if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
1791
|
+
else {
|
|
1792
|
+
context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
1793
|
+
context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
|
|
1794
|
+
context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
1795
|
+
}
|
|
1796
|
+
} else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
|
|
1797
|
+
if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10);
|
|
1798
|
+
else if (rc0 > epsilon) {
|
|
1799
|
+
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
1800
|
+
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
1801
|
+
context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
1802
|
+
if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
1803
|
+
else {
|
|
1804
|
+
context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
1805
|
+
context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
|
|
1806
|
+
context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
1807
|
+
}
|
|
1808
|
+
} else context.arc(0, 0, r0, a10, a00, cw);
|
|
1809
|
+
}
|
|
1810
|
+
context.closePath();
|
|
1811
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
1812
|
+
}
|
|
1813
|
+
__name(arc, "arc");
|
|
1814
|
+
arc.centroid = function() {
|
|
1815
|
+
var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2;
|
|
1816
|
+
return [cos(a) * r, sin(a) * r];
|
|
1817
|
+
};
|
|
1818
|
+
arc.innerRadius = function(_) {
|
|
1819
|
+
return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant(+_), arc) : innerRadius;
|
|
1820
|
+
};
|
|
1821
|
+
arc.outerRadius = function(_) {
|
|
1822
|
+
return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant(+_), arc) : outerRadius;
|
|
1823
|
+
};
|
|
1824
|
+
arc.cornerRadius = function(_) {
|
|
1825
|
+
return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant(+_), arc) : cornerRadius;
|
|
1826
|
+
};
|
|
1827
|
+
arc.padRadius = function(_) {
|
|
1828
|
+
return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant(+_), arc) : padRadius;
|
|
1829
|
+
};
|
|
1830
|
+
arc.startAngle = function(_) {
|
|
1831
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), arc) : startAngle;
|
|
1832
|
+
};
|
|
1833
|
+
arc.endAngle = function(_) {
|
|
1834
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), arc) : endAngle;
|
|
1835
|
+
};
|
|
1836
|
+
arc.padAngle = function(_) {
|
|
1837
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), arc) : padAngle;
|
|
1838
|
+
};
|
|
1839
|
+
arc.context = function(_) {
|
|
1840
|
+
return arguments.length ? (context = _ == null ? null : _, arc) : context;
|
|
1841
|
+
};
|
|
1842
|
+
return arc;
|
|
1843
|
+
}
|
|
1844
|
+
__name(d3Arc, "d3Arc");
|
|
1845
|
+
const _SunburstPartition = class _SunburstPartition extends SVGWidget {
|
|
1846
|
+
svg;
|
|
1847
|
+
radius;
|
|
1848
|
+
_xScale;
|
|
1849
|
+
_yScale;
|
|
1850
|
+
partition;
|
|
1851
|
+
arc;
|
|
1852
|
+
_resetRoot;
|
|
1853
|
+
constructor() {
|
|
1854
|
+
super();
|
|
1855
|
+
ITree.call(this);
|
|
1856
|
+
}
|
|
1857
|
+
data(_) {
|
|
1858
|
+
const retVal = SVGWidget.prototype.data.apply(this, arguments);
|
|
1859
|
+
if (arguments.length) {
|
|
1860
|
+
this._resetRoot = true;
|
|
1861
|
+
}
|
|
1862
|
+
return retVal;
|
|
1863
|
+
}
|
|
1864
|
+
enter(_domNode, element) {
|
|
1865
|
+
const context = this;
|
|
1866
|
+
this.radius = Math.min(this.width(), this.height()) / 2;
|
|
1867
|
+
this._xScale = scaleLinear().range([0, 2 * Math.PI]);
|
|
1868
|
+
this._yScale = scaleSqrt().range([0, this.radius]);
|
|
1869
|
+
this.partition = d3Parition();
|
|
1870
|
+
this.arc = d3Arc().startAngle(function(d) {
|
|
1871
|
+
return Math.max(0, Math.min(2 * Math.PI, context._xScale(d.x0)));
|
|
1872
|
+
}).endAngle(function(d) {
|
|
1873
|
+
return Math.max(0, Math.min(2 * Math.PI, context._xScale(d.x1)));
|
|
1874
|
+
}).innerRadius(function(d) {
|
|
1875
|
+
return Math.max(0, context._yScale(d.y0));
|
|
1876
|
+
}).outerRadius(function(d) {
|
|
1877
|
+
return Math.max(0, context._yScale(d.y1));
|
|
1878
|
+
});
|
|
1879
|
+
this.svg = element.append("g");
|
|
1880
|
+
}
|
|
1881
|
+
update(_domNode, _element) {
|
|
1882
|
+
const context = this;
|
|
1883
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
1884
|
+
if (this.useClonedPalette()) {
|
|
1885
|
+
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
1886
|
+
}
|
|
1887
|
+
this.radius = Math.min(this.width(), this.height()) / 2;
|
|
1888
|
+
this._yScale.range([0, this.radius]);
|
|
1889
|
+
const root = hierarchy(this.data()).sum(function(d) {
|
|
1890
|
+
return d.size !== void 0 ? d.size : 1;
|
|
1891
|
+
});
|
|
1892
|
+
const paths = this.svg.selectAll("path").data(this.partition(root).descendants(), function(d, i) {
|
|
1893
|
+
return d.data.label !== void 0 ? d.data.label : i;
|
|
1894
|
+
});
|
|
1895
|
+
paths.enter().append("path").on("click", function(d) {
|
|
1896
|
+
context.click(d.data, null, null);
|
|
1897
|
+
}).on("dblclick", function(d) {
|
|
1898
|
+
const event = d3Event();
|
|
1899
|
+
if (event) {
|
|
1900
|
+
event.stopPropagation();
|
|
1901
|
+
}
|
|
1902
|
+
context.zoomTo(d);
|
|
1903
|
+
}).each(function() {
|
|
1904
|
+
const element = select(this);
|
|
1905
|
+
element.append("title");
|
|
1906
|
+
}).merge(paths).attr("d", this.arc).style("fill", function(d) {
|
|
1907
|
+
return d.data.__viz_fill ? d.data.__viz_fill : context._palette(d.data.label);
|
|
1908
|
+
}).style("stroke", function(d) {
|
|
1909
|
+
return d.value > 16 ? "white" : "none";
|
|
1910
|
+
}).select("title").text(function(d) {
|
|
1911
|
+
return d.data.label;
|
|
1912
|
+
});
|
|
1913
|
+
paths.exit().remove();
|
|
1914
|
+
if (this._resetRoot) {
|
|
1915
|
+
this._resetRoot = false;
|
|
1916
|
+
this.zoomTo(root);
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
zoomTo(d) {
|
|
1920
|
+
const context = this;
|
|
1921
|
+
this.svg.transition().duration(750).tween("scale", function() {
|
|
1922
|
+
const xd = interpolate(context._xScale.domain(), [d.x0, d.x1]);
|
|
1923
|
+
const yd = interpolate(context._yScale.domain(), [d.y0, 1]);
|
|
1924
|
+
const yr = interpolate(context._yScale.range(), [d.y0 ? 20 : 0, context.radius]);
|
|
1925
|
+
return function(t) {
|
|
1926
|
+
context._xScale.domain(xd(t));
|
|
1927
|
+
context._yScale.domain(yd(t)).range(yr(t));
|
|
1928
|
+
};
|
|
1929
|
+
}).selectAll("path").attrTween("d", function(d2) {
|
|
1930
|
+
return function() {
|
|
1931
|
+
return context.arc(d2);
|
|
1932
|
+
};
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1780
1935
|
};
|
|
1936
|
+
__name(_SunburstPartition, "SunburstPartition");
|
|
1937
|
+
let SunburstPartition = _SunburstPartition;
|
|
1781
1938
|
SunburstPartition.prototype._class += " tree_SunburstPartition";
|
|
1782
1939
|
SunburstPartition.prototype.implements(ITree.prototype);
|
|
1783
1940
|
SunburstPartition.prototype.publish("paletteID", "default", "set", "Color palette for this widget", SunburstPartition.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
1784
1941
|
SunburstPartition.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
return !!this.column();
|
|
1800
|
-
}
|
|
1801
|
-
column;
|
|
1942
|
+
const _TreemapColumn = class _TreemapColumn extends PropertyExt {
|
|
1943
|
+
_owner;
|
|
1944
|
+
constructor() {
|
|
1945
|
+
super();
|
|
1946
|
+
}
|
|
1947
|
+
owner(_) {
|
|
1948
|
+
if (!arguments.length) return this._owner;
|
|
1949
|
+
this._owner = _;
|
|
1950
|
+
return this;
|
|
1951
|
+
}
|
|
1952
|
+
valid() {
|
|
1953
|
+
return !!this.column();
|
|
1954
|
+
}
|
|
1955
|
+
column;
|
|
1802
1956
|
};
|
|
1957
|
+
__name(_TreemapColumn, "TreemapColumn");
|
|
1958
|
+
let TreemapColumn = _TreemapColumn;
|
|
1803
1959
|
TreemapColumn.prototype._class += " tree_Dendrogram.TreemapColumn";
|
|
1804
1960
|
TreemapColumn.prototype.publish("column", null, "set", "Field", function() {
|
|
1805
|
-
|
|
1961
|
+
return this._owner ? this._owner.columns() : [];
|
|
1806
1962
|
}, { optional: true });
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1963
|
+
const _Treemap = class _Treemap extends HTMLWidget {
|
|
1964
|
+
Column;
|
|
1965
|
+
_d3Treemap;
|
|
1966
|
+
_elementDIV;
|
|
1967
|
+
_selection;
|
|
1968
|
+
constructor() {
|
|
1969
|
+
super();
|
|
1970
|
+
ITree.call(this);
|
|
1971
|
+
Utility.SimpleSelectionMixin.call(this, true);
|
|
1972
|
+
}
|
|
1973
|
+
getTilingMethod() {
|
|
1974
|
+
switch (this.tilingMethod()) {
|
|
1975
|
+
case "treemapBinary":
|
|
1976
|
+
return d3treemapBinary;
|
|
1977
|
+
case "treemapDice":
|
|
1978
|
+
return d3treemapDice;
|
|
1979
|
+
case "treemapSlice":
|
|
1980
|
+
return d3treemapSlice;
|
|
1981
|
+
case "treemapSliceDice":
|
|
1982
|
+
return d3treemapSliceDice;
|
|
1983
|
+
case "treemapResquarify":
|
|
1984
|
+
return d3treemapResquarify;
|
|
1985
|
+
case "treemapSquarify":
|
|
1986
|
+
default:
|
|
1987
|
+
return d3treemapSquarify;
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
treemapData() {
|
|
1991
|
+
if (!this.mappings().filter((mapping) => mapping.valid()).length) {
|
|
1992
|
+
return this.data();
|
|
1993
|
+
}
|
|
1994
|
+
const view = this._db.aggregateView(this.mappings().map(function(mapping) {
|
|
1995
|
+
return mapping.column();
|
|
1996
|
+
}), this.aggrType(), this.aggrColumn());
|
|
1997
|
+
const retVal = {
|
|
1998
|
+
key: "root",
|
|
1999
|
+
values: view.entries()
|
|
2000
|
+
};
|
|
2001
|
+
return formatData(retVal);
|
|
2002
|
+
function formatData(node) {
|
|
2003
|
+
if (node.values instanceof Array) {
|
|
2004
|
+
const children = node.values.filter(function(value) {
|
|
2005
|
+
return !(value instanceof Array);
|
|
2006
|
+
}).map(function(value) {
|
|
2007
|
+
return formatData(value);
|
|
2008
|
+
});
|
|
2009
|
+
const retVal2 = {
|
|
2010
|
+
label: node.key
|
|
2011
|
+
};
|
|
2012
|
+
if (children.length) {
|
|
2013
|
+
retVal2.children = children;
|
|
2014
|
+
} else {
|
|
2015
|
+
retVal2.size = 22;
|
|
2016
|
+
}
|
|
2017
|
+
return retVal2;
|
|
2018
|
+
}
|
|
2019
|
+
return {
|
|
2020
|
+
label: node.key,
|
|
2021
|
+
size: node.values.aggregate,
|
|
2022
|
+
origRows: node.values
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
__name(formatData, "formatData");
|
|
2026
|
+
}
|
|
2027
|
+
enter(domNode, element) {
|
|
2028
|
+
super.enter(domNode, element);
|
|
2029
|
+
this._d3Treemap = d3Treemap();
|
|
2030
|
+
this._elementDIV = element.append("div");
|
|
2031
|
+
this._selection.widgetElement(this._elementDIV);
|
|
2032
|
+
}
|
|
2033
|
+
update(domNode, element) {
|
|
2034
|
+
super.update(domNode, element);
|
|
2035
|
+
const context = this;
|
|
2036
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
2037
|
+
if (this.useClonedPalette()) {
|
|
2038
|
+
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
2039
|
+
}
|
|
2040
|
+
const root = hierarchy(this.treemapData()).sum(this.nodeWeight);
|
|
2041
|
+
this._d3Treemap.size([this.width(), this.height()]).paddingInner(this.paddingInner()).paddingOuter(this.paddingOuter()).paddingTop(this.paddingTop());
|
|
2042
|
+
if (["treemapSquarify", "treemapResquarify"].indexOf(this.tilingMethod()) !== -1) {
|
|
2043
|
+
this._d3Treemap.tile(this.getTilingMethod()["ratio"](this.squarifyRatio()));
|
|
2044
|
+
} else {
|
|
2045
|
+
this._d3Treemap.tile(this.getTilingMethod());
|
|
2046
|
+
}
|
|
2047
|
+
this._d3Treemap(root);
|
|
2048
|
+
this._elementDIV.style("font-size", this.fontSize_exists() ? this.fontSize() + "px" : null).style("line-height", this.fontSize_exists() ? this.fontSize() + 2 + "px" : null);
|
|
2049
|
+
const node = this._elementDIV.selectAll(".node").data(root.descendants());
|
|
2050
|
+
node.enter().append("div").attr("class", "node").call(this._selection.enter.bind(this._selection)).on("click", function(d) {
|
|
2051
|
+
if (d) {
|
|
2052
|
+
let columnLabel = "";
|
|
2053
|
+
context.mappings().forEach(function(mapping) {
|
|
2054
|
+
if (mapping.column()) {
|
|
2055
|
+
columnLabel = mapping.column();
|
|
2056
|
+
}
|
|
2057
|
+
});
|
|
2058
|
+
if (d.origRows) {
|
|
2059
|
+
context.click(context.rowToObj(d.origRows[0]), columnLabel, context._selection.selected(this));
|
|
2060
|
+
} else {
|
|
2061
|
+
context.click(d.data, columnLabel, context._selection.selected(this));
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
}).on("dblclick", function(d) {
|
|
2065
|
+
if (d) {
|
|
2066
|
+
let columnLabel = "";
|
|
2067
|
+
context.mappings().forEach(function(mapping) {
|
|
2068
|
+
if (mapping.column()) {
|
|
2069
|
+
columnLabel = mapping.column();
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
2072
|
+
if (d.origRows) {
|
|
2073
|
+
context.dblclick(context.rowToObj(d.origRows[0]), columnLabel, context._selection.selected(this));
|
|
2074
|
+
} else {
|
|
2075
|
+
context.dblclick(d.data, columnLabel, context._selection.selected(this));
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
}).merge(node).style("left", function(d) {
|
|
2079
|
+
return d.x0 + Math.max(0, d.x1 - d.x0) / 2 + "px";
|
|
2080
|
+
}).style("top", function(d) {
|
|
2081
|
+
return d.y0 + Math.max(0, d.y1 - d.y0) / 2 + "px";
|
|
2082
|
+
}).style("width", function() {
|
|
2083
|
+
return "0px";
|
|
2084
|
+
}).style("height", function() {
|
|
2085
|
+
return "0px";
|
|
2086
|
+
}).style("font-size", function(d) {
|
|
2087
|
+
return (d.children ? context.parentFontSize() : context.leafFontSize()) + "px";
|
|
2088
|
+
}).style("line-height", function(d) {
|
|
2089
|
+
return (d.children ? context.parentFontSize() : context.leafFontSize()) + "px";
|
|
2090
|
+
}).attr("title", tooltip).html(function(d) {
|
|
2091
|
+
if (!context.showRoot() && d.depth === 0) {
|
|
2092
|
+
return null;
|
|
2093
|
+
}
|
|
2094
|
+
if (d.children) {
|
|
2095
|
+
if (context.enableParentLabels()) {
|
|
2096
|
+
return context.parentWeightHTML(d);
|
|
2097
|
+
} else {
|
|
2098
|
+
return null;
|
|
2099
|
+
}
|
|
2100
|
+
} else {
|
|
2101
|
+
return context.leafWeightHTML(d);
|
|
2102
|
+
}
|
|
2103
|
+
}).style("background", function(d) {
|
|
2104
|
+
if (!context.showRoot() && d.depth === 0) {
|
|
2105
|
+
this.style.color = "transparent";
|
|
2106
|
+
return "transparent";
|
|
2107
|
+
}
|
|
2108
|
+
const light_dark = context.brighterLeafNodes() ? "brighter" : "darker";
|
|
2109
|
+
let _color;
|
|
2110
|
+
if (context.usePaletteOnParentNodes()) {
|
|
2111
|
+
_color = d.children ? context._palette(d.data.label) : rgb(context._palette(d.parent.data.label))[light_dark](1);
|
|
2112
|
+
} else {
|
|
2113
|
+
if (d.depth > context.depthColorLimit()) {
|
|
2114
|
+
_color = rgb(d.parent.color)[light_dark](1);
|
|
2115
|
+
} else {
|
|
2116
|
+
_color = context._palette(d.data.label);
|
|
2117
|
+
}
|
|
2118
|
+
d.color = _color;
|
|
2119
|
+
}
|
|
2120
|
+
this.style.color = Palette.textColor(_color);
|
|
2121
|
+
return _color;
|
|
2122
|
+
}).transition().duration(this.transitionDuration()).style("pointer-events", function(d) {
|
|
2123
|
+
return !context.showRoot() && d.depth === 0 ? "none" : "all";
|
|
2124
|
+
}).style("opacity", function(d) {
|
|
2125
|
+
return d.children ? 1 : null;
|
|
2126
|
+
}).style("left", function(d) {
|
|
2127
|
+
return d.x0 + "px";
|
|
2128
|
+
}).style("top", function(d) {
|
|
2129
|
+
return d.y0 + "px";
|
|
2130
|
+
}).style("width", function(d) {
|
|
2131
|
+
return Math.max(0, d.x1 - d.x0) + "px";
|
|
2132
|
+
}).style("height", function(d) {
|
|
2133
|
+
return Math.max(0, d.y1 - d.y0) + "px";
|
|
2134
|
+
}).each(function(d) {
|
|
2135
|
+
if (d.depth === 0) {
|
|
2136
|
+
this.style.color = !context.showRoot() ? "transparent" : "";
|
|
2137
|
+
this.style.borderColor = !context.showRoot() ? "transparent" : "";
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
node.exit().transition().duration(this.transitionDuration()).style("opacity", 0).remove();
|
|
2141
|
+
function tooltip(d) {
|
|
2142
|
+
if (d.children && !context.enableParentTooltips()) {
|
|
2143
|
+
return null;
|
|
2144
|
+
}
|
|
2145
|
+
let retVal = d.data.label + " (" + d.value + ")";
|
|
2146
|
+
while (d.parent && d.parent.parent) {
|
|
2147
|
+
retVal = d.parent.data.label + " -> " + retVal;
|
|
2148
|
+
d = d.parent;
|
|
2149
|
+
}
|
|
2150
|
+
return retVal;
|
|
2151
|
+
}
|
|
2152
|
+
__name(tooltip, "tooltip");
|
|
2153
|
+
}
|
|
2154
|
+
exit(domNode, element) {
|
|
2155
|
+
super.exit(domNode, element);
|
|
2156
|
+
}
|
|
2157
|
+
nodeWeight(d) {
|
|
2158
|
+
return d.size || 1;
|
|
2159
|
+
}
|
|
2160
|
+
parentWeightHTML(d) {
|
|
2161
|
+
return this.showParentWeight() ? `<span class="treemap-parent-label">${d.data.label}</span><span class="treemap-parent-value">${d.value}${this.weightSuffix()}</span>` : `<span class="treemap-parent-label">${d.data.label}</span>`;
|
|
2162
|
+
}
|
|
2163
|
+
leafWeightHTML(d) {
|
|
2164
|
+
return this.showLeafWeight() ? `<span class="treemap-leaf-label">${d.data.label}</span><span class="treemap-leaf-value">${d.value}${this.weightSuffix()}</span>` : `<span class="treemap-leaf-label">${d.data.label}</span>`;
|
|
2165
|
+
}
|
|
1964
2166
|
};
|
|
2167
|
+
__name(_Treemap, "Treemap");
|
|
2168
|
+
let Treemap = _Treemap;
|
|
1965
2169
|
Treemap.prototype._class += " tree_Treemap";
|
|
1966
2170
|
Treemap.prototype.implements(ITree.prototype);
|
|
1967
2171
|
Treemap.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
@@ -1969,20 +2173,10 @@ Treemap.prototype.Column = TreemapColumn;
|
|
|
1969
2173
|
Treemap.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Treemap.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
1970
2174
|
Treemap.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
1971
2175
|
Treemap.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: TreemapColumn });
|
|
1972
|
-
Treemap.prototype.publish("aggrType", null, "set", "Aggregation Type", [
|
|
1973
|
-
null,
|
|
1974
|
-
"mean",
|
|
1975
|
-
"median",
|
|
1976
|
-
"sum",
|
|
1977
|
-
"min",
|
|
1978
|
-
"max"
|
|
1979
|
-
], { optional: true });
|
|
2176
|
+
Treemap.prototype.publish("aggrType", null, "set", "Aggregation Type", [null, "mean", "median", "sum", "min", "max"], { optional: true });
|
|
1980
2177
|
Treemap.prototype.publish("aggrColumn", null, "set", "Aggregation Field", function() {
|
|
1981
|
-
|
|
1982
|
-
}, {
|
|
1983
|
-
optional: true,
|
|
1984
|
-
disable: (w) => !w.aggrType()
|
|
1985
|
-
});
|
|
2178
|
+
return this.columns();
|
|
2179
|
+
}, { optional: true, disable: /* @__PURE__ */ __name((w) => !w.aggrType(), "disable") });
|
|
1986
2180
|
Treemap.prototype.publish("fontSize", null, "number", "Font Size", null, { optional: true });
|
|
1987
2181
|
Treemap.prototype.publish("paddingInner", 18.6, "number", "Pixel spacing between each sibling node");
|
|
1988
2182
|
Treemap.prototype.publish("paddingOuter", 30, "number", "Pixel padding of parent nodes");
|
|
@@ -1991,14 +2185,8 @@ Treemap.prototype.publish("showRoot", false, "boolean", "Show root element");
|
|
|
1991
2185
|
Treemap.prototype.publish("parentFontSize", 18, "number", "Parent font-size");
|
|
1992
2186
|
Treemap.prototype.publish("leafFontSize", 16, "number", "Leaf font-size");
|
|
1993
2187
|
Treemap.prototype.publish("usePaletteOnParentNodes", false, "boolean", "Assign a color from the palette to every parent node");
|
|
1994
|
-
Treemap.prototype.publish("depthColorLimit", 1, "number", "Assign a color from the palette to node with depth lower than this value", null, {
|
|
1995
|
-
|
|
1996
|
-
disable: (w) => w.usePaletteOnParentNodes()
|
|
1997
|
-
});
|
|
1998
|
-
Treemap.prototype.publish("squarifyRatio", 1, "number", "Specifies the desired aspect ratio of the generated rectangles (must be >= 1)", null, {
|
|
1999
|
-
optional: true,
|
|
2000
|
-
disable: (w) => ["treemapSquarify", "treemapResquarify"].indexOf(w.tilingMethod()) === -1
|
|
2001
|
-
});
|
|
2188
|
+
Treemap.prototype.publish("depthColorLimit", 1, "number", "Assign a color from the palette to node with depth lower than this value", null, { optional: true, disable: /* @__PURE__ */ __name((w) => w.usePaletteOnParentNodes(), "disable") });
|
|
2189
|
+
Treemap.prototype.publish("squarifyRatio", 1, "number", "Specifies the desired aspect ratio of the generated rectangles (must be >= 1)", null, { optional: true, disable: /* @__PURE__ */ __name((w) => ["treemapSquarify", "treemapResquarify"].indexOf(w.tilingMethod()) === -1, "disable") });
|
|
2002
2190
|
Treemap.prototype.publish("showParentWeight", true, "boolean", "Show weight of parent nodes");
|
|
2003
2191
|
Treemap.prototype.publish("showLeafWeight", true, "boolean", "Show weight of leaf nodes");
|
|
2004
2192
|
Treemap.prototype.publish("weightSuffix", "", "string", "Weight suffix (ex: 'ms')");
|
|
@@ -2006,15 +2194,20 @@ Treemap.prototype.publish("brighterLeafNodes", false, "boolean", "Brighter/darke
|
|
|
2006
2194
|
Treemap.prototype.publish("enableParentLabels", true, "boolean", "Enable parent labels");
|
|
2007
2195
|
Treemap.prototype.publish("enableParentTooltips", true, "boolean", "Enable parent tooltips");
|
|
2008
2196
|
Treemap.prototype.publish("transitionDuration", 250, "number", "Transition Duration");
|
|
2009
|
-
Treemap.prototype.publish("tilingMethod", "treemapSquarify", "set", "Transition Duration", [
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2197
|
+
Treemap.prototype.publish("tilingMethod", "treemapSquarify", "set", "Transition Duration", ["treemapBinary", "treemapDice", "treemapResquarify", "treemapSlice", "treemapSliceDice", "treemapSquarify"]);
|
|
2198
|
+
export {
|
|
2199
|
+
BUILD_VERSION,
|
|
2200
|
+
CirclePacking,
|
|
2201
|
+
Dendrogram,
|
|
2202
|
+
DendrogramColumn,
|
|
2203
|
+
DirectoryTree,
|
|
2204
|
+
Indented,
|
|
2205
|
+
IndentedColumn,
|
|
2206
|
+
PKG_NAME,
|
|
2207
|
+
PKG_VERSION,
|
|
2208
|
+
SunburstPartition,
|
|
2209
|
+
Treemap,
|
|
2210
|
+
TreemapColumn
|
|
2211
|
+
};
|
|
2212
|
+
//# sourceMappingURL=index.js.map
|
|
2213
|
+
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".tree_CirclePacking circle{fill:#1f77b4;fill-opacity:.25;stroke:#1f77b4;stroke-width:1px}.tree_CirclePacking .leaf circle{fill:#ff7f0e;fill-opacity:1}.tree_CirclePacking .label{fill:#fff;text-anchor:middle}.tree_Dendrogram .node circle{fill:#dcf1ff;stroke:#1f77b4;stroke-width:1px}.tree_Dendrogram .node.selected circle{stroke:red}.tree_Dendrogram .node.over circle{stroke:orange}.tree_Dendrogram .node.selected.over circle{stroke:red}.tree_Dendrogram .node.selected text{fill:red}.tree_Dendrogram .node.over text{fill:orange}.tree_Dendrogram .node.selected.over text{fill:red}.tree_Dendrogram .node text{font-size:14px}.tree_Dendrogram .link{fill:none;stroke:#656565;stroke-width:1px}.tree_Indented .node rect{cursor:pointer;fill:#fff;stroke:#3182bd;stroke-width:1px}.tree_Indented .node text{font:10px sans-serif;pointer-events:none}.tree_Indented path.link{fill:none;stroke:#9ecae1;stroke-width:1.5px}.tree_Sunburst path{stroke:#fff;stroke-width:.5px;fill-rule:evenodd}.tree_Treemap *{box-sizing:border-box}.tree_Treemap .node{border:solid 1px #333;overflow:hidden;text-overflow:ellipsis;position:absolute}.tree_Treemap .node.selected{border-color:red}.tree_Treemap .node.over{border-color:orange}.tree_Treemap .node.selected.over{border-color:red}.tree_Treemap .node>span.treemap-parent-label{font-weight:700;display:inline-block;margin:4px 4px 0}.tree_Treemap .node>span.treemap-parent-value{font-weight:400;font-style:italic;margin:4px 0 0}.tree_Treemap .node>span.treemap-singleton-label{font-weight:400;display:block;margin:4px 0 0 4px}.tree_Treemap .node>span.treemap-singleton-value{font-style:italic;display:block;margin:0 0 0 4px}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}}();
|