@hpcc-js/tree 2.42.0 → 3.0.0
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 +121 -2851
- package/dist/index.js.map +7 -1
- package/package.json +29 -33
- package/src/CirclePacking.ts +12 -8
- package/src/Dendrogram.ts +32 -20
- package/src/DirectoryTree.ts +25 -29
- package/src/Indented.ts +20 -13
- package/src/SunburstPartition.ts +14 -8
- package/src/Treemap.ts +59 -33
- package/src/__package__.ts +2 -2
- package/src/index.ts +7 -7
- package/types/CirclePacking.d.ts +7 -6
- package/types/Dendrogram.d.ts +20 -35
- package/types/DirectoryTree.d.ts +11 -16
- package/types/Indented.d.ts +11 -16
- package/types/SunburstPartition.d.ts +8 -5
- package/types/Treemap.d.ts +51 -96
- package/types/__package__.d.ts +2 -3
- package/types/index.d.ts +7 -8
- package/dist/index.es6.js +0 -2836
- package/dist/index.es6.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/types/CirclePacking.d.ts.map +0 -1
- package/types/Dendrogram.d.ts.map +0 -1
- package/types/DirectoryTree.d.ts.map +0 -1
- package/types/Indented.d.ts.map +0 -1
- package/types/SunburstPartition.d.ts.map +0 -1
- package/types/Treemap.d.ts.map +0 -1
- package/types/__package__.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types-3.4/CirclePacking.d.ts +0 -32
- package/types-3.4/Dendrogram.d.ts +0 -60
- package/types-3.4/DirectoryTree.d.ts +0 -62
- package/types-3.4/Indented.d.ts +0 -46
- package/types-3.4/SunburstPartition.d.ts +0 -23
- package/types-3.4/Treemap.d.ts +0 -125
- package/types-3.4/__package__.d.ts +0 -4
- package/types-3.4/index.d.ts +0 -8
package/dist/index.es6.js
DELETED
|
@@ -1,2836 +0,0 @@
|
|
|
1
|
-
import { ITree } from '@hpcc-js/api';
|
|
2
|
-
import { rgb, d3Event, interpolateZoom, SVGWidget, Utility, PropertyExt, select, SVGZoomWidget, Palette, Platform, max as max$1, HTMLWidget, scaleLinear, scaleSqrt, interpolate } from '@hpcc-js/common';
|
|
3
|
-
|
|
4
|
-
var PKG_NAME = "@hpcc-js/tree";
|
|
5
|
-
var PKG_VERSION = "2.42.0";
|
|
6
|
-
var BUILD_VERSION = "2.107.0";
|
|
7
|
-
|
|
8
|
-
/******************************************************************************
|
|
9
|
-
Copyright (c) Microsoft Corporation.
|
|
10
|
-
|
|
11
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
-
purpose with or without fee is hereby granted.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
-
***************************************************************************** */
|
|
22
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
23
|
-
|
|
24
|
-
var extendStatics = function(d, b) {
|
|
25
|
-
extendStatics = Object.setPrototypeOf ||
|
|
26
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
27
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
28
|
-
return extendStatics(d, b);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function __extends(d, b) {
|
|
32
|
-
if (typeof b !== "function" && b !== null)
|
|
33
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
34
|
-
extendStatics(d, b);
|
|
35
|
-
function __() { this.constructor = d; }
|
|
36
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
40
|
-
var e = new Error(message);
|
|
41
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function defaultSeparation$1(a, b) {
|
|
45
|
-
return a.parent === b.parent ? 1 : 2;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function meanX(children) {
|
|
49
|
-
return children.reduce(meanXReduce, 0) / children.length;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function meanXReduce(x, c) {
|
|
53
|
-
return x + c.x;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function maxY(children) {
|
|
57
|
-
return 1 + children.reduce(maxYReduce, 0);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function maxYReduce(y, c) {
|
|
61
|
-
return Math.max(y, c.y);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function leafLeft(node) {
|
|
65
|
-
var children;
|
|
66
|
-
while (children = node.children) node = children[0];
|
|
67
|
-
return node;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function leafRight(node) {
|
|
71
|
-
var children;
|
|
72
|
-
while (children = node.children) node = children[children.length - 1];
|
|
73
|
-
return node;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function d3Cluster() {
|
|
77
|
-
var separation = defaultSeparation$1,
|
|
78
|
-
dx = 1,
|
|
79
|
-
dy = 1,
|
|
80
|
-
nodeSize = false;
|
|
81
|
-
|
|
82
|
-
function cluster(root) {
|
|
83
|
-
var previousNode,
|
|
84
|
-
x = 0;
|
|
85
|
-
|
|
86
|
-
// First walk, computing the initial x & y values.
|
|
87
|
-
root.eachAfter(function(node) {
|
|
88
|
-
var children = node.children;
|
|
89
|
-
if (children) {
|
|
90
|
-
node.x = meanX(children);
|
|
91
|
-
node.y = maxY(children);
|
|
92
|
-
} else {
|
|
93
|
-
node.x = previousNode ? x += separation(node, previousNode) : 0;
|
|
94
|
-
node.y = 0;
|
|
95
|
-
previousNode = node;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
var left = leafLeft(root),
|
|
100
|
-
right = leafRight(root),
|
|
101
|
-
x0 = left.x - separation(left, right) / 2,
|
|
102
|
-
x1 = right.x + separation(right, left) / 2;
|
|
103
|
-
|
|
104
|
-
// Second walk, normalizing x & y to the desired size.
|
|
105
|
-
return root.eachAfter(nodeSize ? function(node) {
|
|
106
|
-
node.x = (node.x - root.x) * dx;
|
|
107
|
-
node.y = (root.y - node.y) * dy;
|
|
108
|
-
} : function(node) {
|
|
109
|
-
node.x = (node.x - x0) / (x1 - x0) * dx;
|
|
110
|
-
node.y = (1 - (root.y ? node.y / root.y : 1)) * dy;
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
cluster.separation = function(x) {
|
|
115
|
-
return arguments.length ? (separation = x, cluster) : separation;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
cluster.size = function(x) {
|
|
119
|
-
return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? null : [dx, dy]);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
cluster.nodeSize = function(x) {
|
|
123
|
-
return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? [dx, dy] : null);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
return cluster;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function count(node) {
|
|
130
|
-
var sum = 0,
|
|
131
|
-
children = node.children,
|
|
132
|
-
i = children && children.length;
|
|
133
|
-
if (!i) sum = 1;
|
|
134
|
-
else while (--i >= 0) sum += children[i].value;
|
|
135
|
-
node.value = sum;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function node_count() {
|
|
139
|
-
return this.eachAfter(count);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function node_each(callback) {
|
|
143
|
-
var node = this, current, next = [node], children, i, n;
|
|
144
|
-
do {
|
|
145
|
-
current = next.reverse(), next = [];
|
|
146
|
-
while (node = current.pop()) {
|
|
147
|
-
callback(node), children = node.children;
|
|
148
|
-
if (children) for (i = 0, n = children.length; i < n; ++i) {
|
|
149
|
-
next.push(children[i]);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
} while (next.length);
|
|
153
|
-
return this;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function node_eachBefore(callback) {
|
|
157
|
-
var node = this, nodes = [node], children, i;
|
|
158
|
-
while (node = nodes.pop()) {
|
|
159
|
-
callback(node), children = node.children;
|
|
160
|
-
if (children) for (i = children.length - 1; i >= 0; --i) {
|
|
161
|
-
nodes.push(children[i]);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return this;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function node_eachAfter(callback) {
|
|
168
|
-
var node = this, nodes = [node], next = [], children, i, n;
|
|
169
|
-
while (node = nodes.pop()) {
|
|
170
|
-
next.push(node), children = node.children;
|
|
171
|
-
if (children) for (i = 0, n = children.length; i < n; ++i) {
|
|
172
|
-
nodes.push(children[i]);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
while (node = next.pop()) {
|
|
176
|
-
callback(node);
|
|
177
|
-
}
|
|
178
|
-
return this;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function node_sum(value) {
|
|
182
|
-
return this.eachAfter(function(node) {
|
|
183
|
-
var sum = +value(node.data) || 0,
|
|
184
|
-
children = node.children,
|
|
185
|
-
i = children && children.length;
|
|
186
|
-
while (--i >= 0) sum += children[i].value;
|
|
187
|
-
node.value = sum;
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function node_sort(compare) {
|
|
192
|
-
return this.eachBefore(function(node) {
|
|
193
|
-
if (node.children) {
|
|
194
|
-
node.children.sort(compare);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function node_path(end) {
|
|
200
|
-
var start = this,
|
|
201
|
-
ancestor = leastCommonAncestor(start, end),
|
|
202
|
-
nodes = [start];
|
|
203
|
-
while (start !== ancestor) {
|
|
204
|
-
start = start.parent;
|
|
205
|
-
nodes.push(start);
|
|
206
|
-
}
|
|
207
|
-
var k = nodes.length;
|
|
208
|
-
while (end !== ancestor) {
|
|
209
|
-
nodes.splice(k, 0, end);
|
|
210
|
-
end = end.parent;
|
|
211
|
-
}
|
|
212
|
-
return nodes;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function leastCommonAncestor(a, b) {
|
|
216
|
-
if (a === b) return a;
|
|
217
|
-
var aNodes = a.ancestors(),
|
|
218
|
-
bNodes = b.ancestors(),
|
|
219
|
-
c = null;
|
|
220
|
-
a = aNodes.pop();
|
|
221
|
-
b = bNodes.pop();
|
|
222
|
-
while (a === b) {
|
|
223
|
-
c = a;
|
|
224
|
-
a = aNodes.pop();
|
|
225
|
-
b = bNodes.pop();
|
|
226
|
-
}
|
|
227
|
-
return c;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function node_ancestors() {
|
|
231
|
-
var node = this, nodes = [node];
|
|
232
|
-
while (node = node.parent) {
|
|
233
|
-
nodes.push(node);
|
|
234
|
-
}
|
|
235
|
-
return nodes;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function node_descendants() {
|
|
239
|
-
var nodes = [];
|
|
240
|
-
this.each(function(node) {
|
|
241
|
-
nodes.push(node);
|
|
242
|
-
});
|
|
243
|
-
return nodes;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function node_leaves() {
|
|
247
|
-
var leaves = [];
|
|
248
|
-
this.eachBefore(function(node) {
|
|
249
|
-
if (!node.children) {
|
|
250
|
-
leaves.push(node);
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
return leaves;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function node_links() {
|
|
257
|
-
var root = this, links = [];
|
|
258
|
-
root.each(function(node) {
|
|
259
|
-
if (node !== root) { // Don’t include the root’s parent, if any.
|
|
260
|
-
links.push({source: node.parent, target: node});
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
return links;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function hierarchy(data, children) {
|
|
267
|
-
var root = new Node$1(data),
|
|
268
|
-
valued = +data.value && (root.value = data.value),
|
|
269
|
-
node,
|
|
270
|
-
nodes = [root],
|
|
271
|
-
child,
|
|
272
|
-
childs,
|
|
273
|
-
i,
|
|
274
|
-
n;
|
|
275
|
-
|
|
276
|
-
if (children == null) children = defaultChildren;
|
|
277
|
-
|
|
278
|
-
while (node = nodes.pop()) {
|
|
279
|
-
if (valued) node.value = +node.data.value;
|
|
280
|
-
if ((childs = children(node.data)) && (n = childs.length)) {
|
|
281
|
-
node.children = new Array(n);
|
|
282
|
-
for (i = n - 1; i >= 0; --i) {
|
|
283
|
-
nodes.push(child = node.children[i] = new Node$1(childs[i]));
|
|
284
|
-
child.parent = node;
|
|
285
|
-
child.depth = node.depth + 1;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return root.eachBefore(computeHeight);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function node_copy() {
|
|
294
|
-
return hierarchy(this).eachBefore(copyData);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function defaultChildren(d) {
|
|
298
|
-
return d.children;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function copyData(node) {
|
|
302
|
-
node.data = node.data.data;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function computeHeight(node) {
|
|
306
|
-
var height = 0;
|
|
307
|
-
do node.height = height;
|
|
308
|
-
while ((node = node.parent) && (node.height < ++height));
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function Node$1(data) {
|
|
312
|
-
this.data = data;
|
|
313
|
-
this.depth =
|
|
314
|
-
this.height = 0;
|
|
315
|
-
this.parent = null;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
Node$1.prototype = hierarchy.prototype = {
|
|
319
|
-
constructor: Node$1,
|
|
320
|
-
count: node_count,
|
|
321
|
-
each: node_each,
|
|
322
|
-
eachAfter: node_eachAfter,
|
|
323
|
-
eachBefore: node_eachBefore,
|
|
324
|
-
sum: node_sum,
|
|
325
|
-
sort: node_sort,
|
|
326
|
-
path: node_path,
|
|
327
|
-
ancestors: node_ancestors,
|
|
328
|
-
descendants: node_descendants,
|
|
329
|
-
leaves: node_leaves,
|
|
330
|
-
links: node_links,
|
|
331
|
-
copy: node_copy
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
var slice = Array.prototype.slice;
|
|
335
|
-
|
|
336
|
-
function shuffle(array) {
|
|
337
|
-
var m = array.length,
|
|
338
|
-
t,
|
|
339
|
-
i;
|
|
340
|
-
|
|
341
|
-
while (m) {
|
|
342
|
-
i = Math.random() * m-- | 0;
|
|
343
|
-
t = array[m];
|
|
344
|
-
array[m] = array[i];
|
|
345
|
-
array[i] = t;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return array;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function enclose(circles) {
|
|
352
|
-
var i = 0, n = (circles = shuffle(slice.call(circles))).length, B = [], p, e;
|
|
353
|
-
|
|
354
|
-
while (i < n) {
|
|
355
|
-
p = circles[i];
|
|
356
|
-
if (e && enclosesWeak(e, p)) ++i;
|
|
357
|
-
else e = encloseBasis(B = extendBasis(B, p)), i = 0;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return e;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
function extendBasis(B, p) {
|
|
364
|
-
var i, j;
|
|
365
|
-
|
|
366
|
-
if (enclosesWeakAll(p, B)) return [p];
|
|
367
|
-
|
|
368
|
-
// If we get here then B must have at least one element.
|
|
369
|
-
for (i = 0; i < B.length; ++i) {
|
|
370
|
-
if (enclosesNot(p, B[i])
|
|
371
|
-
&& enclosesWeakAll(encloseBasis2(B[i], p), B)) {
|
|
372
|
-
return [B[i], p];
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// If we get here then B must have at least two elements.
|
|
377
|
-
for (i = 0; i < B.length - 1; ++i) {
|
|
378
|
-
for (j = i + 1; j < B.length; ++j) {
|
|
379
|
-
if (enclosesNot(encloseBasis2(B[i], B[j]), p)
|
|
380
|
-
&& enclosesNot(encloseBasis2(B[i], p), B[j])
|
|
381
|
-
&& enclosesNot(encloseBasis2(B[j], p), B[i])
|
|
382
|
-
&& enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
|
|
383
|
-
return [B[i], B[j], p];
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// If we get here then something is very wrong.
|
|
389
|
-
throw new Error;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function enclosesNot(a, b) {
|
|
393
|
-
var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
|
|
394
|
-
return dr < 0 || dr * dr < dx * dx + dy * dy;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function enclosesWeak(a, b) {
|
|
398
|
-
var dr = a.r - b.r + 1e-6, dx = b.x - a.x, dy = b.y - a.y;
|
|
399
|
-
return dr > 0 && dr * dr > dx * dx + dy * dy;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function enclosesWeakAll(a, B) {
|
|
403
|
-
for (var i = 0; i < B.length; ++i) {
|
|
404
|
-
if (!enclosesWeak(a, B[i])) {
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return true;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
function encloseBasis(B) {
|
|
412
|
-
switch (B.length) {
|
|
413
|
-
case 1: return encloseBasis1(B[0]);
|
|
414
|
-
case 2: return encloseBasis2(B[0], B[1]);
|
|
415
|
-
case 3: return encloseBasis3(B[0], B[1], B[2]);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function encloseBasis1(a) {
|
|
420
|
-
return {
|
|
421
|
-
x: a.x,
|
|
422
|
-
y: a.y,
|
|
423
|
-
r: a.r
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
function encloseBasis2(a, b) {
|
|
428
|
-
var x1 = a.x, y1 = a.y, r1 = a.r,
|
|
429
|
-
x2 = b.x, y2 = b.y, r2 = b.r,
|
|
430
|
-
x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1,
|
|
431
|
-
l = Math.sqrt(x21 * x21 + y21 * y21);
|
|
432
|
-
return {
|
|
433
|
-
x: (x1 + x2 + x21 / l * r21) / 2,
|
|
434
|
-
y: (y1 + y2 + y21 / l * r21) / 2,
|
|
435
|
-
r: (l + r1 + r2) / 2
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
function encloseBasis3(a, b, c) {
|
|
440
|
-
var x1 = a.x, y1 = a.y, r1 = a.r,
|
|
441
|
-
x2 = b.x, y2 = b.y, r2 = b.r,
|
|
442
|
-
x3 = c.x, y3 = c.y, r3 = c.r,
|
|
443
|
-
a2 = x1 - x2,
|
|
444
|
-
a3 = x1 - x3,
|
|
445
|
-
b2 = y1 - y2,
|
|
446
|
-
b3 = y1 - y3,
|
|
447
|
-
c2 = r2 - r1,
|
|
448
|
-
c3 = r3 - r1,
|
|
449
|
-
d1 = x1 * x1 + y1 * y1 - r1 * r1,
|
|
450
|
-
d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2,
|
|
451
|
-
d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3,
|
|
452
|
-
ab = a3 * b2 - a2 * b3,
|
|
453
|
-
xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1,
|
|
454
|
-
xb = (b3 * c2 - b2 * c3) / ab,
|
|
455
|
-
ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1,
|
|
456
|
-
yb = (a2 * c3 - a3 * c2) / ab,
|
|
457
|
-
A = xb * xb + yb * yb - 1,
|
|
458
|
-
B = 2 * (r1 + xa * xb + ya * yb),
|
|
459
|
-
C = xa * xa + ya * ya - r1 * r1,
|
|
460
|
-
r = -(A ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
|
|
461
|
-
return {
|
|
462
|
-
x: x1 + xa + xb * r,
|
|
463
|
-
y: y1 + ya + yb * r,
|
|
464
|
-
r: r
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
function place(b, a, c) {
|
|
469
|
-
var dx = b.x - a.x, x, a2,
|
|
470
|
-
dy = b.y - a.y, y, b2,
|
|
471
|
-
d2 = dx * dx + dy * dy;
|
|
472
|
-
if (d2) {
|
|
473
|
-
a2 = a.r + c.r, a2 *= a2;
|
|
474
|
-
b2 = b.r + c.r, b2 *= b2;
|
|
475
|
-
if (a2 > b2) {
|
|
476
|
-
x = (d2 + b2 - a2) / (2 * d2);
|
|
477
|
-
y = Math.sqrt(Math.max(0, b2 / d2 - x * x));
|
|
478
|
-
c.x = b.x - x * dx - y * dy;
|
|
479
|
-
c.y = b.y - x * dy + y * dx;
|
|
480
|
-
} else {
|
|
481
|
-
x = (d2 + a2 - b2) / (2 * d2);
|
|
482
|
-
y = Math.sqrt(Math.max(0, a2 / d2 - x * x));
|
|
483
|
-
c.x = a.x + x * dx - y * dy;
|
|
484
|
-
c.y = a.y + x * dy + y * dx;
|
|
485
|
-
}
|
|
486
|
-
} else {
|
|
487
|
-
c.x = a.x + c.r;
|
|
488
|
-
c.y = a.y;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function intersects(a, b) {
|
|
493
|
-
var dr = a.r + b.r - 1e-6, dx = b.x - a.x, dy = b.y - a.y;
|
|
494
|
-
return dr > 0 && dr * dr > dx * dx + dy * dy;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
function score(node) {
|
|
498
|
-
var a = node._,
|
|
499
|
-
b = node.next._,
|
|
500
|
-
ab = a.r + b.r,
|
|
501
|
-
dx = (a.x * b.r + b.x * a.r) / ab,
|
|
502
|
-
dy = (a.y * b.r + b.y * a.r) / ab;
|
|
503
|
-
return dx * dx + dy * dy;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function Node(circle) {
|
|
507
|
-
this._ = circle;
|
|
508
|
-
this.next = null;
|
|
509
|
-
this.previous = null;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
function packEnclose(circles) {
|
|
513
|
-
if (!(n = circles.length)) return 0;
|
|
514
|
-
|
|
515
|
-
var a, b, c, n, aa, ca, i, j, k, sj, sk;
|
|
516
|
-
|
|
517
|
-
// Place the first circle.
|
|
518
|
-
a = circles[0], a.x = 0, a.y = 0;
|
|
519
|
-
if (!(n > 1)) return a.r;
|
|
520
|
-
|
|
521
|
-
// Place the second circle.
|
|
522
|
-
b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0;
|
|
523
|
-
if (!(n > 2)) return a.r + b.r;
|
|
524
|
-
|
|
525
|
-
// Place the third circle.
|
|
526
|
-
place(b, a, c = circles[2]);
|
|
527
|
-
|
|
528
|
-
// Initialize the front-chain using the first three circles a, b and c.
|
|
529
|
-
a = new Node(a), b = new Node(b), c = new Node(c);
|
|
530
|
-
a.next = c.previous = b;
|
|
531
|
-
b.next = a.previous = c;
|
|
532
|
-
c.next = b.previous = a;
|
|
533
|
-
|
|
534
|
-
// Attempt to place each remaining circle…
|
|
535
|
-
pack: for (i = 3; i < n; ++i) {
|
|
536
|
-
place(a._, b._, c = circles[i]), c = new Node(c);
|
|
537
|
-
|
|
538
|
-
// Find the closest intersecting circle on the front-chain, if any.
|
|
539
|
-
// “Closeness” is determined by linear distance along the front-chain.
|
|
540
|
-
// “Ahead” or “behind” is likewise determined by linear distance.
|
|
541
|
-
j = b.next, k = a.previous, sj = b._.r, sk = a._.r;
|
|
542
|
-
do {
|
|
543
|
-
if (sj <= sk) {
|
|
544
|
-
if (intersects(j._, c._)) {
|
|
545
|
-
b = j, a.next = b, b.previous = a, --i;
|
|
546
|
-
continue pack;
|
|
547
|
-
}
|
|
548
|
-
sj += j._.r, j = j.next;
|
|
549
|
-
} else {
|
|
550
|
-
if (intersects(k._, c._)) {
|
|
551
|
-
a = k, a.next = b, b.previous = a, --i;
|
|
552
|
-
continue pack;
|
|
553
|
-
}
|
|
554
|
-
sk += k._.r, k = k.previous;
|
|
555
|
-
}
|
|
556
|
-
} while (j !== k.next);
|
|
557
|
-
|
|
558
|
-
// Success! Insert the new circle c between a and b.
|
|
559
|
-
c.previous = a, c.next = b, a.next = b.previous = b = c;
|
|
560
|
-
|
|
561
|
-
// Compute the new closest circle pair to the centroid.
|
|
562
|
-
aa = score(a);
|
|
563
|
-
while ((c = c.next) !== b) {
|
|
564
|
-
if ((ca = score(c)) < aa) {
|
|
565
|
-
a = c, aa = ca;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
b = a.next;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
// Compute the enclosing circle of the front chain.
|
|
572
|
-
a = [b._], c = b; while ((c = c.next) !== b) a.push(c._); c = enclose(a);
|
|
573
|
-
|
|
574
|
-
// Translate the circles to put the enclosing circle around the origin.
|
|
575
|
-
for (i = 0; i < n; ++i) a = circles[i], a.x -= c.x, a.y -= c.y;
|
|
576
|
-
|
|
577
|
-
return c.r;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
function optional(f) {
|
|
581
|
-
return f == null ? null : required(f);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
function required(f) {
|
|
585
|
-
if (typeof f !== "function") throw new Error;
|
|
586
|
-
return f;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
function constantZero() {
|
|
590
|
-
return 0;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
function constant$1(x) {
|
|
594
|
-
return function() {
|
|
595
|
-
return x;
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
function defaultRadius(d) {
|
|
600
|
-
return Math.sqrt(d.value);
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function d3Pack() {
|
|
604
|
-
var radius = null,
|
|
605
|
-
dx = 1,
|
|
606
|
-
dy = 1,
|
|
607
|
-
padding = constantZero;
|
|
608
|
-
|
|
609
|
-
function pack(root) {
|
|
610
|
-
root.x = dx / 2, root.y = dy / 2;
|
|
611
|
-
if (radius) {
|
|
612
|
-
root.eachBefore(radiusLeaf(radius))
|
|
613
|
-
.eachAfter(packChildren(padding, 0.5))
|
|
614
|
-
.eachBefore(translateChild(1));
|
|
615
|
-
} else {
|
|
616
|
-
root.eachBefore(radiusLeaf(defaultRadius))
|
|
617
|
-
.eachAfter(packChildren(constantZero, 1))
|
|
618
|
-
.eachAfter(packChildren(padding, root.r / Math.min(dx, dy)))
|
|
619
|
-
.eachBefore(translateChild(Math.min(dx, dy) / (2 * root.r)));
|
|
620
|
-
}
|
|
621
|
-
return root;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
pack.radius = function(x) {
|
|
625
|
-
return arguments.length ? (radius = optional(x), pack) : radius;
|
|
626
|
-
};
|
|
627
|
-
|
|
628
|
-
pack.size = function(x) {
|
|
629
|
-
return arguments.length ? (dx = +x[0], dy = +x[1], pack) : [dx, dy];
|
|
630
|
-
};
|
|
631
|
-
|
|
632
|
-
pack.padding = function(x) {
|
|
633
|
-
return arguments.length ? (padding = typeof x === "function" ? x : constant$1(+x), pack) : padding;
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
return pack;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
function radiusLeaf(radius) {
|
|
640
|
-
return function(node) {
|
|
641
|
-
if (!node.children) {
|
|
642
|
-
node.r = Math.max(0, +radius(node) || 0);
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
function packChildren(padding, k) {
|
|
648
|
-
return function(node) {
|
|
649
|
-
if (children = node.children) {
|
|
650
|
-
var children,
|
|
651
|
-
i,
|
|
652
|
-
n = children.length,
|
|
653
|
-
r = padding(node) * k || 0,
|
|
654
|
-
e;
|
|
655
|
-
|
|
656
|
-
if (r) for (i = 0; i < n; ++i) children[i].r += r;
|
|
657
|
-
e = packEnclose(children);
|
|
658
|
-
if (r) for (i = 0; i < n; ++i) children[i].r -= r;
|
|
659
|
-
node.r = e + r;
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
function translateChild(k) {
|
|
665
|
-
return function(node) {
|
|
666
|
-
var parent = node.parent;
|
|
667
|
-
node.r *= k;
|
|
668
|
-
if (parent) {
|
|
669
|
-
node.x = parent.x + k * node.x;
|
|
670
|
-
node.y = parent.y + k * node.y;
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
function roundNode(node) {
|
|
676
|
-
node.x0 = Math.round(node.x0);
|
|
677
|
-
node.y0 = Math.round(node.y0);
|
|
678
|
-
node.x1 = Math.round(node.x1);
|
|
679
|
-
node.y1 = Math.round(node.y1);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
function d3treemapDice(parent, x0, y0, x1, y1) {
|
|
683
|
-
var nodes = parent.children,
|
|
684
|
-
node,
|
|
685
|
-
i = -1,
|
|
686
|
-
n = nodes.length,
|
|
687
|
-
k = parent.value && (x1 - x0) / parent.value;
|
|
688
|
-
|
|
689
|
-
while (++i < n) {
|
|
690
|
-
node = nodes[i], node.y0 = y0, node.y1 = y1;
|
|
691
|
-
node.x0 = x0, node.x1 = x0 += node.value * k;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function d3Parition() {
|
|
696
|
-
var dx = 1,
|
|
697
|
-
dy = 1,
|
|
698
|
-
padding = 0,
|
|
699
|
-
round = false;
|
|
700
|
-
|
|
701
|
-
function partition(root) {
|
|
702
|
-
var n = root.height + 1;
|
|
703
|
-
root.x0 =
|
|
704
|
-
root.y0 = padding;
|
|
705
|
-
root.x1 = dx;
|
|
706
|
-
root.y1 = dy / n;
|
|
707
|
-
root.eachBefore(positionNode(dy, n));
|
|
708
|
-
if (round) root.eachBefore(roundNode);
|
|
709
|
-
return root;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
function positionNode(dy, n) {
|
|
713
|
-
return function(node) {
|
|
714
|
-
if (node.children) {
|
|
715
|
-
d3treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n);
|
|
716
|
-
}
|
|
717
|
-
var x0 = node.x0,
|
|
718
|
-
y0 = node.y0,
|
|
719
|
-
x1 = node.x1 - padding,
|
|
720
|
-
y1 = node.y1 - padding;
|
|
721
|
-
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
722
|
-
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
723
|
-
node.x0 = x0;
|
|
724
|
-
node.y0 = y0;
|
|
725
|
-
node.x1 = x1;
|
|
726
|
-
node.y1 = y1;
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
partition.round = function(x) {
|
|
731
|
-
return arguments.length ? (round = !!x, partition) : round;
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
partition.size = function(x) {
|
|
735
|
-
return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy];
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
partition.padding = function(x) {
|
|
739
|
-
return arguments.length ? (padding = +x, partition) : padding;
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
return partition;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
function defaultSeparation(a, b) {
|
|
746
|
-
return a.parent === b.parent ? 1 : 2;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
// function radialSeparation(a, b) {
|
|
750
|
-
// return (a.parent === b.parent ? 1 : 2) / a.depth;
|
|
751
|
-
// }
|
|
752
|
-
|
|
753
|
-
// This function is used to traverse the left contour of a subtree (or
|
|
754
|
-
// subforest). It returns the successor of v on this contour. This successor is
|
|
755
|
-
// either given by the leftmost child of v or by the thread of v. The function
|
|
756
|
-
// returns null if and only if v is on the highest level of its subtree.
|
|
757
|
-
function nextLeft(v) {
|
|
758
|
-
var children = v.children;
|
|
759
|
-
return children ? children[0] : v.t;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// This function works analogously to nextLeft.
|
|
763
|
-
function nextRight(v) {
|
|
764
|
-
var children = v.children;
|
|
765
|
-
return children ? children[children.length - 1] : v.t;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
// Shifts the current subtree rooted at w+. This is done by increasing
|
|
769
|
-
// prelim(w+) and mod(w+) by shift.
|
|
770
|
-
function moveSubtree(wm, wp, shift) {
|
|
771
|
-
var change = shift / (wp.i - wm.i);
|
|
772
|
-
wp.c -= change;
|
|
773
|
-
wp.s += shift;
|
|
774
|
-
wm.c += change;
|
|
775
|
-
wp.z += shift;
|
|
776
|
-
wp.m += shift;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
// All other shifts, applied to the smaller subtrees between w- and w+, are
|
|
780
|
-
// performed by this function. To prepare the shifts, we have to adjust
|
|
781
|
-
// change(w+), shift(w+), and change(w-).
|
|
782
|
-
function executeShifts(v) {
|
|
783
|
-
var shift = 0,
|
|
784
|
-
change = 0,
|
|
785
|
-
children = v.children,
|
|
786
|
-
i = children.length,
|
|
787
|
-
w;
|
|
788
|
-
while (--i >= 0) {
|
|
789
|
-
w = children[i];
|
|
790
|
-
w.z += shift;
|
|
791
|
-
w.m += shift;
|
|
792
|
-
shift += w.s + (change += w.c);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
// If vi-’s ancestor is a sibling of v, returns vi-’s ancestor. Otherwise,
|
|
797
|
-
// returns the specified (default) ancestor.
|
|
798
|
-
function nextAncestor(vim, v, ancestor) {
|
|
799
|
-
return vim.a.parent === v.parent ? vim.a : ancestor;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
function TreeNode(node, i) {
|
|
803
|
-
this._ = node;
|
|
804
|
-
this.parent = null;
|
|
805
|
-
this.children = null;
|
|
806
|
-
this.A = null; // default ancestor
|
|
807
|
-
this.a = this; // ancestor
|
|
808
|
-
this.z = 0; // prelim
|
|
809
|
-
this.m = 0; // mod
|
|
810
|
-
this.c = 0; // change
|
|
811
|
-
this.s = 0; // shift
|
|
812
|
-
this.t = null; // thread
|
|
813
|
-
this.i = i; // number
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
TreeNode.prototype = Object.create(Node$1.prototype);
|
|
817
|
-
|
|
818
|
-
function treeRoot(root) {
|
|
819
|
-
var tree = new TreeNode(root, 0),
|
|
820
|
-
node,
|
|
821
|
-
nodes = [tree],
|
|
822
|
-
child,
|
|
823
|
-
children,
|
|
824
|
-
i,
|
|
825
|
-
n;
|
|
826
|
-
|
|
827
|
-
while (node = nodes.pop()) {
|
|
828
|
-
if (children = node._.children) {
|
|
829
|
-
node.children = new Array(n = children.length);
|
|
830
|
-
for (i = n - 1; i >= 0; --i) {
|
|
831
|
-
nodes.push(child = node.children[i] = new TreeNode(children[i], i));
|
|
832
|
-
child.parent = node;
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
(tree.parent = new TreeNode(null, 0)).children = [tree];
|
|
838
|
-
return tree;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
// Node-link tree diagram using the Reingold-Tilford "tidy" algorithm
|
|
842
|
-
function d3Tree() {
|
|
843
|
-
var separation = defaultSeparation,
|
|
844
|
-
dx = 1,
|
|
845
|
-
dy = 1,
|
|
846
|
-
nodeSize = null;
|
|
847
|
-
|
|
848
|
-
function tree(root) {
|
|
849
|
-
var t = treeRoot(root);
|
|
850
|
-
|
|
851
|
-
// Compute the layout using Buchheim et al.’s algorithm.
|
|
852
|
-
t.eachAfter(firstWalk), t.parent.m = -t.z;
|
|
853
|
-
t.eachBefore(secondWalk);
|
|
854
|
-
|
|
855
|
-
// If a fixed node size is specified, scale x and y.
|
|
856
|
-
if (nodeSize) root.eachBefore(sizeNode);
|
|
857
|
-
|
|
858
|
-
// If a fixed tree size is specified, scale x and y based on the extent.
|
|
859
|
-
// Compute the left-most, right-most, and depth-most nodes for extents.
|
|
860
|
-
else {
|
|
861
|
-
var left = root,
|
|
862
|
-
right = root,
|
|
863
|
-
bottom = root;
|
|
864
|
-
root.eachBefore(function(node) {
|
|
865
|
-
if (node.x < left.x) left = node;
|
|
866
|
-
if (node.x > right.x) right = node;
|
|
867
|
-
if (node.depth > bottom.depth) bottom = node;
|
|
868
|
-
});
|
|
869
|
-
var s = left === right ? 1 : separation(left, right) / 2,
|
|
870
|
-
tx = s - left.x,
|
|
871
|
-
kx = dx / (right.x + s + tx),
|
|
872
|
-
ky = dy / (bottom.depth || 1);
|
|
873
|
-
root.eachBefore(function(node) {
|
|
874
|
-
node.x = (node.x + tx) * kx;
|
|
875
|
-
node.y = node.depth * ky;
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
return root;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
// Computes a preliminary x-coordinate for v. Before that, FIRST WALK is
|
|
883
|
-
// applied recursively to the children of v, as well as the function
|
|
884
|
-
// APPORTION. After spacing out the children by calling EXECUTE SHIFTS, the
|
|
885
|
-
// node v is placed to the midpoint of its outermost children.
|
|
886
|
-
function firstWalk(v) {
|
|
887
|
-
var children = v.children,
|
|
888
|
-
siblings = v.parent.children,
|
|
889
|
-
w = v.i ? siblings[v.i - 1] : null;
|
|
890
|
-
if (children) {
|
|
891
|
-
executeShifts(v);
|
|
892
|
-
var midpoint = (children[0].z + children[children.length - 1].z) / 2;
|
|
893
|
-
if (w) {
|
|
894
|
-
v.z = w.z + separation(v._, w._);
|
|
895
|
-
v.m = v.z - midpoint;
|
|
896
|
-
} else {
|
|
897
|
-
v.z = midpoint;
|
|
898
|
-
}
|
|
899
|
-
} else if (w) {
|
|
900
|
-
v.z = w.z + separation(v._, w._);
|
|
901
|
-
}
|
|
902
|
-
v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
// Computes all real x-coordinates by summing up the modifiers recursively.
|
|
906
|
-
function secondWalk(v) {
|
|
907
|
-
v._.x = v.z + v.parent.m;
|
|
908
|
-
v.m += v.parent.m;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
// The core of the algorithm. Here, a new subtree is combined with the
|
|
912
|
-
// previous subtrees. Threads are used to traverse the inside and outside
|
|
913
|
-
// contours of the left and right subtree up to the highest common level. The
|
|
914
|
-
// vertices used for the traversals are vi+, vi-, vo-, and vo+, where the
|
|
915
|
-
// superscript o means outside and i means inside, the subscript - means left
|
|
916
|
-
// subtree and + means right subtree. For summing up the modifiers along the
|
|
917
|
-
// contour, we use respective variables si+, si-, so-, and so+. Whenever two
|
|
918
|
-
// nodes of the inside contours conflict, we compute the left one of the
|
|
919
|
-
// greatest uncommon ancestors using the function ANCESTOR and call MOVE
|
|
920
|
-
// SUBTREE to shift the subtree and prepare the shifts of smaller subtrees.
|
|
921
|
-
// Finally, we add a new thread (if necessary).
|
|
922
|
-
function apportion(v, w, ancestor) {
|
|
923
|
-
if (w) {
|
|
924
|
-
var vip = v,
|
|
925
|
-
vop = v,
|
|
926
|
-
vim = w,
|
|
927
|
-
vom = vip.parent.children[0],
|
|
928
|
-
sip = vip.m,
|
|
929
|
-
sop = vop.m,
|
|
930
|
-
sim = vim.m,
|
|
931
|
-
som = vom.m,
|
|
932
|
-
shift;
|
|
933
|
-
while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {
|
|
934
|
-
vom = nextLeft(vom);
|
|
935
|
-
vop = nextRight(vop);
|
|
936
|
-
vop.a = v;
|
|
937
|
-
shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
|
|
938
|
-
if (shift > 0) {
|
|
939
|
-
moveSubtree(nextAncestor(vim, v, ancestor), v, shift);
|
|
940
|
-
sip += shift;
|
|
941
|
-
sop += shift;
|
|
942
|
-
}
|
|
943
|
-
sim += vim.m;
|
|
944
|
-
sip += vip.m;
|
|
945
|
-
som += vom.m;
|
|
946
|
-
sop += vop.m;
|
|
947
|
-
}
|
|
948
|
-
if (vim && !nextRight(vop)) {
|
|
949
|
-
vop.t = vim;
|
|
950
|
-
vop.m += sim - sop;
|
|
951
|
-
}
|
|
952
|
-
if (vip && !nextLeft(vom)) {
|
|
953
|
-
vom.t = vip;
|
|
954
|
-
vom.m += sip - som;
|
|
955
|
-
ancestor = v;
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
return ancestor;
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
function sizeNode(node) {
|
|
962
|
-
node.x *= dx;
|
|
963
|
-
node.y = node.depth * dy;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
tree.separation = function(x) {
|
|
967
|
-
return arguments.length ? (separation = x, tree) : separation;
|
|
968
|
-
};
|
|
969
|
-
|
|
970
|
-
tree.size = function(x) {
|
|
971
|
-
return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]);
|
|
972
|
-
};
|
|
973
|
-
|
|
974
|
-
tree.nodeSize = function(x) {
|
|
975
|
-
return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null);
|
|
976
|
-
};
|
|
977
|
-
|
|
978
|
-
return tree;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
function d3treemapSlice(parent, x0, y0, x1, y1) {
|
|
982
|
-
var nodes = parent.children,
|
|
983
|
-
node,
|
|
984
|
-
i = -1,
|
|
985
|
-
n = nodes.length,
|
|
986
|
-
k = parent.value && (y1 - y0) / parent.value;
|
|
987
|
-
|
|
988
|
-
while (++i < n) {
|
|
989
|
-
node = nodes[i], node.x0 = x0, node.x1 = x1;
|
|
990
|
-
node.y0 = y0, node.y1 = y0 += node.value * k;
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
var phi = (1 + Math.sqrt(5)) / 2;
|
|
995
|
-
|
|
996
|
-
function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
|
|
997
|
-
var rows = [],
|
|
998
|
-
nodes = parent.children,
|
|
999
|
-
row,
|
|
1000
|
-
nodeValue,
|
|
1001
|
-
i0 = 0,
|
|
1002
|
-
i1 = 0,
|
|
1003
|
-
n = nodes.length,
|
|
1004
|
-
dx, dy,
|
|
1005
|
-
value = parent.value,
|
|
1006
|
-
sumValue,
|
|
1007
|
-
minValue,
|
|
1008
|
-
maxValue,
|
|
1009
|
-
newRatio,
|
|
1010
|
-
minRatio,
|
|
1011
|
-
alpha,
|
|
1012
|
-
beta;
|
|
1013
|
-
|
|
1014
|
-
while (i0 < n) {
|
|
1015
|
-
dx = x1 - x0, dy = y1 - y0;
|
|
1016
|
-
|
|
1017
|
-
// Find the next non-empty node.
|
|
1018
|
-
do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);
|
|
1019
|
-
minValue = maxValue = sumValue;
|
|
1020
|
-
alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
|
|
1021
|
-
beta = sumValue * sumValue * alpha;
|
|
1022
|
-
minRatio = Math.max(maxValue / beta, beta / minValue);
|
|
1023
|
-
|
|
1024
|
-
// Keep adding nodes while the aspect ratio maintains or improves.
|
|
1025
|
-
for (; i1 < n; ++i1) {
|
|
1026
|
-
sumValue += nodeValue = nodes[i1].value;
|
|
1027
|
-
if (nodeValue < minValue) minValue = nodeValue;
|
|
1028
|
-
if (nodeValue > maxValue) maxValue = nodeValue;
|
|
1029
|
-
beta = sumValue * sumValue * alpha;
|
|
1030
|
-
newRatio = Math.max(maxValue / beta, beta / minValue);
|
|
1031
|
-
if (newRatio > minRatio) { sumValue -= nodeValue; break; }
|
|
1032
|
-
minRatio = newRatio;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
// Position and record the row orientation.
|
|
1036
|
-
rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
|
|
1037
|
-
if (row.dice) d3treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
|
|
1038
|
-
else d3treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
|
|
1039
|
-
value -= sumValue, i0 = i1;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
return rows;
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
var d3treemapSquarify = (function custom(ratio) {
|
|
1046
|
-
|
|
1047
|
-
function squarify(parent, x0, y0, x1, y1) {
|
|
1048
|
-
squarifyRatio(ratio, parent, x0, y0, x1, y1);
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
squarify.ratio = function(x) {
|
|
1052
|
-
return custom((x = +x) > 1 ? x : 1);
|
|
1053
|
-
};
|
|
1054
|
-
|
|
1055
|
-
return squarify;
|
|
1056
|
-
})(phi);
|
|
1057
|
-
|
|
1058
|
-
function d3Treemap() {
|
|
1059
|
-
var tile = d3treemapSquarify,
|
|
1060
|
-
round = false,
|
|
1061
|
-
dx = 1,
|
|
1062
|
-
dy = 1,
|
|
1063
|
-
paddingStack = [0],
|
|
1064
|
-
paddingInner = constantZero,
|
|
1065
|
-
paddingTop = constantZero,
|
|
1066
|
-
paddingRight = constantZero,
|
|
1067
|
-
paddingBottom = constantZero,
|
|
1068
|
-
paddingLeft = constantZero;
|
|
1069
|
-
|
|
1070
|
-
function treemap(root) {
|
|
1071
|
-
root.x0 =
|
|
1072
|
-
root.y0 = 0;
|
|
1073
|
-
root.x1 = dx;
|
|
1074
|
-
root.y1 = dy;
|
|
1075
|
-
root.eachBefore(positionNode);
|
|
1076
|
-
paddingStack = [0];
|
|
1077
|
-
if (round) root.eachBefore(roundNode);
|
|
1078
|
-
return root;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
function positionNode(node) {
|
|
1082
|
-
var p = paddingStack[node.depth],
|
|
1083
|
-
x0 = node.x0 + p,
|
|
1084
|
-
y0 = node.y0 + p,
|
|
1085
|
-
x1 = node.x1 - p,
|
|
1086
|
-
y1 = node.y1 - p;
|
|
1087
|
-
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
1088
|
-
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
1089
|
-
node.x0 = x0;
|
|
1090
|
-
node.y0 = y0;
|
|
1091
|
-
node.x1 = x1;
|
|
1092
|
-
node.y1 = y1;
|
|
1093
|
-
if (node.children) {
|
|
1094
|
-
p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
|
|
1095
|
-
x0 += paddingLeft(node) - p;
|
|
1096
|
-
y0 += paddingTop(node) - p;
|
|
1097
|
-
x1 -= paddingRight(node) - p;
|
|
1098
|
-
y1 -= paddingBottom(node) - p;
|
|
1099
|
-
if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
|
|
1100
|
-
if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
|
|
1101
|
-
tile(node, x0, y0, x1, y1);
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
treemap.round = function(x) {
|
|
1106
|
-
return arguments.length ? (round = !!x, treemap) : round;
|
|
1107
|
-
};
|
|
1108
|
-
|
|
1109
|
-
treemap.size = function(x) {
|
|
1110
|
-
return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
treemap.tile = function(x) {
|
|
1114
|
-
return arguments.length ? (tile = required(x), treemap) : tile;
|
|
1115
|
-
};
|
|
1116
|
-
|
|
1117
|
-
treemap.padding = function(x) {
|
|
1118
|
-
return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
treemap.paddingInner = function(x) {
|
|
1122
|
-
return arguments.length ? (paddingInner = typeof x === "function" ? x : constant$1(+x), treemap) : paddingInner;
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
|
-
treemap.paddingOuter = function(x) {
|
|
1126
|
-
return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
|
|
1127
|
-
};
|
|
1128
|
-
|
|
1129
|
-
treemap.paddingTop = function(x) {
|
|
1130
|
-
return arguments.length ? (paddingTop = typeof x === "function" ? x : constant$1(+x), treemap) : paddingTop;
|
|
1131
|
-
};
|
|
1132
|
-
|
|
1133
|
-
treemap.paddingRight = function(x) {
|
|
1134
|
-
return arguments.length ? (paddingRight = typeof x === "function" ? x : constant$1(+x), treemap) : paddingRight;
|
|
1135
|
-
};
|
|
1136
|
-
|
|
1137
|
-
treemap.paddingBottom = function(x) {
|
|
1138
|
-
return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant$1(+x), treemap) : paddingBottom;
|
|
1139
|
-
};
|
|
1140
|
-
|
|
1141
|
-
treemap.paddingLeft = function(x) {
|
|
1142
|
-
return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant$1(+x), treemap) : paddingLeft;
|
|
1143
|
-
};
|
|
1144
|
-
|
|
1145
|
-
return treemap;
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
function d3treemapBinary(parent, x0, y0, x1, y1) {
|
|
1149
|
-
var nodes = parent.children,
|
|
1150
|
-
i, n = nodes.length,
|
|
1151
|
-
sum, sums = new Array(n + 1);
|
|
1152
|
-
|
|
1153
|
-
for (sums[0] = sum = i = 0; i < n; ++i) {
|
|
1154
|
-
sums[i + 1] = sum += nodes[i].value;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
partition(0, n, parent.value, x0, y0, x1, y1);
|
|
1158
|
-
|
|
1159
|
-
function partition(i, j, value, x0, y0, x1, y1) {
|
|
1160
|
-
if (i >= j - 1) {
|
|
1161
|
-
var node = nodes[i];
|
|
1162
|
-
node.x0 = x0, node.y0 = y0;
|
|
1163
|
-
node.x1 = x1, node.y1 = y1;
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
var valueOffset = sums[i],
|
|
1168
|
-
valueTarget = (value / 2) + valueOffset,
|
|
1169
|
-
k = i + 1,
|
|
1170
|
-
hi = j - 1;
|
|
1171
|
-
|
|
1172
|
-
while (k < hi) {
|
|
1173
|
-
var mid = k + hi >>> 1;
|
|
1174
|
-
if (sums[mid] < valueTarget) k = mid + 1;
|
|
1175
|
-
else hi = mid;
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
if ((valueTarget - sums[k - 1]) < (sums[k] - valueTarget) && i + 1 < k) --k;
|
|
1179
|
-
|
|
1180
|
-
var valueLeft = sums[k] - valueOffset,
|
|
1181
|
-
valueRight = value - valueLeft;
|
|
1182
|
-
|
|
1183
|
-
if ((x1 - x0) > (y1 - y0)) {
|
|
1184
|
-
var xk = (x0 * valueRight + x1 * valueLeft) / value;
|
|
1185
|
-
partition(i, k, valueLeft, x0, y0, xk, y1);
|
|
1186
|
-
partition(k, j, valueRight, xk, y0, x1, y1);
|
|
1187
|
-
} else {
|
|
1188
|
-
var yk = (y0 * valueRight + y1 * valueLeft) / value;
|
|
1189
|
-
partition(i, k, valueLeft, x0, y0, x1, yk);
|
|
1190
|
-
partition(k, j, valueRight, x0, yk, x1, y1);
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
function d3treemapSliceDice(parent, x0, y0, x1, y1) {
|
|
1196
|
-
(parent.depth & 1 ? d3treemapSlice : d3treemapDice)(parent, x0, y0, x1, y1);
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
var d3treemapResquarify = (function custom(ratio) {
|
|
1200
|
-
|
|
1201
|
-
function resquarify(parent, x0, y0, x1, y1) {
|
|
1202
|
-
if ((rows = parent._squarify) && (rows.ratio === ratio)) {
|
|
1203
|
-
var rows,
|
|
1204
|
-
row,
|
|
1205
|
-
nodes,
|
|
1206
|
-
i,
|
|
1207
|
-
j = -1,
|
|
1208
|
-
n,
|
|
1209
|
-
m = rows.length,
|
|
1210
|
-
value = parent.value;
|
|
1211
|
-
|
|
1212
|
-
while (++j < m) {
|
|
1213
|
-
row = rows[j], nodes = row.children;
|
|
1214
|
-
for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
|
|
1215
|
-
if (row.dice) d3treemapDice(row, x0, y0, x1, y0 += (y1 - y0) * row.value / value);
|
|
1216
|
-
else d3treemapSlice(row, x0, y0, x0 += (x1 - x0) * row.value / value, y1);
|
|
1217
|
-
value -= row.value;
|
|
1218
|
-
}
|
|
1219
|
-
} else {
|
|
1220
|
-
parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
|
|
1221
|
-
rows.ratio = ratio;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
resquarify.ratio = function(x) {
|
|
1226
|
-
return custom((x = +x) > 1 ? x : 1);
|
|
1227
|
-
};
|
|
1228
|
-
|
|
1229
|
-
return resquarify;
|
|
1230
|
-
})(phi);
|
|
1231
|
-
|
|
1232
|
-
function styleInject(css, ref) {
|
|
1233
|
-
if ( ref === void 0 ) ref = {};
|
|
1234
|
-
var insertAt = ref.insertAt;
|
|
1235
|
-
|
|
1236
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
1237
|
-
|
|
1238
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
1239
|
-
var style = document.createElement('style');
|
|
1240
|
-
style.type = 'text/css';
|
|
1241
|
-
|
|
1242
|
-
if (insertAt === 'top') {
|
|
1243
|
-
if (head.firstChild) {
|
|
1244
|
-
head.insertBefore(style, head.firstChild);
|
|
1245
|
-
} else {
|
|
1246
|
-
head.appendChild(style);
|
|
1247
|
-
}
|
|
1248
|
-
} else {
|
|
1249
|
-
head.appendChild(style);
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
if (style.styleSheet) {
|
|
1253
|
-
style.styleSheet.cssText = css;
|
|
1254
|
-
} else {
|
|
1255
|
-
style.appendChild(document.createTextNode(css));
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
var css_248z$4 = ".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}";
|
|
1260
|
-
styleInject(css_248z$4);
|
|
1261
|
-
|
|
1262
|
-
var CirclePacking = /** @class */ (function (_super) {
|
|
1263
|
-
__extends(CirclePacking, _super);
|
|
1264
|
-
function CirclePacking() {
|
|
1265
|
-
var _this = _super.call(this) || this;
|
|
1266
|
-
ITree.call(_this);
|
|
1267
|
-
return _this;
|
|
1268
|
-
}
|
|
1269
|
-
CirclePacking.prototype.enter = function (_domNode, element) {
|
|
1270
|
-
this.diameter = Math.min(this.width(), this.height());
|
|
1271
|
-
this.pack = d3Pack()
|
|
1272
|
-
.size([this.diameter - 4, this.diameter - 4])
|
|
1273
|
-
.padding(1.5);
|
|
1274
|
-
this.svg = element
|
|
1275
|
-
.append("g");
|
|
1276
|
-
};
|
|
1277
|
-
CirclePacking.prototype.update = function (_domNode, _element) {
|
|
1278
|
-
var context = this;
|
|
1279
|
-
this.diameter = Math.min(this.width(), this.height());
|
|
1280
|
-
this.pack
|
|
1281
|
-
.size([this.diameter - 4, this.diameter - 4])
|
|
1282
|
-
.padding(1.5);
|
|
1283
|
-
this._palette = this._palette.switch(this.paletteID());
|
|
1284
|
-
if (this.useClonedPalette()) {
|
|
1285
|
-
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
1286
|
-
}
|
|
1287
|
-
this.svg.selectAll("circle").remove();
|
|
1288
|
-
this.svg.selectAll("text").remove();
|
|
1289
|
-
var root = hierarchy(this.data())
|
|
1290
|
-
.sum(function (d) {
|
|
1291
|
-
return d && d.size ? d.size : 1;
|
|
1292
|
-
}).sort(function (a, b) {
|
|
1293
|
-
return a.value < b.value ? -1 : a.value > b.value ? 1 : 0;
|
|
1294
|
-
});
|
|
1295
|
-
this._focus = root;
|
|
1296
|
-
this.pack(root);
|
|
1297
|
-
this.circle = this.svg.selectAll("circle").data(root.descendants())
|
|
1298
|
-
.enter().append("circle")
|
|
1299
|
-
.attr("class", function (d) { return d.parent ? d.children ? "node" : "node leaf" : "node root"; })
|
|
1300
|
-
.style("fill", function (d) {
|
|
1301
|
-
d.color = context.paletteDepthLevel_exists() && d.depth > context.paletteDepthLevel() ? rgb(d.parent.color)[context.paletteDepthVariant()](1) : context._palette(d.data.label);
|
|
1302
|
-
return d.color;
|
|
1303
|
-
})
|
|
1304
|
-
.on("click", function (d) { context.click(d.data, null, null); })
|
|
1305
|
-
.on("dblclick", function (d) {
|
|
1306
|
-
if (this._focus !== d) {
|
|
1307
|
-
context.zoom(d);
|
|
1308
|
-
}
|
|
1309
|
-
d3Event().stopPropagation();
|
|
1310
|
-
});
|
|
1311
|
-
this.circle.append("title").text(function (d) { return d.data.label; });
|
|
1312
|
-
this.svg.selectAll("text").data(root.descendants())
|
|
1313
|
-
.enter().append("text")
|
|
1314
|
-
.attr("class", "label")
|
|
1315
|
-
.style("fill-opacity", function (d) { return d.parent === root ? 1 : 0; })
|
|
1316
|
-
.style("display", function (d) { return d.parent === root ? null : "none"; })
|
|
1317
|
-
.text(function (d) {
|
|
1318
|
-
return d.data.label + (context.showSize() && typeof d.data.size !== "undefined" ? " " + d.data.size : "");
|
|
1319
|
-
});
|
|
1320
|
-
this._node = this.svg.selectAll("circle,text");
|
|
1321
|
-
this.zoomTo([root.x, root.y, root.r * 2]);
|
|
1322
|
-
};
|
|
1323
|
-
CirclePacking.prototype.zoom = function (newFocus) {
|
|
1324
|
-
this._focus = newFocus;
|
|
1325
|
-
var context = this;
|
|
1326
|
-
var transition = this.svg.transition()
|
|
1327
|
-
.duration(d3Event().altKey ? 7500 : 750)
|
|
1328
|
-
.tween("zoom", function () {
|
|
1329
|
-
var i = interpolateZoom(context.view, [context._focus.x, context._focus.y, context._focus.r * 2]);
|
|
1330
|
-
return function (t) { context.zoomTo(i(t)); };
|
|
1331
|
-
});
|
|
1332
|
-
function showText(d) {
|
|
1333
|
-
return (d === context._focus && !d.children) || d.parent === context._focus;
|
|
1334
|
-
}
|
|
1335
|
-
transition.selectAll("text")
|
|
1336
|
-
.filter(function (d) { return showText(d) || this.style.display === "inline"; })
|
|
1337
|
-
.style("fill-opacity", function (d) { return showText(d) ? 1 : 0; })
|
|
1338
|
-
.on("start", function (d) { if (showText(d))
|
|
1339
|
-
this.style.display = "inline"; })
|
|
1340
|
-
.on("end", function (d) { if (!showText(d))
|
|
1341
|
-
this.style.display = "none"; });
|
|
1342
|
-
};
|
|
1343
|
-
CirclePacking.prototype.zoomTo = function (v) {
|
|
1344
|
-
var k = this.diameter / v[2];
|
|
1345
|
-
this.view = v;
|
|
1346
|
-
this._node.attr("transform", function (d) { return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")"; });
|
|
1347
|
-
this.circle.attr("r", function (d) { return d.r * k; });
|
|
1348
|
-
};
|
|
1349
|
-
return CirclePacking;
|
|
1350
|
-
}(SVGWidget));
|
|
1351
|
-
CirclePacking.prototype._class += " tree_CirclePacking";
|
|
1352
|
-
CirclePacking.prototype.implements(ITree.prototype);
|
|
1353
|
-
CirclePacking.prototype.publish("showSize", true, "boolean", "Show size along with label");
|
|
1354
|
-
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 });
|
|
1355
|
-
CirclePacking.prototype.publish("paletteDepthVariant", "brighter", "set", "Determines paletteDepthLevel decendant color shade variant", ["brighter", "darker"], { disable: function (w) { return w.paletteDepthLevel_exists(); } });
|
|
1356
|
-
CirclePacking.prototype.publish("paletteID", "default", "set", "Color palette for this widget", CirclePacking.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
1357
|
-
CirclePacking.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
1358
|
-
|
|
1359
|
-
var css_248z$3 = ".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}";
|
|
1360
|
-
styleInject(css_248z$3);
|
|
1361
|
-
|
|
1362
|
-
var DendrogramColumn = /** @class */ (function (_super) {
|
|
1363
|
-
__extends(DendrogramColumn, _super);
|
|
1364
|
-
function DendrogramColumn() {
|
|
1365
|
-
return _super.call(this) || this;
|
|
1366
|
-
}
|
|
1367
|
-
DendrogramColumn.prototype.owner = function (_) {
|
|
1368
|
-
if (!arguments.length)
|
|
1369
|
-
return this._owner;
|
|
1370
|
-
this._owner = _;
|
|
1371
|
-
return this;
|
|
1372
|
-
};
|
|
1373
|
-
DendrogramColumn.prototype.valid = function () {
|
|
1374
|
-
return !!this.column();
|
|
1375
|
-
};
|
|
1376
|
-
return DendrogramColumn;
|
|
1377
|
-
}(PropertyExt));
|
|
1378
|
-
DendrogramColumn.prototype._class += " tree_Dendrogram.DendrogramColumn";
|
|
1379
|
-
DendrogramColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true });
|
|
1380
|
-
// ===
|
|
1381
|
-
var Dendrogram = /** @class */ (function (_super) {
|
|
1382
|
-
__extends(Dendrogram, _super);
|
|
1383
|
-
function Dendrogram() {
|
|
1384
|
-
var _this = _super.call(this) || this;
|
|
1385
|
-
ITree.call(_this);
|
|
1386
|
-
Utility.SimpleSelectionMixin.call(_this);
|
|
1387
|
-
_this._drawStartPos = "origin";
|
|
1388
|
-
_this._d3LayoutCluster = d3Cluster();
|
|
1389
|
-
_this._d3LayoutTree = d3Tree();
|
|
1390
|
-
return _this;
|
|
1391
|
-
}
|
|
1392
|
-
Dendrogram.prototype.dendrogramData = function () {
|
|
1393
|
-
if (this.data().length === 0)
|
|
1394
|
-
return [];
|
|
1395
|
-
if (!this.mappings().filter(function (mapping) { return mapping.valid(); }).length) {
|
|
1396
|
-
return this.data();
|
|
1397
|
-
}
|
|
1398
|
-
var view = this._db.rollupView(this.mappings().map(function (mapping) { return mapping.column(); }));
|
|
1399
|
-
var retVal = {
|
|
1400
|
-
key: "root",
|
|
1401
|
-
values: view.entries()
|
|
1402
|
-
};
|
|
1403
|
-
return formatData(retVal);
|
|
1404
|
-
function formatData(node) {
|
|
1405
|
-
return {
|
|
1406
|
-
label: node.key,
|
|
1407
|
-
children: node.values.filter(function (value) { return !(value instanceof Array); }).map(function (value) { return formatData(value); }),
|
|
1408
|
-
origRows: node.values
|
|
1409
|
-
};
|
|
1410
|
-
}
|
|
1411
|
-
};
|
|
1412
|
-
Dendrogram.prototype.enter = function (domNode, element) {
|
|
1413
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
1414
|
-
this._renderElement
|
|
1415
|
-
.attr("opacity", 0)
|
|
1416
|
-
.transition().duration(500)
|
|
1417
|
-
.attr("opacity", 1);
|
|
1418
|
-
this._selection.widgetElement(this._renderElement);
|
|
1419
|
-
};
|
|
1420
|
-
Dendrogram.prototype.update = function (domNode, element) {
|
|
1421
|
-
_super.prototype.update.call(this, domNode, element);
|
|
1422
|
-
var context = this;
|
|
1423
|
-
var isVertical = this.orientation() === "vertical";
|
|
1424
|
-
this._palette = this._palette.switch(this.paletteID());
|
|
1425
|
-
if (this.useClonedPalette()) {
|
|
1426
|
-
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
1427
|
-
}
|
|
1428
|
-
this._d3Layout = this.dendrogram() ? this._d3LayoutCluster : this._d3LayoutTree;
|
|
1429
|
-
if (this.radial()) {
|
|
1430
|
-
this._d3Layout
|
|
1431
|
-
.size([360, this.separation() * 2]);
|
|
1432
|
-
this._d3Layout.separation(function separation(a, b) {
|
|
1433
|
-
return (a.parent === b.parent ? 1 : 2) / a.depth;
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
else {
|
|
1437
|
-
this._d3Layout.nodeSize([14, this.separation()]);
|
|
1438
|
-
this._d3Layout.separation(function separation(a, b) {
|
|
1439
|
-
return a.parent === b.parent ? 1 : 2;
|
|
1440
|
-
});
|
|
1441
|
-
}
|
|
1442
|
-
var data = this.dendrogramData();
|
|
1443
|
-
var root = hierarchy(data);
|
|
1444
|
-
this._d3Layout(root);
|
|
1445
|
-
var dataNodes = root.descendants();
|
|
1446
|
-
var links = root.descendants().slice(1);
|
|
1447
|
-
// Lines ---
|
|
1448
|
-
function linkVertical(d) {
|
|
1449
|
-
return "M" + d.parent.x + "," + d.parent.y
|
|
1450
|
-
+ "C" + d.parent.x + "," + (d.parent.y + d.y) / 2
|
|
1451
|
-
+ " " + d.x + "," + (d.parent.y + d.y) / 2
|
|
1452
|
-
+ " " + d.x + "," + d.y;
|
|
1453
|
-
}
|
|
1454
|
-
function linkHorizontal(d) {
|
|
1455
|
-
return "M" + d.y + "," + d.x
|
|
1456
|
-
+ "C" + (d.y + d.parent.y) / 2 + "," + d.x
|
|
1457
|
-
+ " " + (d.y + d.parent.y) / 2 + "," + d.parent.x
|
|
1458
|
-
+ " " + d.parent.y + "," + d.parent.x;
|
|
1459
|
-
}
|
|
1460
|
-
function diagonal(d) {
|
|
1461
|
-
return isVertical ? linkVertical(d) : linkHorizontal(d);
|
|
1462
|
-
}
|
|
1463
|
-
function project(x, y) {
|
|
1464
|
-
var angle = (x - 90) / 180 * Math.PI;
|
|
1465
|
-
var radius = y;
|
|
1466
|
-
return [radius * Math.cos(angle), radius * Math.sin(angle)];
|
|
1467
|
-
}
|
|
1468
|
-
function radialDiagonal(d) {
|
|
1469
|
-
return "M" + project(d.x, d.y)
|
|
1470
|
-
+ "C" + project(d.x, (d.y + d.parent.y) / 2)
|
|
1471
|
-
+ " " + project(d.parent.x, (d.y + d.parent.y) / 2)
|
|
1472
|
-
+ " " + project(d.parent.x, d.parent.y);
|
|
1473
|
-
}
|
|
1474
|
-
var transitionDuration = this._renderCount ? 500 : 0;
|
|
1475
|
-
var lines = this._renderElement.selectAll(".link").data(links);
|
|
1476
|
-
lines.enter().append("path")
|
|
1477
|
-
.attr("class", "link")
|
|
1478
|
-
.attr("d", this.radial() ? radialDiagonal : diagonal);
|
|
1479
|
-
lines.transition().duration(transitionDuration)
|
|
1480
|
-
.attr("d", this.radial() ? radialDiagonal : diagonal);
|
|
1481
|
-
lines.exit().remove();
|
|
1482
|
-
// Nodes ---
|
|
1483
|
-
var textOffsetX = this.circleRadius() + 2;
|
|
1484
|
-
function nodeTransform(d) {
|
|
1485
|
-
if (context.radial()) {
|
|
1486
|
-
return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")";
|
|
1487
|
-
}
|
|
1488
|
-
return context.orientation() === "horizontal" ? "translate(" + d.y + "," + d.x + ")" : "translate(" + d.x + "," + d.y + ")";
|
|
1489
|
-
}
|
|
1490
|
-
var nodes = this._renderElement.selectAll(".node").data(dataNodes);
|
|
1491
|
-
nodes.transition().duration(transitionDuration)
|
|
1492
|
-
.attr("transform", nodeTransform);
|
|
1493
|
-
var enterNodes = nodes.enter().append("g")
|
|
1494
|
-
.attr("class", "node")
|
|
1495
|
-
.attr("transform", nodeTransform)
|
|
1496
|
-
.call(this._selection.enter.bind(this._selection))
|
|
1497
|
-
.on("click", function (d) {
|
|
1498
|
-
var tmp = d;
|
|
1499
|
-
while (tmp.children) {
|
|
1500
|
-
tmp = tmp.children[0];
|
|
1501
|
-
}
|
|
1502
|
-
if (d.depth > 0) {
|
|
1503
|
-
if (tmp.origRows) {
|
|
1504
|
-
context.click(context.rowToObj(tmp.origRows[0]), context.mappings()[d.depth - 1].column(), true);
|
|
1505
|
-
}
|
|
1506
|
-
else {
|
|
1507
|
-
context.click(tmp.data, context.mappings()[d.depth - 1].column(), true);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
})
|
|
1511
|
-
.on("dblclick", function (d) {
|
|
1512
|
-
var tmp = d;
|
|
1513
|
-
while (tmp.children) {
|
|
1514
|
-
tmp = tmp.children[0];
|
|
1515
|
-
}
|
|
1516
|
-
if (d.depth > 0) {
|
|
1517
|
-
if (tmp.origRows) {
|
|
1518
|
-
context.dblclick(context.rowToObj(tmp.origRows[0]), context.mappings()[d.depth - 1].column(), true);
|
|
1519
|
-
}
|
|
1520
|
-
else {
|
|
1521
|
-
context.dblclick(tmp.data, context.mappings()[d.depth - 1].column(), true);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
})
|
|
1525
|
-
.each(function () {
|
|
1526
|
-
var e = select(this);
|
|
1527
|
-
e.append("circle");
|
|
1528
|
-
e.append("text");
|
|
1529
|
-
});
|
|
1530
|
-
enterNodes.merge(nodes).select("circle")
|
|
1531
|
-
.attr("r", this.circleRadius())
|
|
1532
|
-
.style("fill", function (d) { return context._palette(d.data.label); })
|
|
1533
|
-
.append("title")
|
|
1534
|
-
.text(function (d) { return d.data.label; });
|
|
1535
|
-
enterNodes.merge(nodes).select("text")
|
|
1536
|
-
.attr("dx", function (d) {
|
|
1537
|
-
if (context.radial()) {
|
|
1538
|
-
if (d.children) {
|
|
1539
|
-
return d.x < 180 ? -textOffsetX : textOffsetX;
|
|
1540
|
-
}
|
|
1541
|
-
else {
|
|
1542
|
-
return d.x < 180 ? textOffsetX : -textOffsetX;
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
else if (isVertical) {
|
|
1546
|
-
return d.children ? textOffsetX : -textOffsetX;
|
|
1547
|
-
}
|
|
1548
|
-
return d.children ? -textOffsetX : textOffsetX;
|
|
1549
|
-
})
|
|
1550
|
-
.attr("dy", "0.25em")
|
|
1551
|
-
.style("text-anchor", function (d) {
|
|
1552
|
-
if (context.radial()) {
|
|
1553
|
-
if (d.children) {
|
|
1554
|
-
return d.x < 180 ? "end" : "start";
|
|
1555
|
-
}
|
|
1556
|
-
else {
|
|
1557
|
-
return d.x < 180 ? "start" : "end";
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
else if (isVertical) {
|
|
1561
|
-
return d.children ? "start" : "end";
|
|
1562
|
-
}
|
|
1563
|
-
return d.children ? "end" : "start";
|
|
1564
|
-
})
|
|
1565
|
-
.attr("transform", function (d) {
|
|
1566
|
-
if (context.radial()) {
|
|
1567
|
-
return d.x < 180 ? null : "rotate(180)";
|
|
1568
|
-
}
|
|
1569
|
-
else if (isVertical) {
|
|
1570
|
-
return "rotate(-66)";
|
|
1571
|
-
}
|
|
1572
|
-
return null;
|
|
1573
|
-
})
|
|
1574
|
-
.text(function (d) { return d.data.label; });
|
|
1575
|
-
nodes.exit().remove();
|
|
1576
|
-
if (!this._renderCount) {
|
|
1577
|
-
context.zoomToFit();
|
|
1578
|
-
}
|
|
1579
|
-
};
|
|
1580
|
-
return Dendrogram;
|
|
1581
|
-
}(SVGZoomWidget));
|
|
1582
|
-
Dendrogram.prototype._class += " tree_Dendrogram";
|
|
1583
|
-
Dendrogram.prototype.implements(ITree.prototype);
|
|
1584
|
-
Dendrogram.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
1585
|
-
Dendrogram.prototype.Column = DendrogramColumn;
|
|
1586
|
-
Dendrogram.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Dendrogram.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
1587
|
-
Dendrogram.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
1588
|
-
Dendrogram.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: DendrogramColumn });
|
|
1589
|
-
Dendrogram.prototype.publish("circleRadius", 4.5, "number", "Text offset from circle");
|
|
1590
|
-
Dendrogram.prototype.publish("separation", 240, "number", "Leaf Separation");
|
|
1591
|
-
Dendrogram.prototype.publish("dendrogram", true, "boolean", "Dendrogram");
|
|
1592
|
-
Dendrogram.prototype.publish("radial", false, "boolean", "Radial");
|
|
1593
|
-
Dendrogram.prototype.publish("orientation", "horizontal", "set", "Orientation", ["horizontal", "vertical"], { tags: ["Private"], disable: function (w) { return w.radial(); } });
|
|
1594
|
-
|
|
1595
|
-
var DirectoryTree = /** @class */ (function (_super) {
|
|
1596
|
-
__extends(DirectoryTree, _super);
|
|
1597
|
-
function DirectoryTree() {
|
|
1598
|
-
return _super.call(this) || this;
|
|
1599
|
-
}
|
|
1600
|
-
DirectoryTree.prototype.flattenData = function (json) {
|
|
1601
|
-
var context = this;
|
|
1602
|
-
var root = hierarchy(json);
|
|
1603
|
-
var ret = [];
|
|
1604
|
-
if (!this.omitRoot()) {
|
|
1605
|
-
visitNode(root);
|
|
1606
|
-
}
|
|
1607
|
-
else if (root.children) {
|
|
1608
|
-
root.children.forEach(visitNode);
|
|
1609
|
-
}
|
|
1610
|
-
return ret;
|
|
1611
|
-
function visitNode(node) {
|
|
1612
|
-
var weightValue = node.data.markers && node.data.markers.length ? node.data.markers.length : "";
|
|
1613
|
-
ret.push({
|
|
1614
|
-
label: node.data.label,
|
|
1615
|
-
depth: node.depth - (context.omitRoot() ? 1 : 0),
|
|
1616
|
-
content: node.data.content,
|
|
1617
|
-
isFolder: !!node.data.children,
|
|
1618
|
-
iconClass: node.data.iconClass,
|
|
1619
|
-
color: node.data.color,
|
|
1620
|
-
bold: node.data.bold,
|
|
1621
|
-
weightValue: weightValue,
|
|
1622
|
-
markers: node.data.markers,
|
|
1623
|
-
selected: node.data.selected
|
|
1624
|
-
});
|
|
1625
|
-
if (node.children) {
|
|
1626
|
-
node.children.forEach(visitNode);
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
};
|
|
1630
|
-
DirectoryTree.prototype.iconClass = function (d) {
|
|
1631
|
-
if (d.label === "error") {
|
|
1632
|
-
return "fa fa-exclamation";
|
|
1633
|
-
}
|
|
1634
|
-
if (d.isFolder) {
|
|
1635
|
-
return this.folderIconOpen();
|
|
1636
|
-
}
|
|
1637
|
-
return this.textFileIcon();
|
|
1638
|
-
};
|
|
1639
|
-
DirectoryTree.prototype.calcRequiredWidth = function () {
|
|
1640
|
-
var _this = this;
|
|
1641
|
-
var flatData = this.flattenData(this.data());
|
|
1642
|
-
var widest = 0;
|
|
1643
|
-
var padding = this.rowItemPadding();
|
|
1644
|
-
var iconWidth = this.iconSize() + (padding * 2);
|
|
1645
|
-
var scrollbarWidth = Platform.getScrollbarWidth();
|
|
1646
|
-
flatData.forEach(function (row) {
|
|
1647
|
-
var offsetWidth = (row.depth * iconWidth) + (padding * 2);
|
|
1648
|
-
var textWidth = Utility.textSize(row.label, _this.fontFamily(), _this.fontSize(), !!row.bold).width + (padding * 2);
|
|
1649
|
-
var totalWidth = textWidth + iconWidth + offsetWidth + scrollbarWidth;
|
|
1650
|
-
if (widest < totalWidth) {
|
|
1651
|
-
widest = totalWidth;
|
|
1652
|
-
}
|
|
1653
|
-
});
|
|
1654
|
-
return widest;
|
|
1655
|
-
};
|
|
1656
|
-
DirectoryTree.prototype.rowClick = function (str, markers) { };
|
|
1657
|
-
DirectoryTree.prototype.enter = function (domNode, element) {
|
|
1658
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
1659
|
-
element
|
|
1660
|
-
.style("width", "100%")
|
|
1661
|
-
.style("height", "100%");
|
|
1662
|
-
};
|
|
1663
|
-
DirectoryTree.prototype.update = function (domNode, element) {
|
|
1664
|
-
var _this = this;
|
|
1665
|
-
_super.prototype.update.call(this, domNode, element);
|
|
1666
|
-
this._palette = this._palette.switch(this.paletteID());
|
|
1667
|
-
element
|
|
1668
|
-
.style("overflow-y", this.verticalScroll() ? "scroll" : null);
|
|
1669
|
-
var flatData = this.flattenData(this.data());
|
|
1670
|
-
var maxWeightValue = max$1(flatData, function (n) { return Number(n.weightValue); });
|
|
1671
|
-
flatData.forEach(function (d) {
|
|
1672
|
-
if (!d.weightValue) {
|
|
1673
|
-
d.weightColor = "transparent";
|
|
1674
|
-
}
|
|
1675
|
-
else {
|
|
1676
|
-
d.weightColor = _this._palette(d.weightValue, 1, maxWeightValue);
|
|
1677
|
-
}
|
|
1678
|
-
});
|
|
1679
|
-
var context = this;
|
|
1680
|
-
var padding = this.rowItemPadding();
|
|
1681
|
-
var iconWidth = this.iconSize() + padding;
|
|
1682
|
-
var lineHeight = Math.max(context.iconSize(), context.fontSize());
|
|
1683
|
-
var rowSelection = element.selectAll(".directory-row").data(flatData);
|
|
1684
|
-
var fontFamily = this.fontFamily();
|
|
1685
|
-
var fontSize = this.fontSize();
|
|
1686
|
-
var maxWeightWidth = max$1(flatData, function (d) { return _this.textSize(d.weightValue, fontFamily, fontSize).width; });
|
|
1687
|
-
var rowItemPadding = "".concat(padding, "px ").concat(padding, "px ").concat(padding / 2, "px ").concat(padding, "px");
|
|
1688
|
-
var rowEnter = rowSelection.enter().append("div")
|
|
1689
|
-
.attr("class", function (d) { return "directory-row directory-row-depth-".concat(d.depth); })
|
|
1690
|
-
.style("display", "flex")
|
|
1691
|
-
.style("cursor", "pointer")
|
|
1692
|
-
.each(function (d) {
|
|
1693
|
-
var rowDiv = select(this);
|
|
1694
|
-
var fontColor = d.color ? d.color : context.fontColor();
|
|
1695
|
-
var weightColor = d.weightColor ? d.weightColor : "transparent";
|
|
1696
|
-
var weightFontColor = Palette.textColor(weightColor);
|
|
1697
|
-
var weightDiv = rowDiv.append("div")
|
|
1698
|
-
.attr("class", "row-weight")
|
|
1699
|
-
.style("padding", rowItemPadding)
|
|
1700
|
-
.style("color", weightFontColor)
|
|
1701
|
-
.style("box-shadow", "inset 0 0 100px ".concat(weightColor))
|
|
1702
|
-
.style("font-weight", d.bold ? "bold" : "normal")
|
|
1703
|
-
.style("font-family", fontFamily)
|
|
1704
|
-
.style("font-size", fontSize + "px")
|
|
1705
|
-
.text(d.weightValue)
|
|
1706
|
-
.attr("title", d.weightValue)
|
|
1707
|
-
.style("overflow", "hidden")
|
|
1708
|
-
.style("width", (maxWeightWidth + (padding * 2)) + "px")
|
|
1709
|
-
.style("text-overflow", "ellipsis")
|
|
1710
|
-
.style("text-align", "right")
|
|
1711
|
-
.style("line-height", lineHeight + "px");
|
|
1712
|
-
rowDiv.append("div")
|
|
1713
|
-
.attr("class", "row-depth")
|
|
1714
|
-
.style("width", (context.depthSize() * d.depth) + "px")
|
|
1715
|
-
.style("opacity", 1)
|
|
1716
|
-
.style("line-height", lineHeight + "px");
|
|
1717
|
-
var iconDiv = rowDiv.append("div")
|
|
1718
|
-
.attr("class", "row-icon " + (d.iconClass ? d.iconClass : context.iconClass(d)))
|
|
1719
|
-
.style("width", iconWidth + "px")
|
|
1720
|
-
.style("height", lineHeight + "px")
|
|
1721
|
-
.style("color", fontColor)
|
|
1722
|
-
.style("background-color", d.selected ? context.selectionBackgroundColor() : "transparent")
|
|
1723
|
-
.style("font-size", context.iconSize() + "px")
|
|
1724
|
-
.style("padding", rowItemPadding)
|
|
1725
|
-
.style("line-height", lineHeight + "px");
|
|
1726
|
-
var labelDiv = rowDiv.append("div")
|
|
1727
|
-
.attr("class", "row-label")
|
|
1728
|
-
.style("padding", rowItemPadding)
|
|
1729
|
-
.style("color", fontColor)
|
|
1730
|
-
.style("background-color", d.selected ? context.selectionBackgroundColor() : "transparent")
|
|
1731
|
-
.style("font-weight", d.bold ? "bold" : "normal")
|
|
1732
|
-
.style("font-family", context.fontFamily())
|
|
1733
|
-
.style("font-size", context.fontSize() + "px")
|
|
1734
|
-
.text(d.label)
|
|
1735
|
-
.attr("title", d.label)
|
|
1736
|
-
.style("flex", 1)
|
|
1737
|
-
.style("overflow", "hidden")
|
|
1738
|
-
.style("text-overflow", "ellipsis")
|
|
1739
|
-
.style("line-height", lineHeight + "px");
|
|
1740
|
-
rowDiv
|
|
1741
|
-
.on("mouseenter", function () {
|
|
1742
|
-
labelDiv.style("font-weight", "bold");
|
|
1743
|
-
})
|
|
1744
|
-
.on("mouseleave", function () {
|
|
1745
|
-
labelDiv.style("font-weight", d.bold ? "bold" : "normal");
|
|
1746
|
-
});
|
|
1747
|
-
weightDiv
|
|
1748
|
-
.on("mouseenter", function () {
|
|
1749
|
-
context.weight_mouseenter(d);
|
|
1750
|
-
})
|
|
1751
|
-
.on("mouseleave", function () {
|
|
1752
|
-
context.weight_mouseleave(d);
|
|
1753
|
-
});
|
|
1754
|
-
if (d.isFolder) {
|
|
1755
|
-
rowDiv.on("click", function (d) {
|
|
1756
|
-
var next = this.nextSibling;
|
|
1757
|
-
var wasClosed = rowDiv.classed("folder-closed");
|
|
1758
|
-
if (wasClosed) {
|
|
1759
|
-
rowDiv.classed("folder-closed", false);
|
|
1760
|
-
rowDiv.classed("folder-open", true);
|
|
1761
|
-
iconDiv.attr("class", "row-icon " + context.folderIconOpen());
|
|
1762
|
-
}
|
|
1763
|
-
else {
|
|
1764
|
-
rowDiv.classed("folder-closed", true);
|
|
1765
|
-
rowDiv.classed("folder-open", false);
|
|
1766
|
-
iconDiv.attr("class", "row-icon " + context.folderIconClosed());
|
|
1767
|
-
}
|
|
1768
|
-
while (next !== null) {
|
|
1769
|
-
var nextDepth = select(next).datum().depth;
|
|
1770
|
-
if (nextDepth > d.depth) {
|
|
1771
|
-
next.style.display = wasClosed ? "flex" : "none";
|
|
1772
|
-
next = next.nextSibling;
|
|
1773
|
-
}
|
|
1774
|
-
else {
|
|
1775
|
-
next = null;
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
});
|
|
1779
|
-
}
|
|
1780
|
-
else {
|
|
1781
|
-
rowDiv.on("click", function () {
|
|
1782
|
-
element.selectAll(".row-label").style("background-color", "transparent");
|
|
1783
|
-
element.selectAll(".row-icon").style("background-color", "transparent");
|
|
1784
|
-
iconDiv.style("background-color", context.selectionBackgroundColor());
|
|
1785
|
-
labelDiv.style("background-color", context.selectionBackgroundColor());
|
|
1786
|
-
var ext = d.label.split(".").pop().toLowerCase();
|
|
1787
|
-
context.rowClick(ext === "json" ? JSON.stringify(JSON.parse(d.content), null, 4) : d.content, d.markers);
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
});
|
|
1791
|
-
rowEnter
|
|
1792
|
-
.merge(rowSelection)
|
|
1793
|
-
.style("background-color", context.backgroundColor());
|
|
1794
|
-
rowSelection.exit().remove();
|
|
1795
|
-
};
|
|
1796
|
-
DirectoryTree.prototype.weight_mouseenter = function (d) {
|
|
1797
|
-
};
|
|
1798
|
-
DirectoryTree.prototype.weight_mouseleave = function (d) {
|
|
1799
|
-
};
|
|
1800
|
-
return DirectoryTree;
|
|
1801
|
-
}(HTMLWidget));
|
|
1802
|
-
DirectoryTree.prototype._class += " tree_DirectoryTree";
|
|
1803
|
-
DirectoryTree.prototype._palette = Palette.rainbow("Blues");
|
|
1804
|
-
DirectoryTree.prototype.publish("depthSize", 14, "number", "Width of indentation per file or folder depth (pixels)");
|
|
1805
|
-
DirectoryTree.prototype.publish("paletteID", "Blues", "set", "Color palette for the weight backgrounds", DirectoryTree.prototype._palette.switch(), { tags: ["Basic"] });
|
|
1806
|
-
DirectoryTree.prototype.publish("omitRoot", false, "boolean", "If true, root node will not display");
|
|
1807
|
-
DirectoryTree.prototype.publish("rowItemPadding", 2, "number", "Top, bottom, left and right row item padding");
|
|
1808
|
-
DirectoryTree.prototype.publish("selectionBackgroundColor", "#CCC", "html-color", "Background color of selected directory rows");
|
|
1809
|
-
DirectoryTree.prototype.publish("backgroundColor", "#FFF", "html-color", "Directory item background color");
|
|
1810
|
-
DirectoryTree.prototype.publish("fontColor", "#000", "html-color", "Directory item font color");
|
|
1811
|
-
DirectoryTree.prototype.publish("fontFamily", "Arial", "string", "Directory item font family");
|
|
1812
|
-
DirectoryTree.prototype.publish("fontSize", 12, "number", "Directory item font size (pixels)");
|
|
1813
|
-
DirectoryTree.prototype.publish("iconSize", 12, "number", "Directory folder and file icon size (pixels)");
|
|
1814
|
-
DirectoryTree.prototype.publish("folderIconOpen", "fa fa-folder-open", "string", "Open folder icon class");
|
|
1815
|
-
DirectoryTree.prototype.publish("folderIconClosed", "fa fa-folder", "string", "Closed folder icon class");
|
|
1816
|
-
DirectoryTree.prototype.publish("textFileIcon", "fa fa-file-text-o", "string", "Text file icon class");
|
|
1817
|
-
DirectoryTree.prototype.publish("verticalScroll", true, "boolean", "If true, vertical scroll bar will be shown");
|
|
1818
|
-
|
|
1819
|
-
var css_248z$2 = ".tree_Indented .node rect{fill:#fff;stroke:#3182bd;stroke-width:1px;cursor:pointer}.tree_Indented .node text{font:10px sans-serif;pointer-events:none}.tree_Indented path.link{fill:none;stroke:#9ecae1;stroke-width:1.5px}";
|
|
1820
|
-
styleInject(css_248z$2);
|
|
1821
|
-
|
|
1822
|
-
var IndentedColumn = /** @class */ (function (_super) {
|
|
1823
|
-
__extends(IndentedColumn, _super);
|
|
1824
|
-
function IndentedColumn() {
|
|
1825
|
-
return _super.call(this) || this;
|
|
1826
|
-
}
|
|
1827
|
-
IndentedColumn.prototype.owner = function (_) {
|
|
1828
|
-
if (!arguments.length)
|
|
1829
|
-
return this._owner;
|
|
1830
|
-
this._owner = _;
|
|
1831
|
-
return this;
|
|
1832
|
-
};
|
|
1833
|
-
IndentedColumn.prototype.valid = function () {
|
|
1834
|
-
return !!this.column();
|
|
1835
|
-
};
|
|
1836
|
-
return IndentedColumn;
|
|
1837
|
-
}(PropertyExt));
|
|
1838
|
-
IndentedColumn.prototype._class += " tree_Dendrogram.IndentedColumn";
|
|
1839
|
-
IndentedColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true });
|
|
1840
|
-
// ===
|
|
1841
|
-
var Indented = /** @class */ (function (_super) {
|
|
1842
|
-
__extends(Indented, _super);
|
|
1843
|
-
function Indented() {
|
|
1844
|
-
var _this = _super.call(this) || this;
|
|
1845
|
-
_this._collapsed = {};
|
|
1846
|
-
ITree.call(_this);
|
|
1847
|
-
Utility.SimpleSelectionMixin.call(_this);
|
|
1848
|
-
_this._drawStartPos = "origin";
|
|
1849
|
-
_this._d3Tree = d3Tree();
|
|
1850
|
-
return _this;
|
|
1851
|
-
}
|
|
1852
|
-
Indented.prototype.xmlToData = function (xml, id) {
|
|
1853
|
-
if (id === void 0) { id = ""; }
|
|
1854
|
-
if (DOMParser) {
|
|
1855
|
-
var parser = new DOMParser();
|
|
1856
|
-
var doc = parser.parseFromString(xml, "text/xml");
|
|
1857
|
-
return xmlToJson(doc, id).children[0];
|
|
1858
|
-
}
|
|
1859
|
-
return [];
|
|
1860
|
-
};
|
|
1861
|
-
Indented.prototype.xml = function (_) {
|
|
1862
|
-
if (!arguments.length)
|
|
1863
|
-
return this._xml;
|
|
1864
|
-
this._xml = _;
|
|
1865
|
-
this.data(this.xmlToData(this._xml));
|
|
1866
|
-
return this;
|
|
1867
|
-
};
|
|
1868
|
-
Indented.prototype.IndentedData = function () {
|
|
1869
|
-
if (this.data().length === 0)
|
|
1870
|
-
return [];
|
|
1871
|
-
if (this.xmlColumn_exists()) {
|
|
1872
|
-
var cellIdx_1 = this.columns().indexOf(this.xmlColumn());
|
|
1873
|
-
var retVal = {
|
|
1874
|
-
label: this.xmlColumn(),
|
|
1875
|
-
children: this.data().map(function (row, idx) {
|
|
1876
|
-
return this.xmlToData(row[cellIdx_1], "[" + idx + "]");
|
|
1877
|
-
}, this)
|
|
1878
|
-
};
|
|
1879
|
-
return retVal.children.length === 1 ? retVal.children[0] : retVal;
|
|
1880
|
-
}
|
|
1881
|
-
else {
|
|
1882
|
-
if (!this.mappings().filter(function (mapping) { return mapping.valid(); }).length) {
|
|
1883
|
-
return this.data();
|
|
1884
|
-
}
|
|
1885
|
-
var view = this._db.rollupView(this.mappings().map(function (mapping) { return mapping.column(); }));
|
|
1886
|
-
var root = {
|
|
1887
|
-
key: "root",
|
|
1888
|
-
values: view.entries()
|
|
1889
|
-
};
|
|
1890
|
-
return formatData(root);
|
|
1891
|
-
}
|
|
1892
|
-
function formatData(node) {
|
|
1893
|
-
if (node.values instanceof Array) {
|
|
1894
|
-
var children = node.values.filter(function (value) {
|
|
1895
|
-
return !(value instanceof Array);
|
|
1896
|
-
}).map(function (value) {
|
|
1897
|
-
return formatData(value);
|
|
1898
|
-
});
|
|
1899
|
-
var retVal = {
|
|
1900
|
-
label: node.key
|
|
1901
|
-
};
|
|
1902
|
-
if (children.length) {
|
|
1903
|
-
retVal.children = children;
|
|
1904
|
-
}
|
|
1905
|
-
else {
|
|
1906
|
-
retVal.size = 22;
|
|
1907
|
-
}
|
|
1908
|
-
return retVal;
|
|
1909
|
-
}
|
|
1910
|
-
return {
|
|
1911
|
-
label: node.key,
|
|
1912
|
-
size: node.values.aggregate,
|
|
1913
|
-
origRows: node.values
|
|
1914
|
-
};
|
|
1915
|
-
}
|
|
1916
|
-
};
|
|
1917
|
-
Indented.prototype.enter = function (domNode, element) {
|
|
1918
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
1919
|
-
this._svgLinks = this._renderElement.append("g");
|
|
1920
|
-
this._svgNodes = this._renderElement.append("g");
|
|
1921
|
-
this._selection.widgetElement(this._svgNodes);
|
|
1922
|
-
};
|
|
1923
|
-
Indented.prototype.update = function (domNode, _element) {
|
|
1924
|
-
var _this = this;
|
|
1925
|
-
_super.prototype.update.call(this, domNode, _element);
|
|
1926
|
-
var context = this;
|
|
1927
|
-
this._d3Tree
|
|
1928
|
-
.nodeSize([0, this.barHeight()]);
|
|
1929
|
-
var dataChecksum = this._db.dataChecksum();
|
|
1930
|
-
if (this._prevDataChecksum !== dataChecksum) {
|
|
1931
|
-
this._treeData = this.IndentedData();
|
|
1932
|
-
this._prevDataChecksum = dataChecksum;
|
|
1933
|
-
}
|
|
1934
|
-
function getID(d) {
|
|
1935
|
-
return (d.parent ? getID(d.parent) + "." : "") + d.data.label;
|
|
1936
|
-
}
|
|
1937
|
-
var root = hierarchy(this.data())
|
|
1938
|
-
.sum(function (d) {
|
|
1939
|
-
return d.size || 50;
|
|
1940
|
-
}).each(function (d) {
|
|
1941
|
-
if (_this._collapsed[getID(d)]) {
|
|
1942
|
-
delete (d.children);
|
|
1943
|
-
}
|
|
1944
|
-
});
|
|
1945
|
-
var dataNodes = this._d3Tree(root).descendants();
|
|
1946
|
-
var links = this._d3Tree(root).descendants().slice(1);
|
|
1947
|
-
var nodeIdx = 0;
|
|
1948
|
-
root.eachBefore(function (n) {
|
|
1949
|
-
n.x = nodeIdx * context.barHeight();
|
|
1950
|
-
++nodeIdx;
|
|
1951
|
-
});
|
|
1952
|
-
var boxSize = this.barHeight() - 4;
|
|
1953
|
-
var transitionDuration = this._renderCount ? 500 : 0;
|
|
1954
|
-
// Lines ---
|
|
1955
|
-
var lines = this._svgLinks.selectAll(".link").data(links, function (d) { return getID(d); });
|
|
1956
|
-
lines.enter().append("path")
|
|
1957
|
-
.attr("class", "link")
|
|
1958
|
-
.attr("d", elbow);
|
|
1959
|
-
lines.transition().duration(transitionDuration)
|
|
1960
|
-
.attr("d", elbow);
|
|
1961
|
-
lines.exit().remove();
|
|
1962
|
-
function elbow(d) {
|
|
1963
|
-
return "M" + d.parent.y + "," + d.parent.x
|
|
1964
|
-
+ "V" + d.x + ", H" + d.y;
|
|
1965
|
-
}
|
|
1966
|
-
// Nodes ---
|
|
1967
|
-
var nodes = this._svgNodes.selectAll(".node").data(dataNodes, function (d) { return getID(d); });
|
|
1968
|
-
nodes.transition().duration(transitionDuration)
|
|
1969
|
-
.attr("transform", function (d) { return "translate(" + d.y + "," + d.x + ")"; });
|
|
1970
|
-
var enterNodes = nodes.enter().append("g")
|
|
1971
|
-
.attr("class", "node")
|
|
1972
|
-
.attr("transform", function (d) { return "translate(" + d.y + "," + d.x + ")"; })
|
|
1973
|
-
.call(this._selection.enter.bind(this._selection))
|
|
1974
|
-
.each(function () {
|
|
1975
|
-
var element = select(this);
|
|
1976
|
-
element.append("rect")
|
|
1977
|
-
.attr("height", boxSize)
|
|
1978
|
-
.attr("width", boxSize)
|
|
1979
|
-
.on("click", function (d) {
|
|
1980
|
-
if (context._collapsed[getID(d)]) {
|
|
1981
|
-
delete context._collapsed[getID(d)];
|
|
1982
|
-
}
|
|
1983
|
-
else if (d.children) {
|
|
1984
|
-
context._collapsed[getID(d)] = true;
|
|
1985
|
-
}
|
|
1986
|
-
context.lazyRender();
|
|
1987
|
-
});
|
|
1988
|
-
element.append("text");
|
|
1989
|
-
})
|
|
1990
|
-
.style("opacity", 0);
|
|
1991
|
-
enterNodes.transition()
|
|
1992
|
-
.style("opacity", 1);
|
|
1993
|
-
enterNodes.merge(nodes).select("rect")
|
|
1994
|
-
.attr("x", -boxSize / 2)
|
|
1995
|
-
.attr("y", -boxSize / 2)
|
|
1996
|
-
.style("fill", color);
|
|
1997
|
-
enterNodes.merge(nodes).select("text")
|
|
1998
|
-
.attr("dx", boxSize / 2 + 4 + "px")
|
|
1999
|
-
.attr("dy", "0.33em")
|
|
2000
|
-
.text(function (d) { return d.data.label; });
|
|
2001
|
-
nodes.exit().transition()
|
|
2002
|
-
.style("opacity", 0)
|
|
2003
|
-
.remove();
|
|
2004
|
-
if (!this._renderCount) {
|
|
2005
|
-
context.zoomToFit();
|
|
2006
|
-
}
|
|
2007
|
-
function color(d) {
|
|
2008
|
-
return context._collapsed[getID(d)] ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c";
|
|
2009
|
-
}
|
|
2010
|
-
};
|
|
2011
|
-
return Indented;
|
|
2012
|
-
}(SVGZoomWidget));
|
|
2013
|
-
Indented.prototype._class += " tree_Indented";
|
|
2014
|
-
Indented.prototype.implements(ITree.prototype);
|
|
2015
|
-
Indented.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
2016
|
-
Indented.prototype.Column = IndentedColumn;
|
|
2017
|
-
Indented.prototype.publish("xmlColumn", null, "set", "Field", function () { return this.columns(); }, { optional: true });
|
|
2018
|
-
Indented.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: IndentedColumn, disable: function (w) { return w.xmlColumn_exists(); } });
|
|
2019
|
-
Indented.prototype.publish("barHeight", 16, "number", "Bar height");
|
|
2020
|
-
function xmlToJson(xml, id) {
|
|
2021
|
-
if (id === void 0) { id = ""; }
|
|
2022
|
-
var retVal = {
|
|
2023
|
-
id: id,
|
|
2024
|
-
label: "",
|
|
2025
|
-
attributes: {},
|
|
2026
|
-
children: []
|
|
2027
|
-
};
|
|
2028
|
-
retVal.label = xml.nodeName;
|
|
2029
|
-
if (xml.nodeType === 1) { // element
|
|
2030
|
-
if (xml.attributes.length > 0) {
|
|
2031
|
-
for (var j = 0; j < xml.attributes.length; j++) {
|
|
2032
|
-
var attribute = xml.attributes.item(j);
|
|
2033
|
-
retVal.attributes[attribute.nodeName] = attribute.nodeValue;
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
else if (xml.nodeType === 3) { // text
|
|
2038
|
-
retVal.label = xml.nodeValue;
|
|
2039
|
-
}
|
|
2040
|
-
if (xml.hasChildNodes()) {
|
|
2041
|
-
for (var i = 0; i < xml.childNodes.length; i++) {
|
|
2042
|
-
var item = xml.childNodes.item(i);
|
|
2043
|
-
var child = xmlToJson(item, id + "[" + retVal.children.length + "]");
|
|
2044
|
-
retVal.children.push(child);
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
return retVal;
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
var pi$1 = Math.PI,
|
|
2051
|
-
tau$1 = 2 * pi$1,
|
|
2052
|
-
epsilon$1 = 1e-6,
|
|
2053
|
-
tauEpsilon = tau$1 - epsilon$1;
|
|
2054
|
-
|
|
2055
|
-
function Path() {
|
|
2056
|
-
this._x0 = this._y0 = // start of current subpath
|
|
2057
|
-
this._x1 = this._y1 = null; // end of current subpath
|
|
2058
|
-
this._ = "";
|
|
2059
|
-
}
|
|
2060
|
-
|
|
2061
|
-
function path() {
|
|
2062
|
-
return new Path;
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
Path.prototype = path.prototype = {
|
|
2066
|
-
constructor: Path,
|
|
2067
|
-
moveTo: function(x, y) {
|
|
2068
|
-
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
|
|
2069
|
-
},
|
|
2070
|
-
closePath: function() {
|
|
2071
|
-
if (this._x1 !== null) {
|
|
2072
|
-
this._x1 = this._x0, this._y1 = this._y0;
|
|
2073
|
-
this._ += "Z";
|
|
2074
|
-
}
|
|
2075
|
-
},
|
|
2076
|
-
lineTo: function(x, y) {
|
|
2077
|
-
this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
2078
|
-
},
|
|
2079
|
-
quadraticCurveTo: function(x1, y1, x, y) {
|
|
2080
|
-
this._ += "Q" + (+x1) + "," + (+y1) + "," + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
2081
|
-
},
|
|
2082
|
-
bezierCurveTo: function(x1, y1, x2, y2, x, y) {
|
|
2083
|
-
this._ += "C" + (+x1) + "," + (+y1) + "," + (+x2) + "," + (+y2) + "," + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
2084
|
-
},
|
|
2085
|
-
arcTo: function(x1, y1, x2, y2, r) {
|
|
2086
|
-
x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
|
|
2087
|
-
var x0 = this._x1,
|
|
2088
|
-
y0 = this._y1,
|
|
2089
|
-
x21 = x2 - x1,
|
|
2090
|
-
y21 = y2 - y1,
|
|
2091
|
-
x01 = x0 - x1,
|
|
2092
|
-
y01 = y0 - y1,
|
|
2093
|
-
l01_2 = x01 * x01 + y01 * y01;
|
|
2094
|
-
|
|
2095
|
-
// Is the radius negative? Error.
|
|
2096
|
-
if (r < 0) throw new Error("negative radius: " + r);
|
|
2097
|
-
|
|
2098
|
-
// Is this path empty? Move to (x1,y1).
|
|
2099
|
-
if (this._x1 === null) {
|
|
2100
|
-
this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
// Or, is (x1,y1) coincident with (x0,y0)? Do nothing.
|
|
2104
|
-
else if (!(l01_2 > epsilon$1));
|
|
2105
|
-
|
|
2106
|
-
// Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?
|
|
2107
|
-
// Equivalently, is (x1,y1) coincident with (x2,y2)?
|
|
2108
|
-
// Or, is the radius zero? Line to (x1,y1).
|
|
2109
|
-
else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon$1) || !r) {
|
|
2110
|
-
this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
2111
|
-
}
|
|
2112
|
-
|
|
2113
|
-
// Otherwise, draw an arc!
|
|
2114
|
-
else {
|
|
2115
|
-
var x20 = x2 - x0,
|
|
2116
|
-
y20 = y2 - y0,
|
|
2117
|
-
l21_2 = x21 * x21 + y21 * y21,
|
|
2118
|
-
l20_2 = x20 * x20 + y20 * y20,
|
|
2119
|
-
l21 = Math.sqrt(l21_2),
|
|
2120
|
-
l01 = Math.sqrt(l01_2),
|
|
2121
|
-
l = r * Math.tan((pi$1 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),
|
|
2122
|
-
t01 = l / l01,
|
|
2123
|
-
t21 = l / l21;
|
|
2124
|
-
|
|
2125
|
-
// If the start tangent is not coincident with (x0,y0), line to.
|
|
2126
|
-
if (Math.abs(t01 - 1) > epsilon$1) {
|
|
2127
|
-
this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
|
-
this._ += "A" + r + "," + r + ",0,0," + (+(y01 * x20 > x01 * y20)) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
|
|
2131
|
-
}
|
|
2132
|
-
},
|
|
2133
|
-
arc: function(x, y, r, a0, a1, ccw) {
|
|
2134
|
-
x = +x, y = +y, r = +r, ccw = !!ccw;
|
|
2135
|
-
var dx = r * Math.cos(a0),
|
|
2136
|
-
dy = r * Math.sin(a0),
|
|
2137
|
-
x0 = x + dx,
|
|
2138
|
-
y0 = y + dy,
|
|
2139
|
-
cw = 1 ^ ccw,
|
|
2140
|
-
da = ccw ? a0 - a1 : a1 - a0;
|
|
2141
|
-
|
|
2142
|
-
// Is the radius negative? Error.
|
|
2143
|
-
if (r < 0) throw new Error("negative radius: " + r);
|
|
2144
|
-
|
|
2145
|
-
// Is this path empty? Move to (x0,y0).
|
|
2146
|
-
if (this._x1 === null) {
|
|
2147
|
-
this._ += "M" + x0 + "," + y0;
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
// Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).
|
|
2151
|
-
else if (Math.abs(this._x1 - x0) > epsilon$1 || Math.abs(this._y1 - y0) > epsilon$1) {
|
|
2152
|
-
this._ += "L" + x0 + "," + y0;
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
// Is this arc empty? We’re done.
|
|
2156
|
-
if (!r) return;
|
|
2157
|
-
|
|
2158
|
-
// Does the angle go the wrong way? Flip the direction.
|
|
2159
|
-
if (da < 0) da = da % tau$1 + tau$1;
|
|
2160
|
-
|
|
2161
|
-
// Is this a complete circle? Draw two arcs to complete the circle.
|
|
2162
|
-
if (da > tauEpsilon) {
|
|
2163
|
-
this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
|
-
// Is this arc non-empty? Draw an arc!
|
|
2167
|
-
else if (da > epsilon$1) {
|
|
2168
|
-
this._ += "A" + r + "," + r + ",0," + (+(da >= pi$1)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
|
|
2169
|
-
}
|
|
2170
|
-
},
|
|
2171
|
-
rect: function(x, y, w, h) {
|
|
2172
|
-
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + (+w) + "v" + (+h) + "h" + (-w) + "Z";
|
|
2173
|
-
},
|
|
2174
|
-
toString: function() {
|
|
2175
|
-
return this._;
|
|
2176
|
-
}
|
|
2177
|
-
};
|
|
2178
|
-
|
|
2179
|
-
function constant(x) {
|
|
2180
|
-
return function constant() {
|
|
2181
|
-
return x;
|
|
2182
|
-
};
|
|
2183
|
-
}
|
|
2184
|
-
|
|
2185
|
-
var abs = Math.abs;
|
|
2186
|
-
var atan2 = Math.atan2;
|
|
2187
|
-
var cos = Math.cos;
|
|
2188
|
-
var max = Math.max;
|
|
2189
|
-
var min = Math.min;
|
|
2190
|
-
var sin = Math.sin;
|
|
2191
|
-
var sqrt = Math.sqrt;
|
|
2192
|
-
|
|
2193
|
-
var epsilon = 1e-12;
|
|
2194
|
-
var pi = Math.PI;
|
|
2195
|
-
var halfPi = pi / 2;
|
|
2196
|
-
var tau = 2 * pi;
|
|
2197
|
-
|
|
2198
|
-
function acos(x) {
|
|
2199
|
-
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
|
|
2200
|
-
}
|
|
2201
|
-
|
|
2202
|
-
function asin(x) {
|
|
2203
|
-
return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);
|
|
2204
|
-
}
|
|
2205
|
-
|
|
2206
|
-
function arcInnerRadius(d) {
|
|
2207
|
-
return d.innerRadius;
|
|
2208
|
-
}
|
|
2209
|
-
|
|
2210
|
-
function arcOuterRadius(d) {
|
|
2211
|
-
return d.outerRadius;
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
|
-
function arcStartAngle(d) {
|
|
2215
|
-
return d.startAngle;
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
function arcEndAngle(d) {
|
|
2219
|
-
return d.endAngle;
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
function arcPadAngle(d) {
|
|
2223
|
-
return d && d.padAngle; // Note: optional!
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
|
|
2227
|
-
var x10 = x1 - x0, y10 = y1 - y0,
|
|
2228
|
-
x32 = x3 - x2, y32 = y3 - y2,
|
|
2229
|
-
t = y32 * x10 - x32 * y10;
|
|
2230
|
-
if (t * t < epsilon) return;
|
|
2231
|
-
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
2232
|
-
return [x0 + t * x10, y0 + t * y10];
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
// Compute perpendicular offset line of length rc.
|
|
2236
|
-
// http://mathworld.wolfram.com/Circle-LineIntersection.html
|
|
2237
|
-
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
|
|
2238
|
-
var x01 = x0 - x1,
|
|
2239
|
-
y01 = y0 - y1,
|
|
2240
|
-
lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01),
|
|
2241
|
-
ox = lo * y01,
|
|
2242
|
-
oy = -lo * x01,
|
|
2243
|
-
x11 = x0 + ox,
|
|
2244
|
-
y11 = y0 + oy,
|
|
2245
|
-
x10 = x1 + ox,
|
|
2246
|
-
y10 = y1 + oy,
|
|
2247
|
-
x00 = (x11 + x10) / 2,
|
|
2248
|
-
y00 = (y11 + y10) / 2,
|
|
2249
|
-
dx = x10 - x11,
|
|
2250
|
-
dy = y10 - y11,
|
|
2251
|
-
d2 = dx * dx + dy * dy,
|
|
2252
|
-
r = r1 - rc,
|
|
2253
|
-
D = x11 * y10 - x10 * y11,
|
|
2254
|
-
d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)),
|
|
2255
|
-
cx0 = (D * dy - dx * d) / d2,
|
|
2256
|
-
cy0 = (-D * dx - dy * d) / d2,
|
|
2257
|
-
cx1 = (D * dy + dx * d) / d2,
|
|
2258
|
-
cy1 = (-D * dx + dy * d) / d2,
|
|
2259
|
-
dx0 = cx0 - x00,
|
|
2260
|
-
dy0 = cy0 - y00,
|
|
2261
|
-
dx1 = cx1 - x00,
|
|
2262
|
-
dy1 = cy1 - y00;
|
|
2263
|
-
|
|
2264
|
-
// Pick the closer of the two intersection points.
|
|
2265
|
-
// TODO Is there a faster way to determine which intersection to use?
|
|
2266
|
-
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
|
|
2267
|
-
|
|
2268
|
-
return {
|
|
2269
|
-
cx: cx0,
|
|
2270
|
-
cy: cy0,
|
|
2271
|
-
x01: -ox,
|
|
2272
|
-
y01: -oy,
|
|
2273
|
-
x11: cx0 * (r1 / r - 1),
|
|
2274
|
-
y11: cy0 * (r1 / r - 1)
|
|
2275
|
-
};
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
function d3Arc() {
|
|
2279
|
-
var innerRadius = arcInnerRadius,
|
|
2280
|
-
outerRadius = arcOuterRadius,
|
|
2281
|
-
cornerRadius = constant(0),
|
|
2282
|
-
padRadius = null,
|
|
2283
|
-
startAngle = arcStartAngle,
|
|
2284
|
-
endAngle = arcEndAngle,
|
|
2285
|
-
padAngle = arcPadAngle,
|
|
2286
|
-
context = null;
|
|
2287
|
-
|
|
2288
|
-
function arc() {
|
|
2289
|
-
var buffer,
|
|
2290
|
-
r,
|
|
2291
|
-
r0 = +innerRadius.apply(this, arguments),
|
|
2292
|
-
r1 = +outerRadius.apply(this, arguments),
|
|
2293
|
-
a0 = startAngle.apply(this, arguments) - halfPi,
|
|
2294
|
-
a1 = endAngle.apply(this, arguments) - halfPi,
|
|
2295
|
-
da = abs(a1 - a0),
|
|
2296
|
-
cw = a1 > a0;
|
|
2297
|
-
|
|
2298
|
-
if (!context) context = buffer = path();
|
|
2299
|
-
|
|
2300
|
-
// Ensure that the outer radius is always larger than the inner radius.
|
|
2301
|
-
if (r1 < r0) r = r1, r1 = r0, r0 = r;
|
|
2302
|
-
|
|
2303
|
-
// Is it a point?
|
|
2304
|
-
if (!(r1 > epsilon)) context.moveTo(0, 0);
|
|
2305
|
-
|
|
2306
|
-
// Or is it a circle or annulus?
|
|
2307
|
-
else if (da > tau - epsilon) {
|
|
2308
|
-
context.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
2309
|
-
context.arc(0, 0, r1, a0, a1, !cw);
|
|
2310
|
-
if (r0 > epsilon) {
|
|
2311
|
-
context.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
2312
|
-
context.arc(0, 0, r0, a1, a0, cw);
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
// Or is it a circular or annular sector?
|
|
2317
|
-
else {
|
|
2318
|
-
var a01 = a0,
|
|
2319
|
-
a11 = a1,
|
|
2320
|
-
a00 = a0,
|
|
2321
|
-
a10 = a1,
|
|
2322
|
-
da0 = da,
|
|
2323
|
-
da1 = da,
|
|
2324
|
-
ap = padAngle.apply(this, arguments) / 2,
|
|
2325
|
-
rp = (ap > epsilon) && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)),
|
|
2326
|
-
rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)),
|
|
2327
|
-
rc0 = rc,
|
|
2328
|
-
rc1 = rc,
|
|
2329
|
-
t0,
|
|
2330
|
-
t1;
|
|
2331
|
-
|
|
2332
|
-
// Apply padding? Note that since r1 ≥ r0, da1 ≥ da0.
|
|
2333
|
-
if (rp > epsilon) {
|
|
2334
|
-
var p0 = asin(rp / r0 * sin(ap)),
|
|
2335
|
-
p1 = asin(rp / r1 * sin(ap));
|
|
2336
|
-
if ((da0 -= p0 * 2) > epsilon) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0;
|
|
2337
|
-
else da0 = 0, a00 = a10 = (a0 + a1) / 2;
|
|
2338
|
-
if ((da1 -= p1 * 2) > epsilon) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1;
|
|
2339
|
-
else da1 = 0, a01 = a11 = (a0 + a1) / 2;
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
var x01 = r1 * cos(a01),
|
|
2343
|
-
y01 = r1 * sin(a01),
|
|
2344
|
-
x10 = r0 * cos(a10),
|
|
2345
|
-
y10 = r0 * sin(a10);
|
|
2346
|
-
|
|
2347
|
-
// Apply rounded corners?
|
|
2348
|
-
if (rc > epsilon) {
|
|
2349
|
-
var x11 = r1 * cos(a11),
|
|
2350
|
-
y11 = r1 * sin(a11),
|
|
2351
|
-
x00 = r0 * cos(a00),
|
|
2352
|
-
y00 = r0 * sin(a00),
|
|
2353
|
-
oc;
|
|
2354
|
-
|
|
2355
|
-
// Restrict the corner radius according to the sector angle.
|
|
2356
|
-
if (da < pi && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) {
|
|
2357
|
-
var ax = x01 - oc[0],
|
|
2358
|
-
ay = y01 - oc[1],
|
|
2359
|
-
bx = x11 - oc[0],
|
|
2360
|
-
by = y11 - oc[1],
|
|
2361
|
-
kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2),
|
|
2362
|
-
lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
2363
|
-
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
2364
|
-
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
2365
|
-
}
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
// Is the sector collapsed to a line?
|
|
2369
|
-
if (!(da1 > epsilon)) context.moveTo(x01, y01);
|
|
2370
|
-
|
|
2371
|
-
// Does the sector’s outer ring have rounded corners?
|
|
2372
|
-
else if (rc1 > epsilon) {
|
|
2373
|
-
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
2374
|
-
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
2375
|
-
|
|
2376
|
-
context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
2377
|
-
|
|
2378
|
-
// Have the corners merged?
|
|
2379
|
-
if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
2380
|
-
|
|
2381
|
-
// Otherwise, draw the two corners and the ring.
|
|
2382
|
-
else {
|
|
2383
|
-
context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
2384
|
-
context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
|
|
2385
|
-
context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
// Or is the outer ring just a circular arc?
|
|
2390
|
-
else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
|
|
2391
|
-
|
|
2392
|
-
// Is there no inner ring, and it’s a circular sector?
|
|
2393
|
-
// Or perhaps it’s an annular sector collapsed due to padding?
|
|
2394
|
-
if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10);
|
|
2395
|
-
|
|
2396
|
-
// Does the sector’s inner ring (or point) have rounded corners?
|
|
2397
|
-
else if (rc0 > epsilon) {
|
|
2398
|
-
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
2399
|
-
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
2400
|
-
|
|
2401
|
-
context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
2402
|
-
|
|
2403
|
-
// Have the corners merged?
|
|
2404
|
-
if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
2405
|
-
|
|
2406
|
-
// Otherwise, draw the two corners and the ring.
|
|
2407
|
-
else {
|
|
2408
|
-
context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
2409
|
-
context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
|
|
2410
|
-
context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
// Or is the inner ring just a circular arc?
|
|
2415
|
-
else context.arc(0, 0, r0, a10, a00, cw);
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
context.closePath();
|
|
2419
|
-
|
|
2420
|
-
if (buffer) return context = null, buffer + "" || null;
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2423
|
-
arc.centroid = function() {
|
|
2424
|
-
var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2,
|
|
2425
|
-
a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2;
|
|
2426
|
-
return [cos(a) * r, sin(a) * r];
|
|
2427
|
-
};
|
|
2428
|
-
|
|
2429
|
-
arc.innerRadius = function(_) {
|
|
2430
|
-
return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant(+_), arc) : innerRadius;
|
|
2431
|
-
};
|
|
2432
|
-
|
|
2433
|
-
arc.outerRadius = function(_) {
|
|
2434
|
-
return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant(+_), arc) : outerRadius;
|
|
2435
|
-
};
|
|
2436
|
-
|
|
2437
|
-
arc.cornerRadius = function(_) {
|
|
2438
|
-
return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant(+_), arc) : cornerRadius;
|
|
2439
|
-
};
|
|
2440
|
-
|
|
2441
|
-
arc.padRadius = function(_) {
|
|
2442
|
-
return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant(+_), arc) : padRadius;
|
|
2443
|
-
};
|
|
2444
|
-
|
|
2445
|
-
arc.startAngle = function(_) {
|
|
2446
|
-
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), arc) : startAngle;
|
|
2447
|
-
};
|
|
2448
|
-
|
|
2449
|
-
arc.endAngle = function(_) {
|
|
2450
|
-
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), arc) : endAngle;
|
|
2451
|
-
};
|
|
2452
|
-
|
|
2453
|
-
arc.padAngle = function(_) {
|
|
2454
|
-
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), arc) : padAngle;
|
|
2455
|
-
};
|
|
2456
|
-
|
|
2457
|
-
arc.context = function(_) {
|
|
2458
|
-
return arguments.length ? ((context = _ == null ? null : _), arc) : context;
|
|
2459
|
-
};
|
|
2460
|
-
|
|
2461
|
-
return arc;
|
|
2462
|
-
}
|
|
2463
|
-
|
|
2464
|
-
var css_248z$1 = ".tree_Sunburst path{stroke:#fff;stroke-width:.5px;fill-rule:evenodd}";
|
|
2465
|
-
styleInject(css_248z$1);
|
|
2466
|
-
|
|
2467
|
-
var SunburstPartition = /** @class */ (function (_super) {
|
|
2468
|
-
__extends(SunburstPartition, _super);
|
|
2469
|
-
function SunburstPartition() {
|
|
2470
|
-
var _this = _super.call(this) || this;
|
|
2471
|
-
ITree.call(_this);
|
|
2472
|
-
return _this;
|
|
2473
|
-
}
|
|
2474
|
-
SunburstPartition.prototype.data = function (_) {
|
|
2475
|
-
var retVal = SVGWidget.prototype.data.apply(this, arguments);
|
|
2476
|
-
if (arguments.length) {
|
|
2477
|
-
this._resetRoot = true;
|
|
2478
|
-
}
|
|
2479
|
-
return retVal;
|
|
2480
|
-
};
|
|
2481
|
-
SunburstPartition.prototype.enter = function (_domNode, element) {
|
|
2482
|
-
var context = this;
|
|
2483
|
-
this.radius = Math.min(this.width(), this.height()) / 2;
|
|
2484
|
-
this._xScale = scaleLinear()
|
|
2485
|
-
.range([0, 2 * Math.PI]);
|
|
2486
|
-
this._yScale = scaleSqrt()
|
|
2487
|
-
.range([0, this.radius]);
|
|
2488
|
-
this.partition = d3Parition();
|
|
2489
|
-
this.arc = d3Arc()
|
|
2490
|
-
.startAngle(function (d) {
|
|
2491
|
-
return Math.max(0, Math.min(2 * Math.PI, context._xScale(d.x0)));
|
|
2492
|
-
})
|
|
2493
|
-
.endAngle(function (d) {
|
|
2494
|
-
return Math.max(0, Math.min(2 * Math.PI, context._xScale(d.x1)));
|
|
2495
|
-
})
|
|
2496
|
-
.innerRadius(function (d) {
|
|
2497
|
-
return Math.max(0, context._yScale(d.y0));
|
|
2498
|
-
})
|
|
2499
|
-
.outerRadius(function (d) {
|
|
2500
|
-
return Math.max(0, context._yScale(d.y1));
|
|
2501
|
-
});
|
|
2502
|
-
this.svg = element.append("g");
|
|
2503
|
-
};
|
|
2504
|
-
SunburstPartition.prototype.update = function (_domNode, _element) {
|
|
2505
|
-
var context = this;
|
|
2506
|
-
this._palette = this._palette.switch(this.paletteID());
|
|
2507
|
-
if (this.useClonedPalette()) {
|
|
2508
|
-
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
2509
|
-
}
|
|
2510
|
-
this.radius = Math.min(this.width(), this.height()) / 2;
|
|
2511
|
-
this._yScale.range([0, this.radius]);
|
|
2512
|
-
var root = hierarchy(this.data())
|
|
2513
|
-
.sum(function (d) {
|
|
2514
|
-
return d.size !== undefined ? d.size : 1;
|
|
2515
|
-
});
|
|
2516
|
-
var paths = this.svg.selectAll("path").data(this.partition(root).descendants(), function (d, i) {
|
|
2517
|
-
return d.data.label !== undefined ? d.data.label : i;
|
|
2518
|
-
});
|
|
2519
|
-
paths.enter().append("path")
|
|
2520
|
-
.on("click", function (d) { context.click(d.data, null, null); })
|
|
2521
|
-
.on("dblclick", function (d) {
|
|
2522
|
-
var event = d3Event();
|
|
2523
|
-
if (event) {
|
|
2524
|
-
event.stopPropagation();
|
|
2525
|
-
}
|
|
2526
|
-
context.zoomTo(d);
|
|
2527
|
-
})
|
|
2528
|
-
.each(function () {
|
|
2529
|
-
var element = select(this);
|
|
2530
|
-
element
|
|
2531
|
-
.append("title");
|
|
2532
|
-
})
|
|
2533
|
-
.merge(paths)
|
|
2534
|
-
.attr("d", this.arc)
|
|
2535
|
-
.style("fill", function (d) {
|
|
2536
|
-
return d.data.__viz_fill ? d.data.__viz_fill : context._palette(d.data.label);
|
|
2537
|
-
})
|
|
2538
|
-
.style("stroke", function (d) {
|
|
2539
|
-
return d.value > 16 ? "white" : "none";
|
|
2540
|
-
})
|
|
2541
|
-
.select("title")
|
|
2542
|
-
.text(function (d) {
|
|
2543
|
-
return d.data.label;
|
|
2544
|
-
});
|
|
2545
|
-
paths.exit().remove();
|
|
2546
|
-
if (this._resetRoot) {
|
|
2547
|
-
this._resetRoot = false;
|
|
2548
|
-
this.zoomTo(root);
|
|
2549
|
-
}
|
|
2550
|
-
};
|
|
2551
|
-
SunburstPartition.prototype.zoomTo = function (d) {
|
|
2552
|
-
var context = this;
|
|
2553
|
-
this.svg.transition()
|
|
2554
|
-
.duration(750)
|
|
2555
|
-
.tween("scale", function () {
|
|
2556
|
-
var xd = interpolate(context._xScale.domain(), [d.x0, d.x1]);
|
|
2557
|
-
var yd = interpolate(context._yScale.domain(), [d.y0, 1]);
|
|
2558
|
-
var yr = interpolate(context._yScale.range(), [d.y0 ? 20 : 0, context.radius]);
|
|
2559
|
-
return function (t) { context._xScale.domain(xd(t)); context._yScale.domain(yd(t)).range(yr(t)); };
|
|
2560
|
-
})
|
|
2561
|
-
.selectAll("path")
|
|
2562
|
-
.attrTween("d", function (d2) { return function () { return context.arc(d2); }; });
|
|
2563
|
-
};
|
|
2564
|
-
return SunburstPartition;
|
|
2565
|
-
}(SVGWidget));
|
|
2566
|
-
SunburstPartition.prototype._class += " tree_SunburstPartition";
|
|
2567
|
-
SunburstPartition.prototype.implements(ITree.prototype);
|
|
2568
|
-
SunburstPartition.prototype.publish("paletteID", "default", "set", "Color palette for this widget", SunburstPartition.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
2569
|
-
SunburstPartition.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
2570
|
-
|
|
2571
|
-
var css_248z = ".tree_Treemap *{box-sizing:border-box}.tree_Treemap .node{border:1px solid #333;overflow:hidden;position:absolute;text-overflow:ellipsis}.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{display:inline-block;font-weight:700;margin:4px 4px 0}.tree_Treemap .node>span.treemap-parent-value{font-style:italic;font-weight:400;margin:4px 0 0}.tree_Treemap .node>span.treemap-singleton-label{display:block;font-weight:400;margin:4px 0 0 4px}.tree_Treemap .node>span.treemap-singleton-value{display:block;font-style:italic;margin:0 0 0 4px}";
|
|
2572
|
-
styleInject(css_248z);
|
|
2573
|
-
|
|
2574
|
-
var TreemapColumn = /** @class */ (function (_super) {
|
|
2575
|
-
__extends(TreemapColumn, _super);
|
|
2576
|
-
function TreemapColumn() {
|
|
2577
|
-
return _super.call(this) || this;
|
|
2578
|
-
}
|
|
2579
|
-
TreemapColumn.prototype.owner = function (_) {
|
|
2580
|
-
if (!arguments.length)
|
|
2581
|
-
return this._owner;
|
|
2582
|
-
this._owner = _;
|
|
2583
|
-
return this;
|
|
2584
|
-
};
|
|
2585
|
-
TreemapColumn.prototype.valid = function () {
|
|
2586
|
-
return !!this.column();
|
|
2587
|
-
};
|
|
2588
|
-
return TreemapColumn;
|
|
2589
|
-
}(PropertyExt));
|
|
2590
|
-
TreemapColumn.prototype._class += " tree_Dendrogram.TreemapColumn";
|
|
2591
|
-
TreemapColumn.prototype.publish("column", null, "set", "Field", function () { return this._owner ? this._owner.columns() : []; }, { optional: true });
|
|
2592
|
-
// ===
|
|
2593
|
-
var Treemap = /** @class */ (function (_super) {
|
|
2594
|
-
__extends(Treemap, _super);
|
|
2595
|
-
function Treemap() {
|
|
2596
|
-
var _this = _super.call(this) || this;
|
|
2597
|
-
ITree.call(_this);
|
|
2598
|
-
Utility.SimpleSelectionMixin.call(_this, true);
|
|
2599
|
-
return _this;
|
|
2600
|
-
}
|
|
2601
|
-
Treemap.prototype.getTilingMethod = function () {
|
|
2602
|
-
switch (this.tilingMethod()) {
|
|
2603
|
-
case "treemapBinary":
|
|
2604
|
-
return d3treemapBinary;
|
|
2605
|
-
case "treemapDice":
|
|
2606
|
-
return d3treemapDice;
|
|
2607
|
-
case "treemapSlice":
|
|
2608
|
-
return d3treemapSlice;
|
|
2609
|
-
case "treemapSliceDice":
|
|
2610
|
-
return d3treemapSliceDice;
|
|
2611
|
-
case "treemapResquarify":
|
|
2612
|
-
return d3treemapResquarify;
|
|
2613
|
-
case "treemapSquarify":
|
|
2614
|
-
default:
|
|
2615
|
-
return d3treemapSquarify;
|
|
2616
|
-
}
|
|
2617
|
-
};
|
|
2618
|
-
Treemap.prototype.treemapData = function () {
|
|
2619
|
-
if (!this.mappings().filter(function (mapping) { return mapping.valid(); }).length) {
|
|
2620
|
-
return this.data();
|
|
2621
|
-
}
|
|
2622
|
-
var view = this._db.aggregateView(this.mappings().map(function (mapping) { return mapping.column(); }), this.aggrType(), this.aggrColumn());
|
|
2623
|
-
var retVal = {
|
|
2624
|
-
key: "root",
|
|
2625
|
-
values: view.entries()
|
|
2626
|
-
};
|
|
2627
|
-
return formatData(retVal);
|
|
2628
|
-
function formatData(node) {
|
|
2629
|
-
if (node.values instanceof Array) {
|
|
2630
|
-
var children = node.values.filter(function (value) {
|
|
2631
|
-
return !(value instanceof Array);
|
|
2632
|
-
}).map(function (value) {
|
|
2633
|
-
return formatData(value);
|
|
2634
|
-
});
|
|
2635
|
-
var retVal2 = {
|
|
2636
|
-
label: node.key
|
|
2637
|
-
};
|
|
2638
|
-
if (children.length) {
|
|
2639
|
-
retVal2.children = children;
|
|
2640
|
-
}
|
|
2641
|
-
else {
|
|
2642
|
-
retVal2.size = 22;
|
|
2643
|
-
}
|
|
2644
|
-
return retVal2;
|
|
2645
|
-
}
|
|
2646
|
-
return {
|
|
2647
|
-
label: node.key,
|
|
2648
|
-
size: node.values.aggregate,
|
|
2649
|
-
origRows: node.values
|
|
2650
|
-
};
|
|
2651
|
-
}
|
|
2652
|
-
};
|
|
2653
|
-
Treemap.prototype.enter = function (domNode, element) {
|
|
2654
|
-
_super.prototype.enter.call(this, domNode, element);
|
|
2655
|
-
this._d3Treemap = d3Treemap();
|
|
2656
|
-
this._elementDIV = element.append("div");
|
|
2657
|
-
this._selection.widgetElement(this._elementDIV);
|
|
2658
|
-
};
|
|
2659
|
-
Treemap.prototype.update = function (domNode, element) {
|
|
2660
|
-
_super.prototype.update.call(this, domNode, element);
|
|
2661
|
-
var context = this;
|
|
2662
|
-
this._palette = this._palette.switch(this.paletteID());
|
|
2663
|
-
if (this.useClonedPalette()) {
|
|
2664
|
-
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
2665
|
-
}
|
|
2666
|
-
var root = hierarchy(this.treemapData())
|
|
2667
|
-
.sum(this.nodeWeight);
|
|
2668
|
-
this._d3Treemap
|
|
2669
|
-
.size([this.width(), this.height()])
|
|
2670
|
-
.paddingInner(this.paddingInner())
|
|
2671
|
-
.paddingOuter(this.paddingOuter())
|
|
2672
|
-
.paddingTop(this.paddingTop());
|
|
2673
|
-
if (["treemapSquarify", "treemapResquarify"].indexOf(this.tilingMethod()) !== -1) {
|
|
2674
|
-
this._d3Treemap.tile(this.getTilingMethod()["ratio"](this.squarifyRatio()));
|
|
2675
|
-
}
|
|
2676
|
-
else {
|
|
2677
|
-
this._d3Treemap.tile(this.getTilingMethod());
|
|
2678
|
-
}
|
|
2679
|
-
this._d3Treemap(root);
|
|
2680
|
-
this._elementDIV
|
|
2681
|
-
.style("font-size", this.fontSize_exists() ? this.fontSize() + "px" : null)
|
|
2682
|
-
.style("line-height", this.fontSize_exists() ? (this.fontSize() + 2) + "px" : null);
|
|
2683
|
-
var node = this._elementDIV.selectAll(".node").data(root.descendants());
|
|
2684
|
-
node.enter().append("div")
|
|
2685
|
-
.attr("class", "node")
|
|
2686
|
-
.call(this._selection.enter.bind(this._selection))
|
|
2687
|
-
.on("click", function (d) {
|
|
2688
|
-
if (d) {
|
|
2689
|
-
var columnLabel_1 = "";
|
|
2690
|
-
context.mappings().forEach(function (mapping) {
|
|
2691
|
-
if (mapping.column()) {
|
|
2692
|
-
columnLabel_1 = mapping.column();
|
|
2693
|
-
}
|
|
2694
|
-
});
|
|
2695
|
-
if (d.origRows) {
|
|
2696
|
-
context.click(context.rowToObj(d.origRows[0]), columnLabel_1, context._selection.selected(this));
|
|
2697
|
-
}
|
|
2698
|
-
else {
|
|
2699
|
-
context.click(d.data, columnLabel_1, context._selection.selected(this));
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
})
|
|
2703
|
-
.on("dblclick", function (d) {
|
|
2704
|
-
if (d) {
|
|
2705
|
-
var columnLabel_2 = "";
|
|
2706
|
-
context.mappings().forEach(function (mapping) {
|
|
2707
|
-
if (mapping.column()) {
|
|
2708
|
-
columnLabel_2 = mapping.column();
|
|
2709
|
-
}
|
|
2710
|
-
});
|
|
2711
|
-
if (d.origRows) {
|
|
2712
|
-
context.dblclick(context.rowToObj(d.origRows[0]), columnLabel_2, context._selection.selected(this));
|
|
2713
|
-
}
|
|
2714
|
-
else {
|
|
2715
|
-
context.dblclick(d.data, columnLabel_2, context._selection.selected(this));
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
})
|
|
2719
|
-
.merge(node)
|
|
2720
|
-
.style("left", function (d) { return (d.x0 + Math.max(0, d.x1 - d.x0) / 2) + "px"; })
|
|
2721
|
-
.style("top", function (d) { return (d.y0 + Math.max(0, d.y1 - d.y0) / 2) + "px"; })
|
|
2722
|
-
.style("width", function () { return 0 + "px"; })
|
|
2723
|
-
.style("height", function () { return 0 + "px"; })
|
|
2724
|
-
.style("font-size", function (d) { return (d.children ? context.parentFontSize() : context.leafFontSize()) + "px"; })
|
|
2725
|
-
.style("line-height", function (d) { return (d.children ? context.parentFontSize() : context.leafFontSize()) + "px"; })
|
|
2726
|
-
.attr("title", tooltip)
|
|
2727
|
-
.html(function (d) {
|
|
2728
|
-
if (!context.showRoot() && d.depth === 0) {
|
|
2729
|
-
return null;
|
|
2730
|
-
}
|
|
2731
|
-
if (d.children) {
|
|
2732
|
-
if (context.enableParentLabels()) {
|
|
2733
|
-
return context.parentWeightHTML(d);
|
|
2734
|
-
}
|
|
2735
|
-
else {
|
|
2736
|
-
return null;
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
else {
|
|
2740
|
-
return context.leafWeightHTML(d);
|
|
2741
|
-
}
|
|
2742
|
-
})
|
|
2743
|
-
.style("background", function (d) {
|
|
2744
|
-
if (!context.showRoot() && d.depth === 0) {
|
|
2745
|
-
this.style.color = "transparent";
|
|
2746
|
-
return "transparent";
|
|
2747
|
-
}
|
|
2748
|
-
var light_dark = context.brighterLeafNodes() ? "brighter" : "darker";
|
|
2749
|
-
var _color;
|
|
2750
|
-
if (context.usePaletteOnParentNodes()) {
|
|
2751
|
-
_color = d.children ? context._palette(d.data.label) : rgb(context._palette(d.parent.data.label))[light_dark](1);
|
|
2752
|
-
}
|
|
2753
|
-
else {
|
|
2754
|
-
if (d.depth > context.depthColorLimit()) {
|
|
2755
|
-
_color = rgb(d.parent.color)[light_dark](1);
|
|
2756
|
-
}
|
|
2757
|
-
else {
|
|
2758
|
-
_color = context._palette(d.data.label);
|
|
2759
|
-
}
|
|
2760
|
-
d.color = _color;
|
|
2761
|
-
}
|
|
2762
|
-
this.style.color = Palette.textColor(_color);
|
|
2763
|
-
return _color;
|
|
2764
|
-
})
|
|
2765
|
-
.transition().duration(this.transitionDuration())
|
|
2766
|
-
.style("pointer-events", function (d) { return !context.showRoot() && d.depth === 0 ? "none" : "all"; })
|
|
2767
|
-
.style("opacity", function (d) { return d.children ? 1 : null; })
|
|
2768
|
-
.style("left", function (d) { return d.x0 + "px"; })
|
|
2769
|
-
.style("top", function (d) { return d.y0 + "px"; })
|
|
2770
|
-
.style("width", function (d) { return Math.max(0, d.x1 - d.x0) + "px"; })
|
|
2771
|
-
.style("height", function (d) { return Math.max(0, d.y1 - d.y0) + "px"; })
|
|
2772
|
-
.each(function (d) {
|
|
2773
|
-
if (d.depth === 0) {
|
|
2774
|
-
this.style.color = !context.showRoot() ? "transparent" : "";
|
|
2775
|
-
this.style.borderColor = !context.showRoot() ? "transparent" : "";
|
|
2776
|
-
}
|
|
2777
|
-
});
|
|
2778
|
-
node.exit().transition().duration(this.transitionDuration())
|
|
2779
|
-
.style("opacity", 0)
|
|
2780
|
-
.remove();
|
|
2781
|
-
function tooltip(d) {
|
|
2782
|
-
if (d.children && !context.enableParentTooltips()) {
|
|
2783
|
-
return null;
|
|
2784
|
-
}
|
|
2785
|
-
var retVal = d.data.label + " (" + d.value + ")";
|
|
2786
|
-
while (d.parent && d.parent.parent) {
|
|
2787
|
-
retVal = d.parent.data.label + " -> " + retVal;
|
|
2788
|
-
d = d.parent;
|
|
2789
|
-
}
|
|
2790
|
-
return retVal;
|
|
2791
|
-
}
|
|
2792
|
-
};
|
|
2793
|
-
Treemap.prototype.exit = function (domNode, element) {
|
|
2794
|
-
_super.prototype.exit.call(this, domNode, element);
|
|
2795
|
-
};
|
|
2796
|
-
Treemap.prototype.nodeWeight = function (d) {
|
|
2797
|
-
return d.size || 1;
|
|
2798
|
-
};
|
|
2799
|
-
Treemap.prototype.parentWeightHTML = function (d) {
|
|
2800
|
-
return this.showParentWeight() ? "<span class=\"treemap-parent-label\">".concat(d.data.label, "</span><span class=\"treemap-parent-value\">").concat(d.value).concat(this.weightSuffix(), "</span>") : "<span class=\"treemap-parent-label\">".concat(d.data.label, "</span>");
|
|
2801
|
-
};
|
|
2802
|
-
Treemap.prototype.leafWeightHTML = function (d) {
|
|
2803
|
-
return this.showLeafWeight() ? "<span class=\"treemap-leaf-label\">".concat(d.data.label, "</span><span class=\"treemap-leaf-value\">").concat(d.value).concat(this.weightSuffix(), "</span>") : "<span class=\"treemap-leaf-label\">".concat(d.data.label, "</span>");
|
|
2804
|
-
};
|
|
2805
|
-
return Treemap;
|
|
2806
|
-
}(HTMLWidget));
|
|
2807
|
-
Treemap.prototype._class += " tree_Treemap";
|
|
2808
|
-
Treemap.prototype.implements(ITree.prototype);
|
|
2809
|
-
Treemap.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
2810
|
-
Treemap.prototype.Column = TreemapColumn;
|
|
2811
|
-
Treemap.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Treemap.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
2812
|
-
Treemap.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
2813
|
-
Treemap.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: TreemapColumn });
|
|
2814
|
-
Treemap.prototype.publish("aggrType", null, "set", "Aggregation Type", [null, "mean", "median", "sum", "min", "max"], { optional: true });
|
|
2815
|
-
Treemap.prototype.publish("aggrColumn", null, "set", "Aggregation Field", function () { return this.columns(); }, { optional: true, disable: function (w) { return !w.aggrType(); } });
|
|
2816
|
-
Treemap.prototype.publish("fontSize", null, "number", "Font Size", null, { optional: true });
|
|
2817
|
-
Treemap.prototype.publish("paddingInner", 18.6, "number", "Pixel spacing between each sibling node");
|
|
2818
|
-
Treemap.prototype.publish("paddingOuter", 30, "number", "Pixel padding of parent nodes");
|
|
2819
|
-
Treemap.prototype.publish("paddingTop", 41.4, "number", "Additional top pixel padding of parent nodes");
|
|
2820
|
-
Treemap.prototype.publish("showRoot", false, "boolean", "Show root element");
|
|
2821
|
-
Treemap.prototype.publish("parentFontSize", 18, "number", "Parent font-size");
|
|
2822
|
-
Treemap.prototype.publish("leafFontSize", 16, "number", "Leaf font-size");
|
|
2823
|
-
Treemap.prototype.publish("usePaletteOnParentNodes", false, "boolean", "Assign a color from the palette to every parent node");
|
|
2824
|
-
Treemap.prototype.publish("depthColorLimit", 1, "number", "Assign a color from the palette to node with depth lower than this value", null, { optional: true, disable: function (w) { return w.usePaletteOnParentNodes(); } });
|
|
2825
|
-
Treemap.prototype.publish("squarifyRatio", 1, "number", "Specifies the desired aspect ratio of the generated rectangles (must be >= 1)", null, { optional: true, disable: function (w) { return ["treemapSquarify", "treemapResquarify"].indexOf(w.tilingMethod()) === -1; } });
|
|
2826
|
-
Treemap.prototype.publish("showParentWeight", true, "boolean", "Show weight of parent nodes");
|
|
2827
|
-
Treemap.prototype.publish("showLeafWeight", true, "boolean", "Show weight of leaf nodes");
|
|
2828
|
-
Treemap.prototype.publish("weightSuffix", "", "string", "Weight suffix (ex: 'ms')");
|
|
2829
|
-
Treemap.prototype.publish("brighterLeafNodes", false, "boolean", "Brighter/darker leaf node color (false = darker)");
|
|
2830
|
-
Treemap.prototype.publish("enableParentLabels", true, "boolean", "Enable parent labels");
|
|
2831
|
-
Treemap.prototype.publish("enableParentTooltips", true, "boolean", "Enable parent tooltips");
|
|
2832
|
-
Treemap.prototype.publish("transitionDuration", 250, "number", "Transition Duration");
|
|
2833
|
-
Treemap.prototype.publish("tilingMethod", "treemapSquarify", "set", "Transition Duration", ["treemapBinary", "treemapDice", "treemapResquarify", "treemapSlice", "treemapSliceDice", "treemapSquarify"]);
|
|
2834
|
-
|
|
2835
|
-
export { BUILD_VERSION, CirclePacking, Dendrogram, DendrogramColumn, DirectoryTree, Indented, IndentedColumn, PKG_NAME, PKG_VERSION, SunburstPartition, Treemap, TreemapColumn };
|
|
2836
|
-
//# sourceMappingURL=index.es6.js.map
|