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