igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
1,461 lines (1,460 loc) • 162 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { HighlightingManager } from "igniteui-angular-core";
import { Base, markType, runOn, delegateCombine, delegateRemove, fromEnum, String_$type, INotifyPropertyChanged_$type, PropertyChangedEventArgs, EventArgs, fromEn, EnumUtil, enumGetBox, typeGetValue, Point_$type } from "igniteui-angular-core";
import { TreemapHighlightingMode_$type } from "./TreemapHighlightingMode";
import { RenderingContext } from "igniteui-angular-core";
import { FontInfo } from "igniteui-angular-core";
import { FontDefaults } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { CanvasViewRenderer } from "igniteui-angular-core";
import { CanvasGestureDOMEventProxy } from "igniteui-angular-core";
import { TreemapVisualData } from "./TreemapVisualData";
import { List$1 } from "igniteui-angular-core";
import { TreemapVisual } from "./TreemapVisual";
import { Pool$1 } from "igniteui-angular-core";
import { FontUtil } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { DOMExecutionContext } from "igniteui-angular-core";
import { truncate, isNaN_, logBase } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
import { TextBlock } from "igniteui-angular-core";
import { HorizontalAlignment_$type } from "igniteui-angular-core";
import { VerticalAlignment_$type } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { TreemapNodeVisualData } from "./TreemapNodeVisualData";
import { TreemapLabelVisualData } from "./TreemapLabelVisualData";
import { RectangleVisualData } from "igniteui-angular-core";
import { AppearanceHelper } from "igniteui-angular-core";
import { PointData } from "igniteui-angular-core";
import { SizeData } from "igniteui-angular-core";
import { HashSet$1 } from "igniteui-angular-core";
import { TreemapOrientation_$type } from "./TreemapOrientation";
import { Size } from "igniteui-angular-core";
import { AreaInfo } from "./AreaInfo";
import { Dictionary$2 } from "igniteui-angular-core";
import { DoubleAnimator } from "igniteui-angular-core";
import { TreemapHighlightedValueDisplayMode_$type } from "./TreemapHighlightedValueDisplayMode";
import { BrushCollection } from "igniteui-angular-core";
import { TreemapFillScaleMode_$type } from "./TreemapFillScaleMode";
import { TreemapLabelVerticalFitMode_$type } from "./TreemapLabelVerticalFitMode";
import { TreemapLabelHorizontalFitMode_$type } from "./TreemapLabelHorizontalFitMode";
import { TreemapHeaderDisplayMode_$type } from "./TreemapHeaderDisplayMode";
import { TreemapLayoutType_$type } from "./TreemapLayoutType";
import { FastItemsSource } from "igniteui-angular-core";
import { HighlightingInfo } from "igniteui-angular-core";
import { EasingFunctions } from "igniteui-angular-core";
import { NotifyCollectionChangedEventArgs } from "igniteui-angular-core";
import { ObservableCollection$1 } from "igniteui-angular-core";
import { RectData } from "igniteui-angular-core";
import { TreemapNodeVisualDataList } from "./TreemapNodeVisualDataList";
import { BrushCollectionUtil } from "igniteui-angular-core";
import { TreemapValueMappingMode_$type } from "./TreemapValueMappingMode";
import { TreemapNodePointerEventArgs } from "./TreemapNodePointerEventArgs";
import { TreemapNodeStyleMappingTargetType_$type } from "./TreemapNodeStyleMappingTargetType";
import { stringIsNullOrEmpty, stringReplace } from "igniteui-angular-core";
/**
* @hidden
*/
export let TreemapHighlightingManager = /*@__PURE__*/ (() => {
class TreemapHighlightingManager extends HighlightingManager {
isCrossContextHighlight(a) {
let b = a;
return b.au == 3;
}
}
TreemapHighlightingManager.$t = markType(TreemapHighlightingManager, 'TreemapHighlightingManager', HighlightingManager.$);
return TreemapHighlightingManager;
})();
/**
* @hidden
*/
export let TreemapView = /*@__PURE__*/ (() => {
class TreemapView extends Base {
constructor() {
super();
this.b = null;
this.a = null;
this.p = false;
this.af = null;
this.m = null;
this.ad = null;
this.t = 0;
this.s = 0;
this.g = null;
this.ae = null;
this.w = 1;
this.ac = null;
this.c = null;
this.u = 0;
this.v = 0;
this.a4 = null;
this.i = ((() => {
let $ret = new FontInfo();
$ret.q = FontDefaults.treemapFontFamily;
$ret.f = DeviceUtils.f(FontDefaults.treemapFontSize);
return $ret;
})());
this.h = ((() => {
let $ret = new FontInfo();
$ret.q = FontDefaults.treemapFontFamily;
$ret.f = DeviceUtils.f(FontDefaults.treemapFontSize);
return $ret;
})());
this.r = null;
this.n = null;
this.a5 = ((() => {
let $ret = new Brush();
$ret.fill = "rgba(0,0,0, 0.0)";
return $ret;
})());
this.f = ((() => {
let $ret = new FontInfo();
$ret.q = FontDefaults.treemapFontFamily;
$ret.f = DeviceUtils.f(FontDefaults.treemapFontSize);
return $ret;
})());
this.e = ((() => {
let $ret = new FontInfo();
$ret.q = FontDefaults.treemapHeaderFontFamily;
$ret.f = DeviceUtils.f(FontDefaults.treemapHeaderFontSize);
return $ret;
})());
this.o = true;
this.b = new TreemapViewRenderer();
this.b.j = ((() => {
let $ret = new Brush();
$ret.fill = "white";
return $ret;
})());
}
ax() {
}
a1() {
this.a0();
}
a2() {
if (!this.p) {
this.p = true;
if (this.ad != null) {
this.ad.setTimeout(runOn(this, this.ag), 0);
}
else {
window.setTimeout(runOn(this, this.ag), 0);
}
}
}
ag() {
if (this.p) {
this.p = false;
this.a.i1();
}
}
q() {
return true;
}
ay() {
this.w = this.a.dg;
this.a2();
}
au(a) {
if (a == null) {
this.af = null;
this.ad = null;
this.m = null;
if (this.ac != null) {
window.removeEventListener("resize", this.ac, false);
this.ac = null;
}
this.ah();
return;
}
this.ad = a;
this.ae = a;
let b = this.ae.rootWrapper.width();
let c = this.ae.rootWrapper.height();
this.ar();
this.w = (isNaN_(this.a.ee) ? this.a.dg : this.a.ee);
let d = this.w;
let e = Math.round(a.rootWrapper.width());
let f = Math.round(a.rootWrapper.height());
let g = e * d;
let h = f * d;
this.ad.rootWrapper.setStyleProperty("position", "relative");
let i = a.createElement("canvas");
i.setStyleProperty("position", "absolute");
this.ad.rootWrapper.append(i);
this.t = b;
this.s = c;
i.setAttribute("width", g.toString());
i.setAttribute("height", h.toString());
i.setStyleProperty("width", e.toString() + "px");
i.setStyleProperty("height", f.toString() + "px");
this.n = i.listen("contextmenu", (j) => j.preventDefault());
this.a.kb = new Rect(0, 0, 0, e, f);
this.af = i;
let j = this.ad.get2DCanvasContext(this.af);
this.m = new RenderingContext(new CanvasViewRenderer(), j);
this.aq();
this.a3();
this.m.ad(this.g);
this.a0();
this.c = new CanvasGestureDOMEventProxy(this.af, this.ad, true);
this.c.ao = (k) => true;
this.c.bl = this.a.kb;
let k = this.c;
k.onMouseOver = delegateCombine(k.onMouseOver, runOn(this, this.am));
let l = this.c;
l.onMouseUp = delegateCombine(l.onMouseUp, runOn(this, this.an));
let m = this.c;
m.onMouseDown = delegateCombine(m.onMouseDown, runOn(this, this.aj));
let n = this.c;
n.onMouseEnter = delegateCombine(n.onMouseEnter, runOn(this, this.ak));
let o = this.c;
o.onMouseLeave = delegateCombine(o.onMouseLeave, runOn(this, this.al));
}
al(a) {
this.a.iq(a);
}
ao(a) {
this.b.e(a, this.r, this);
}
ak(a) {
this.a.ip(a);
}
ar() {
if (this.ac == null) {
this.ac = (a) => {
let b = this.a.ee;
let c = this.a.dg;
if (!isNaN_(b) && b != 0) {
return;
}
if (window.devicePixelRatio != undefined && window.devicePixelRatio != c) {
this.a.dg = window.devicePixelRatio;
}
};
let e_ = this.ac;
window.addEventListener("resize", e_, false);
}
this.ac(null);
}
ah() {
if (this.n != null) {
this.n();
this.n = null;
}
if (this.c != null) {
let a = this.c;
a.onMouseOver = delegateRemove(a.onMouseOver, runOn(this, this.am));
let b = this.c;
b.onMouseUp = delegateRemove(b.onMouseUp, runOn(this, this.an));
let c = this.c;
c.onMouseDown = delegateRemove(c.onMouseDown, runOn(this, this.aj));
let d = this.c;
d.onMouseEnter = delegateRemove(d.onMouseEnter, runOn(this, this.ak));
let e = this.c;
e.onMouseLeave = delegateRemove(e.onMouseLeave, runOn(this, this.al));
this.c.ao = null;
this.c.av();
}
}
aj(a) {
if (this.c.al) {
this.a.iu(a);
}
else {
this.a.io(a);
}
}
an(a) {
if (this.c.al) {
this.a.iv(a);
}
else {
this.a.is(a);
}
}
am(a, b, c) {
this.a.ir(a);
}
aq() {
}
l() {
return this.b.b;
}
a3() {
this.g = FontUtil.getFont(this.ad);
if (this.h != null) {
this.u = this.x(this.h);
}
else {
this.u = this.x(this.g);
}
if (this.i != null) {
this.v = this.x(this.i);
}
else {
this.v = this.x(this.g);
}
this.a4 = new Brush();
this.a4._fill = this.ad.rootWrapper.getStyleProperty("color");
if (this.m != null) {
this.m.ad(this.g);
}
}
as() {
let a = this.ae.rootWrapper.width();
let b = this.ae.rootWrapper.height();
this.a.kb = new Rect(0, 0, 0, a, b);
this.ar();
}
ap() {
if (this.p) {
this.ag();
}
}
a0() {
if (this.m == null) {
return;
}
let a = this.a.kb.width;
let b = this.a.kb.height;
let c = Math.round(a * this.w);
let d = Math.round(b * this.w);
if (this.t != c || this.s != d) {
this.af.setAttribute("width", c.toString());
this.af.setAttribute("height", d.toString());
this.af.setStyleProperty("width", a.toString() + "px");
this.af.setStyleProperty("height", b.toString() + "px");
this.t = truncate(Math.round(c));
this.s = truncate(Math.round(d));
}
if (this.m.d && this.w != 1) {
this.m.aa();
this.m.ab(this.w, this.w);
}
this.b.f(this.m, this.a.kb, this.r, this.u);
if (this.m.d && this.w != 1) {
this.m.z();
}
}
aw(a) {
this.i = a;
if (this.i != null) {
this.v = this.x(this.i);
}
else {
this.v = this.x(this.g);
}
}
az(a) {
this.h = a;
if (this.h != null) {
this.u = this.x(this.h);
}
else {
this.u = this.x(this.g);
}
if (this.i != null) {
this.v = this.x(this.i);
}
else {
this.v = this.x(this.g);
}
}
ai(a) {
this.r = a;
this.a0();
}
ab(a) {
if (a != null) {
if (this.h != null) {
this.m.ad(this.h);
}
else {
this.m.ad(this.f);
}
return this.m.g(a);
}
return 0;
}
z(a) {
if (a != null) {
if (this.i != null) {
this.m.ad(this.i);
}
else {
this.m.ad(this.f);
}
return this.m.g(a);
}
return 0;
}
x(a) {
return FontUtil.getCurrentFontHeight(this.ad, a);
}
aa(a) {
return this.u;
}
y(a) {
return this.v;
}
a7() {
return ((() => {
let $ret = new Brush();
$ret.fill = "rgb(220,220,220)";
return $ret;
})());
}
a9() {
return ((() => {
let $ret = new Brush();
$ret.fill = "rgb(240, 240, 240)";
return $ret;
})());
}
a8() {
return ((() => {
let $ret = new Brush();
$ret.fill = "rgb(102, 102, 102)";
return $ret;
})());
}
bf() {
return this.a5;
}
bb() {
return ((() => {
let $ret = new Brush();
$ret.fill = "black";
return $ret;
})());
}
ba() {
return ((() => {
let $ret = new Brush();
$ret.fill = "rgb(240,240,240)";
return $ret;
})());
}
be() {
return ((() => {
let $ret = new Brush();
$ret.fill = "rgb(240, 240, 240)";
return $ret;
})());
}
a6() {
return ((() => {
let $ret = new Brush();
$ret.fill = "rgb(102, 102, 102)";
return $ret;
})());
}
k() {
return this.f;
}
j() {
return this.e;
}
bc() {
return BrushUtil.h(153, 25, 25, 25);
}
bd() {
return BrushUtil.h(153, 45, 45, 45);
}
at() {
this.o = true;
this.ar();
if (this.c != null) {
this.c.at(this.ad.rootWrapper, "");
}
}
av() {
this.o = false;
if (this.c != null && this.ad != null) {
this.c.bh(this.ad.rootWrapper, "");
}
}
d() {
return new DOMExecutionContext(this.ad);
}
}
TreemapView.$t = markType(TreemapView, 'TreemapView');
return TreemapView;
})();
/**
* @hidden
*/
export let TreemapViewRenderer = /*@__PURE__*/ (() => {
class TreemapViewRenderer extends Base {
constructor() {
super();
this.b = null;
this.c = null;
this.j = null;
this.c = new List$1(TreemapVisual.$, 0);
this.b = ((() => {
let $ret = new Pool$1(TreemapVisual.$);
$ret.create = runOn(this, this.a);
$ret.activate = runOn(this, this.g);
$ret.disactivate = runOn(this, this.i);
$ret.destroy = runOn(this, this.h);
return $ret;
})());
}
a() {
let a = new TreemapVisual();
this.c.add(a);
return a;
}
g(a) {
a.x = 0;
}
i(a) {
a.x = 1;
}
h(a) {
this.c.remove(a);
}
d(a) {
if (a.c.count != 5) {
a.c.add1(new Rectangle());
a.c.add1(new Rectangle());
a.c.add1(new TextBlock());
a.c.add1(new Rectangle());
a.c.add1(new Rectangle());
}
}
f(a, b, c, d) {
a.l(b.left, b.top, b.width, b.height);
if (c != null) {
for (let e = 0; e < c.count; e++) {
let f = c._inner[e];
this.d(f);
let g = f.c._inner[0];
let h = f.c._inner[1];
let i = f.c._inner[2];
let j = f.c._inner[3];
let k = f.c._inner[4];
g._fill = f.l;
g._opacity = f.d;
g.width = f.p.width;
g.height = f.p.height;
g.n = f.p.left;
g.o = f.p.top;
j._fill = f.l;
j.width = !f.q.isEmpty ? f.q.width : 0;
j.height = !f.q.isEmpty ? f.q.height : 0;
j.n = !f.q.isEmpty ? f.q.left : 0;
j.o = !f.q.isEmpty ? f.q.top : 0;
k._fill = null;
k._stroke = f.o;
k.ad = f.i;
k.width = f.p.width;
k.height = f.p.height;
k.n = f.p.left;
k.o = f.p.top;
a.ad(f.a);
let l = a.g(f.j);
if (f.b) {
i.al = f.j;
switch (f.k) {
case 0:
i.n = f.p.left + f.s.left;
break;
case 1:
case 3:
i.n = f.p.left + f.p.width / 2 - f.f / 2;
break;
case 2:
i.n = Math.max(f.p.left + f.s.left, f.p.right - (l + f.s.right));
break;
}
switch (f.t) {
case 0:
i.o = f.p.top + f.s.top;
break;
case 1:
case 3:
i.o = f.p.top + f.p.height / 2 - f.e / 2;
break;
case 2:
i.o = Math.max(f.p.top + f.s.top, f.p.bottom - (d + f.s.bottom));
break;
}
i.ao = f.n;
}
else {
h._fill = f.m;
h._stroke = f.o;
h.ad = f.i;
h.width = f.p.width;
h.height = f.e;
h.n = f.p.left;
h.o = f.p.top;
if (f.w == 0) {
h.width = l + f.r.left + f.r.right;
}
i.n = f.p.left + f.r.left;
i.o = f.p.top + f.r.top;
i.al = f.j;
i.ao = f.n;
}
a.ae(f.h);
if (f.b) {
a.l(g.n, g.o, g.width, g.height);
}
a.w(g);
if (!f.q.isEmpty) {
a.w(j);
}
if (k.ad > 0) {
a.w(k);
}
if (f.u == 0) {
if (!f.b) {
a.w(h);
}
}
a.aa();
a.af(f.p);
if (f.w == 0) {
if (!f.b) {
a.w(h);
}
}
a.x(i);
a.z();
}
}
}
e(a, b, c) {
if (b != null) {
for (let d = 0; d < b.count; d++) {
let e = b._inner[d];
this.d(e);
let f = e.c._inner[0];
let g = e.c._inner[1];
let h = e.c._inner[2];
let i = e.c._inner[3];
let j = e.c._inner[4];
let k = new TreemapNodeVisualData();
k.d = new RectangleVisualData(1, "NodePath", f);
k.d.appearance.stroke = AppearanceHelper.b(j._stroke);
k.d.appearance.strokeExtended = AppearanceHelper.a(j._stroke);
k.d.appearance.strokeThickness = j.ad;
k.b = new RectangleVisualData(1, "HeaderRect", g);
k.c = new RectangleVisualData(1, "HighlightRect", i);
let l = new TreemapLabelVisualData();
l.labelPosition = new PointData(h.n, h.o);
if (e.b) {
l.labelSize = new SizeData(c.ab(h.al), c.aa(h.al));
}
else {
l.labelSize = new SizeData(c.z(h.al), c.y(h.al));
}
l.labelValue = h.al;
l.appearance = AppearanceHelper.c(h, e.a);
k.a = l;
a.nodes.add(k);
}
}
}
}
TreemapViewRenderer.$t = markType(TreemapViewRenderer, 'TreemapViewRenderer');
return TreemapViewRenderer;
})();
/**
* @hidden
*/
export let TreemapLayoutCalculator = /*@__PURE__*/ (() => {
class TreemapLayoutCalculator extends Base {
static c(a, b, c, d) {
let e = a.e();
let f = d.f;
let g = f * f / (b.width * b.height);
if (e / c < g) {
return true;
}
return false;
}
static a(a, b, c, d, e) {
for (let f = 0; f < c.count; f++) {
let g = c._inner[f];
if (!a.contains(g)) {
return false;
}
}
return true;
}
static b(a, b) {
if (a.width < b.f || a.height < b.f) {
return true;
}
return false;
}
h(a, b, c) {
return a.o(b);
}
i(a, b, c) {
let d = a.o(b);
if (d.isEmpty) {
return d;
}
if (b.b != null && b.b.count > 0) {
let e = c.i;
let f = e.left + e.right;
let g = e.top + e.bottom;
let h = a.b(b);
if (!h) {
return d;
}
let i = new Rect(0, d.left - e.left, d.top - e.top, d.width + f, d.height + g);
return i;
}
else {
return d;
}
}
g(a, b, c, d) {
if (b.b != null && b.b.count > 0) {
let e = d.i;
let f = e.left + e.right;
let g = e.top + e.bottom;
if (c.width < f || c.height < g) {
a.m(b, c);
return;
}
let h = new Rect(0, c.left + e.left, c.top + e.top, c.width - f, c.height - g);
a.m(b, h);
a.n(b, true);
}
else {
a.m(b, c);
}
}
f(a, b, c, d, e, f) {
if (!TreemapLayoutCalculator.a(a, b, c, e, f)) {
while (d > 0) {
let g = 0;
for (let h of fromEnum(c)) {
if (a.contains(h)) {
continue;
}
if (d > 0) {
let i = (d > 1) ? 1 : d;
let j = this.i(b, h, f);
if (j.isEmpty) {
continue;
}
this.g(b, h, new Rect(0, j.x + g, j.y, j.width + i, j.height), f);
d -= i;
g += i;
}
else {
let k = this.i(b, h, f);
if (k.isEmpty) {
continue;
}
this.g(b, h, new Rect(0, k.x + g, k.y, k.width, k.height), f);
}
}
}
}
}
e(a, b, c, d, e, f) {
if (!TreemapLayoutCalculator.a(a, b, c, e, f)) {
while (d > 0) {
let g = 0;
for (let h of fromEnum(c)) {
if (a.contains(h)) {
continue;
}
if (d > 0) {
let i = (d > 1) ? 1 : d;
let j = this.i(b, h, f);
if (j.isEmpty) {
continue;
}
this.g(b, h, new Rect(0, j.x, j.y + g, j.width, j.height + i), f);
d -= i;
g += i;
}
else {
let k = this.i(b, h, f);
if (k.isEmpty) {
continue;
}
this.g(b, h, new Rect(0, k.x, k.y + g, k.width, k.height), f);
}
}
}
}
}
}
TreemapLayoutCalculator.$t = markType(TreemapLayoutCalculator, 'TreemapLayoutCalculator');
return TreemapLayoutCalculator;
})();
/**
* @hidden
*/
export let StrippedCalculator = /*@__PURE__*/ (() => {
class StrippedCalculator extends TreemapLayoutCalculator {
d(a, b) {
a.g();
this.o(a, b.b.a, b.h, b, 0);
}
q(a, b, c) {
return c.j;
}
o(a, b, c, d, e) {
if (d.g >= 0 && e > d.g) {
return;
}
if (b == d.c) {
d.d = true;
this.g(a, b, c, d);
let f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
c = f;
}
if (!d.d) {
for (let g of fromEnum(b.b)) {
this.o(a, g, c, d, e + 1);
}
return;
}
let h = this.q(b, c, d);
let i = h.left + h.right;
let j = h.top + h.bottom;
let k = new Rect(0, c.left, c.top, c.width, c.height);
let l = d.a;
if (i >= k.width || j >= k.height) {
return;
}
k.x = k.x + h.left;
k.width = k.width - i;
k.y = k.y + h.top;
k.height = k.height - j;
let m = new HashSet$1(TreemapTreeNode.$, 0);
StrippedCalculator.p(m, d, b.b, k);
let n = 0;
for (let o = 0; o < b.b.count; o++) {
let p = b.b._inner[o];
if (!m.contains(p)) {
n += p.e();
}
}
let q = n;
let r = (k.width * k.height) / q;
let s = l == 0 ? k.width : k.height;
let t = new List$1(TreemapTreeNode.$, 0);
let u = new List$1(TreemapTreeNode.$, 0);
for (let v = 0; v < b.b.count; v++) {
let w = b.b._inner[v];
if (m.contains(w) || isNaN_(w.e())) {
continue;
}
let x = StrippedCalculator.j(u, s, r);
u.add(w);
let y = StrippedCalculator.j(u, s, r);
if (x < y) {
if (t.count > 0) {
let z = this.m(m, a, d, t, r, k, l, false);
k = z.p5;
}
u.removeAt(u.count - 1);
t.o(u);
u.clear();
u.add(w);
}
}
let aa = StrippedCalculator.j(t, s, r);
let ab = StrippedCalculator.j(u, s, r);
let ac = new List$1(TreemapTreeNode.$, 0);
ac.o(t);
ac.o(u);
let ad = StrippedCalculator.j(ac, s, r);
if (ad < (aa + ab) / 2 || k.height < d.f * 2) {
let ae = this.m(m, a, d, ac, r, k, l, true);
k = ae.p5;
}
else {
let af = this.m(m, a, d, t, r, k, l, false);
k = af.p5;
let ag = this.m(m, a, d, u, r, k, l, true);
k = ag.p5;
}
for (let ah = 0; ah < b.b.count; ah++) {
let ai = b.b._inner[ah];
if (m.contains(ai)) {
continue;
}
let aj = this.h(a, ai, d);
if (aj.isEmpty) {
continue;
}
let ak = new Rect(0, aj.left, aj.top + d.e, aj.width, Math.max(aj.height - d.e, 0));
this.o(a, ai, ak, d, e + 1);
}
if (b == d.c) {
d.d = false;
}
}
m(a, b, c, d, e, f, g, h) {
if (d.count == 0) {
return {
p5: f
};
}
if (g == 0) {
let i = this.l(a, b, c, d, e, f, h);
f = i.p5;
}
else {
let j = this.n(a, b, c, d, e, f, h);
f = j.p5;
}
return {
p5: f
};
}
l(a, b, c, d, e, f, g) {
let h = StrippedCalculator.k(d);
if (h <= 0) {
return {
p5: f
};
}
let i = f.width;
let j = (h * e) / i;
let k = f.x;
let l = 0;
for (let m = 0; m < d.count; ++m) {
let n = d._inner[m];
let o = Math.floor((n.e() / h) * i);
let p = new Rect(0, k, f.y, o, j);
if (TreemapLayoutCalculator.b(p, c)) {
a.add_1(n);
}
else {
l = p.right;
this.g(b, n, p, c);
}
if (a.contains(n)) {
h -= n.e();
}
else {
k += o;
}
}
this.f(a, b, d, f.right - k, f, c);
f.y = f.y + j;
if (f.height < j) {
f.height = 0;
}
else {
f.height = f.height - j;
}
d.clear();
return {
p5: f
};
}
n(a, b, c, d, e, f, g) {
let h = StrippedCalculator.k(d);
if (h <= 0) {
return {
p5: f
};
}
let i = f.height;
let j = (h * e) / i;
let k = f.y;
let l = 0;
for (let m = 0; m < d.count; ++m) {
let n = d._inner[m];
let o = Math.floor((n.e() / h) * i);
let p = new Rect(0, f.x, k, j, o);
if (TreemapLayoutCalculator.b(p, c)) {
a.add_1(n);
}
else {
l = p.bottom;
this.g(b, n, p, c);
}
if (a.contains(n)) {
h -= n.e();
}
else {
k += o;
}
}
this.e(a, b, d, f.bottom - k, f, c);
f.x = f.x + j;
if (f.width < j) {
f.width = 0;
}
else {
f.width = f.width - j;
}
d.clear();
return {
p5: f
};
}
static j(a, b, c) {
if (a.count == 0) {
return 1.7976931348623157E+308;
}
let d = StrippedCalculator.k(a);
let e = (d * c) / b;
let f = 0;
for (let g = 0; g < a.count; g++) {
let h = a._inner[g];
let i = (h.e() / d) * b;
f += Math.max(i / e, e / i);
}
f /= a.count;
return f;
}
static k(a) {
let b = 0;
for (let c = 0; c < a.count; c++) {
let d = a._inner[c];
b += d.e();
}
return b;
}
static p(a, b, c, d) {
let e = 0;
for (let f = 0; f < c.count; f++) {
let g = c._inner[f];
}
let h = e;
let i = b.f * b.f / (d.width * d.height);
for (let j = 0; j < c.count; j++) {
let k = c._inner[j];
if (k.e() / h < i) {
a.add_1(k);
}
}
}
}
StrippedCalculator.$t = markType(StrippedCalculator, 'StrippedCalculator', TreemapLayoutCalculator.$);
return StrippedCalculator;
})();
/**
* @hidden
*/
export let SliceAndDiceCalculator = /*@__PURE__*/ (() => {
class SliceAndDiceCalculator extends TreemapLayoutCalculator {
d(a, b) {
a.g();
this.m(a, b.b.a, b.h, b, 0);
}
o(a, b, c) {
return c.j;
}
m(a, b, c, d, e) {
if (d.g >= 0 && e > d.g) {
return;
}
if (b == d.c) {
d.d = true;
this.g(a, b, c, d);
let f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
c = f;
}
if (!d.d) {
for (let g of fromEnum(b.b)) {
this.m(a, g, c, d, e + 1);
}
return;
}
let h = this.o(b, c, d);
let i = SliceAndDiceCalculator.j(b, d, e);
let j = h.left + h.right;
let k = h.top + h.bottom;
let l = new Rect(0, c.left, c.top, c.width, c.height);
if (j >= l.width || k >= l.height) {
return;
}
l.x = l.x + h.left;
l.width = l.width - j;
l.y = l.y + h.top;
l.height = l.height - k;
let m = new Size(1, l.width, l.height);
let n = l.left;
let o = l.top;
let p = new HashSet$1(TreemapTreeNode.$, 0);
let q = SliceAndDiceCalculator.k(b.b, b, d, m, p);
if (q) {
SliceAndDiceCalculator.n(b.b, b, d, m, p);
}
let r = 0;
for (let s = 0; s < b.b.count; s++) {
let t = b.b._inner[s];
if (!p.contains(t)) {
r += t.e();
}
}
let u = (i == 0) ? m.height : m.width;
let v = new Rect(4);
for (let w = 0; w < b.b.count; w++) {
let x = b.b._inner[w];
if (p.contains(x) || isNaN_(x.e())) {
continue;
}
if (r <= 0 || u <= 0) {
break;
}
let y = x.e() / r;
v.x = n;
v.y = o;
if (i == 0) {
v.width = m.width;
v.height = Math.round(u * y);
}
else {
v.width = Math.round(u * y);
v.height = m.height;
}
this.g(a, x, new Rect(0, v.left, v.top, v.width, v.height), d);
if (i == 0) {
o += v.height;
u -= v.height;
}
else {
n += v.width;
u -= v.width;
}
r -= x.e();
let z = this.h(a, x, d);
if (z.isEmpty) {
continue;
}
let aa = new Rect(0, z.left, z.top + d.e, z.width, Math.max(z.height - d.e, 0));
this.m(a, x, aa, d, e + 1);
}
if (b == d.c) {
d.d = false;
}
}
static j(a, b, c) {
let d = 0;
if (b.a == 0) {
d = (c % 2 == 0) ? 0 : 1;
}
else {
d = (c % 2 == 0) ? 1 : 0;
}
return d;
}
static k(a, b, c, d, e) {
let f = true;
let g = b.e();
let h = Math.min(d.width, d.height);
for (let i = 0; i < a.count; i++) {
let j = a._inner[i];
if (Math.round(j.e() / g * h) < c.f) {
if (!e.contains(j)) {
e.add_1(j);
}
}
else {
f = false;
}
}
return f;
}
static n(a, b, c, d, e) {
let f = new List$1(TreemapTreeNode.$, 0);
f.o(a);
f.aa((g, h) => {
if (g.e() > h.e()) {
return 1;
}
else if (g.e() < h.e()) {
return -1;
}
return 0;
});
let g = 0;
let h = Math.min(d.width, d.height);
for (let i = 0; i < f.count; i++) {
let j = f._inner[i];
if (isNaN_(j.e())) {
continue;
}
g += j.e();
if (j.e() / g * h < c.f) {
break;
}
else {
if (e.contains(j)) {
e.remove(j);
}
}
}
}
}
SliceAndDiceCalculator.$t = markType(SliceAndDiceCalculator, 'SliceAndDiceCalculator', TreemapLayoutCalculator.$);
SliceAndDiceCalculator.l = null;
return SliceAndDiceCalculator;
})();
/**
* @hidden
*/
export let TreemapLayoutSettings = /*@__PURE__*/ (() => {
class TreemapLayoutSettings extends Base {
constructor() {
super();
this.a = 0;
this.h = null;
this.b = null;
this.j = null;
this.i = null;
this.e = 0;
this.f = 0;
this.g = 0;
this.c = null;
this.d = false;
this.g = -1;
this.d = false;
}
}
TreemapLayoutSettings.$t = markType(TreemapLayoutSettings, 'TreemapLayoutSettings');
return TreemapLayoutSettings;
})();
/**
* @hidden
*/
export let SquarifiedCalculator = /*@__PURE__*/ (() => {
class SquarifiedCalculator extends TreemapLayoutCalculator {
n(a, b, c, d, e) {
if (d.g >= 0 && e > d.g) {
return;
}
if (b == d.c) {
d.d = true;
this.g(a, b, c, d);
let f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
c = f;
}
if (!d.d) {
for (let g of fromEnum(b.b)) {
this.n(a, g, c, d, e + 1);
}
return;
}
let h = this.o(b, c, d);
let i = new Rect(0, c.left, c.top, c.width, c.height);
let j = h.left + h.right;
let k = h.top + h.bottom;
if (j >= i.width || k >= i.height) {
return;
}
i.x = i.x + h.left;
i.width = i.width - j;
i.y = i.y + h.top;
i.height = i.height - k;
let l = i.left;
let m = i.top;
let n = new List$1(TreemapTreeNode.$, 0);
let o = b.e();
let p = new Rect(0, i.left, i.top, i.width, i.height);
let q = (i.width * i.height) / o;
let r = new List$1(TreemapTreeNode.$, 1, b.b);
r.aa((s, t) => {
if (t.e() < s.e()) {
return -1;
}
if (t.e() > s.e()) {
return 1;
}
return 0;
});
let s = new AreaInfo();
s.b = i;
s.a = o;
let t = new HashSet$1(TreemapTreeNode.$, 0);
for (let u of fromEnum(r)) {
if (TreemapLayoutCalculator.c(u, p, o, d) || isNaN_(u.e())) {
t.add_1(u);
continue;
}
let v = Math.min(i.width, i.height);
let w = SquarifiedCalculator.j(n, v, q);
n.add(u);
let x = SquarifiedCalculator.j(n, v, q);
if (w <= x) {
n.removeAt(n.count - 1);
this.l(t, a, n, s, d);
i = s.b;
n.add(u);
}
}
this.l(t, a, n, s, d);
i = s.b;
for (let y of fromEnum(b.b)) {
if (t.contains(y)) {
continue;
}
let z = this.h(a, y, d);
if (z.isEmpty) {
continue;
}
let aa = new Rect(0, z.left, z.top + d.e, z.width, Math.max(z.height - d.e, 0));
this.n(a, y, aa, d, e + 1);
}
if (b == d.c) {
d.d = false;
}
}
o(a, b, c) {
return c.j;
}
static j(a, b, c) {
if (a.count == 0) {
return 1.7976931348623157E+308;
}
let d = 0;
let e = 1.7976931348623157E+308;
let f = -1.7976931348623157E+308;
for (let g of fromEnum(a)) {
let h = g.e() * c;
if (e > h) {
e = h;
}
if (f < h) {
f = h;
}
d += h;
}
let i = (b * b * f) / (d * d);
let j = (d * d) / (b * b * e);
return Math.max(i, j);
}
l(a, b, c, d, e) {
if (c.count < 1) {
return;
}
let f = 0;
for (let g = 0; g < c.count; ++g) {
f += c._inner[g].e();
}
if (f <= 0) {
return;
}
if (d.b.width > d.b.height) {
this.k(a, b, c, f, d, e);
}
else {
this.m(a, b, c, f, d, e);
}
}
m(a, b, c, d, e, f) {
let g = e.b;
let h = e.a;
let i = Math.round((d / h) * g.height);
let j = g.x;
for (let k = 0; k < c.count; ++k) {
let l = c._inner[k];
if (g.right < j) {
a.add_1(l);
continue;
}
let m = Math.floor((l.e() / d) * g.width);
let n = new Rect(0, j, g.y, m, i);
if (TreemapLayoutCalculator.b(n, f)) {
a.add_1(l);
continue;
}
this.g(b, l, n, f);
j += n.width;
}
this.f(a, b, c, g.right - j, g, f);
g.y = g.y + i;
if (g.height < i) {
g.height = 0;
}
else {
g.height = g.height - i;
}
h -= d;
e.a = h;
e.b = g;
c.clear();
}
k(a, b, c, d, e, f) {
let g = e.b;
let h = e.a;
let i = Math.round((d / h) * g.width);
let j = g.y;
for (let k = 0; k < c.count; ++k) {
let l = c._inner[k];
if (g.bottom < j) {
a.add_1(l);
continue;
}
let m = Math.floor((l.e() / d) * g.height);
let n = new Rect(0, g.x, j, i, m);
if (TreemapLayoutCalculator.b(n, f)) {
a.add_1(l);
continue;
}
this.g(b, l, n, f);
j += n.height;
}
this.e(a, b, c, g.bottom - j, g, f);
g.x = g.x + i;
if (g.width < i) {
g.width = 0;
}
else {
g.width = g.width - i;
}
h -= d;
e.a = h;
e.b = g;
c.clear();
}
d(a, b) {
a.g();
this.n(a, b.b.a, b.h, b, 0);
}
}
SquarifiedCalculator.$t = markType(SquarifiedCalculator, 'SquarifiedCalculator', TreemapLayoutCalculator.$);
return SquarifiedCalculator;
})();
/**
* @hidden
*/
export let TreemapTreeData = /*@__PURE__*/ (() => {
class TreemapTreeData extends Base {
constructor() {
super();
this.a = null;
this.b = null;
this.d = null;
this.c = null;
this.b = new Dictionary$2(String_$type, TreemapTreeNode.$, 0);
this.d = new List$1(String_$type, 0);
this.c = new Dictionary$2(String_$type, List$1.$.specialize(TreemapTreeNode.$), 0);
this.a = new TreemapTreeNode();
}
e(a) {
this.b.addItem(a.l, a);
this.d.add(a.l);
if (a.n == null) {
this.a.b.add(a);
}
else if (this.b.containsKey(a.n)) {