igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
1,540 lines • 178 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 { __extends, __values } from "tslib";
import { HighlightingManager } from "igniteui-react-core";
import { Base, markType, runOn, delegateCombine, delegateRemove, fromEnum, String_$type, INotifyPropertyChanged_$type, PropertyChangedEventArgs, EventArgs, fromEn, EnumUtil, enumGetBox, typeGetValue, Point_$type } from "igniteui-react-core";
import { TreemapHighlightingMode_$type } from "./TreemapHighlightingMode";
import { RenderingContext } from "igniteui-react-core";
import { FontInfo } from "igniteui-react-core";
import { FontDefaults } from "igniteui-react-core";
import { DeviceUtils } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { CanvasViewRenderer } from "igniteui-react-core";
import { CanvasGestureDOMEventProxy } from "igniteui-react-core";
import { TreemapVisualData } from "./TreemapVisualData";
import { List$1 } from "igniteui-react-core";
import { TreemapVisual } from "./TreemapVisual";
import { Pool$1 } from "igniteui-react-core";
import { FontUtil } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { DOMExecutionContext } from "igniteui-react-core";
import { truncate, isNaN_, logBase } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { TextBlock } from "igniteui-react-core";
import { HorizontalAlignment_$type } from "igniteui-react-core";
import { VerticalAlignment_$type } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { TreemapNodeVisualData } from "./TreemapNodeVisualData";
import { TreemapLabelVisualData } from "./TreemapLabelVisualData";
import { RectangleVisualData } from "igniteui-react-core";
import { AppearanceHelper } from "igniteui-react-core";
import { PointData } from "igniteui-react-core";
import { SizeData } from "igniteui-react-core";
import { HashSet$1 } from "igniteui-react-core";
import { TreemapOrientation_$type } from "./TreemapOrientation";
import { Size } from "igniteui-react-core";
import { AreaInfo } from "./AreaInfo";
import { Dictionary$2 } from "igniteui-react-core";
import { DoubleAnimator } from "igniteui-react-core";
import { TreemapHighlightedValueDisplayMode_$type } from "./TreemapHighlightedValueDisplayMode";
import { BrushCollection } from "igniteui-react-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-react-core";
import { HighlightingInfo } from "igniteui-react-core";
import { EasingFunctions } from "igniteui-react-core";
import { NotifyCollectionChangedEventArgs } from "igniteui-react-core";
import { ObservableCollection$1 } from "igniteui-react-core";
import { RectData } from "igniteui-react-core";
import { TreemapNodeVisualDataList } from "./TreemapNodeVisualDataList";
import { BrushCollectionUtil } from "igniteui-react-core";
import { TreemapValueMappingMode_$type } from "./TreemapValueMappingMode";
import { TreemapNodePointerEventArgs } from "./TreemapNodePointerEventArgs";
import { TreemapNodeStyleMappingTargetType_$type } from "./TreemapNodeStyleMappingTargetType";
import { stringIsNullOrEmpty, stringReplace } from "igniteui-react-core";
/**
* @hidden
*/
var TreemapHighlightingManager = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TreemapHighlightingManager, _super);
function TreemapHighlightingManager() {
return _super !== null && _super.apply(this, arguments) || this;
}
TreemapHighlightingManager.prototype.isCrossContextHighlight = function (a) {
var b = a;
return b.au == 3;
};
TreemapHighlightingManager.$t = markType(TreemapHighlightingManager, 'TreemapHighlightingManager', HighlightingManager.$);
return TreemapHighlightingManager;
}(HighlightingManager));
export { TreemapHighlightingManager };
/**
* @hidden
*/
var TreemapView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TreemapView, _super);
function TreemapView() {
var _this = _super.call(this) || this;
_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 = ((function () {
var $ret = new FontInfo();
$ret.q = FontDefaults.treemapFontFamily;
$ret.f = DeviceUtils.f(FontDefaults.treemapFontSize);
return $ret;
})());
_this.h = ((function () {
var $ret = new FontInfo();
$ret.q = FontDefaults.treemapFontFamily;
$ret.f = DeviceUtils.f(FontDefaults.treemapFontSize);
return $ret;
})());
_this.r = null;
_this.n = null;
_this.a5 = ((function () {
var $ret = new Brush();
$ret.fill = "rgba(0,0,0, 0.0)";
return $ret;
})());
_this.f = ((function () {
var $ret = new FontInfo();
$ret.q = FontDefaults.treemapFontFamily;
$ret.f = DeviceUtils.f(FontDefaults.treemapFontSize);
return $ret;
})());
_this.e = ((function () {
var $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 = ((function () {
var $ret = new Brush();
$ret.fill = "white";
return $ret;
})());
return _this;
}
TreemapView.prototype.ax = function () {
};
TreemapView.prototype.a1 = function () {
this.a0();
};
TreemapView.prototype.a2 = function () {
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);
}
}
};
TreemapView.prototype.ag = function () {
if (this.p) {
this.p = false;
this.a.i1();
}
};
TreemapView.prototype.q = function () {
return true;
};
TreemapView.prototype.ay = function () {
this.w = this.a.dg;
this.a2();
};
TreemapView.prototype.au = function (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;
var b = this.ae.rootWrapper.width();
var c = this.ae.rootWrapper.height();
this.ar();
this.w = (isNaN_(this.a.ee) ? this.a.dg : this.a.ee);
var d = this.w;
var e = Math.round(a.rootWrapper.width());
var f = Math.round(a.rootWrapper.height());
var g = e * d;
var h = f * d;
this.ad.rootWrapper.setStyleProperty("position", "relative");
var 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", function (j) { return j.preventDefault(); });
this.a.kb = new Rect(0, 0, 0, e, f);
this.af = i;
var j = this.ad.get2DCanvasContext(this.af);
this.m = new RenderingContext(new CanvasViewRenderer(), j);
this.aq();
this.a3();
this.m.ae(this.g);
this.a0();
this.c = new CanvasGestureDOMEventProxy(this.af, this.ad, true);
this.c.ao = function (k) { return true; };
this.c.bl = this.a.kb;
var k = this.c;
k.onMouseOver = delegateCombine(k.onMouseOver, runOn(this, this.am));
var l = this.c;
l.onMouseUp = delegateCombine(l.onMouseUp, runOn(this, this.an));
var m = this.c;
m.onMouseDown = delegateCombine(m.onMouseDown, runOn(this, this.aj));
var n = this.c;
n.onMouseEnter = delegateCombine(n.onMouseEnter, runOn(this, this.ak));
var o = this.c;
o.onMouseLeave = delegateCombine(o.onMouseLeave, runOn(this, this.al));
};
TreemapView.prototype.al = function (a) {
this.a.iq(a);
};
TreemapView.prototype.ao = function (a) {
this.b.e(a, this.r, this);
};
TreemapView.prototype.ak = function (a) {
this.a.ip(a);
};
TreemapView.prototype.ar = function () {
var _this = this;
if (this.ac == null) {
this.ac = function (a) {
var b = _this.a.ee;
var c = _this.a.dg;
if (!isNaN_(b) && b != 0) {
return;
}
if (window.devicePixelRatio != undefined && window.devicePixelRatio != c) {
_this.a.dg = window.devicePixelRatio;
}
};
var e_ = this.ac;
window.addEventListener("resize", e_, false);
}
this.ac(null);
};
TreemapView.prototype.ah = function () {
if (this.n != null) {
this.n();
this.n = null;
}
if (this.c != null) {
var a = this.c;
a.onMouseOver = delegateRemove(a.onMouseOver, runOn(this, this.am));
var b = this.c;
b.onMouseUp = delegateRemove(b.onMouseUp, runOn(this, this.an));
var c = this.c;
c.onMouseDown = delegateRemove(c.onMouseDown, runOn(this, this.aj));
var d = this.c;
d.onMouseEnter = delegateRemove(d.onMouseEnter, runOn(this, this.ak));
var e = this.c;
e.onMouseLeave = delegateRemove(e.onMouseLeave, runOn(this, this.al));
this.c.ao = null;
this.c.av();
}
};
TreemapView.prototype.aj = function (a) {
if (this.c.al) {
this.a.iu(a);
}
else {
this.a.io(a);
}
};
TreemapView.prototype.an = function (a) {
if (this.c.al) {
this.a.iv(a);
}
else {
this.a.is(a);
}
};
TreemapView.prototype.am = function (a, b, c) {
this.a.ir(a);
};
TreemapView.prototype.aq = function () {
};
TreemapView.prototype.l = function () {
return this.b.b;
};
TreemapView.prototype.a3 = function () {
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.ae(this.g);
}
};
TreemapView.prototype.as = function () {
var a = this.ae.rootWrapper.width();
var b = this.ae.rootWrapper.height();
this.a.kb = new Rect(0, 0, 0, a, b);
this.ar();
};
TreemapView.prototype.ap = function () {
if (this.p) {
this.ag();
}
};
TreemapView.prototype.a0 = function () {
if (this.m == null) {
return;
}
var a = this.a.kb.width;
var b = this.a.kb.height;
var c = Math.round(a * this.w);
var 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();
}
};
TreemapView.prototype.aw = function (a) {
this.i = a;
if (this.i != null) {
this.v = this.x(this.i);
}
else {
this.v = this.x(this.g);
}
};
TreemapView.prototype.az = function (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);
}
};
TreemapView.prototype.ai = function (a) {
this.r = a;
this.a0();
};
TreemapView.prototype.ab = function (a) {
if (a != null) {
if (this.h != null) {
this.m.ae(this.h);
}
else {
this.m.ae(this.f);
}
return this.m.g(a);
}
return 0;
};
TreemapView.prototype.z = function (a) {
if (a != null) {
if (this.i != null) {
this.m.ae(this.i);
}
else {
this.m.ae(this.f);
}
return this.m.g(a);
}
return 0;
};
TreemapView.prototype.x = function (a) {
return FontUtil.getCurrentFontHeight(this.ad, a);
};
TreemapView.prototype.aa = function (a) {
return this.u;
};
TreemapView.prototype.y = function (a) {
return this.v;
};
TreemapView.prototype.a7 = function () {
return ((function () {
var $ret = new Brush();
$ret.fill = "rgb(220,220,220)";
return $ret;
})());
};
TreemapView.prototype.a9 = function () {
return ((function () {
var $ret = new Brush();
$ret.fill = "rgb(240, 240, 240)";
return $ret;
})());
};
TreemapView.prototype.a8 = function () {
return ((function () {
var $ret = new Brush();
$ret.fill = "rgb(102, 102, 102)";
return $ret;
})());
};
TreemapView.prototype.bf = function () {
return this.a5;
};
TreemapView.prototype.bb = function () {
return ((function () {
var $ret = new Brush();
$ret.fill = "black";
return $ret;
})());
};
TreemapView.prototype.ba = function () {
return ((function () {
var $ret = new Brush();
$ret.fill = "rgb(240,240,240)";
return $ret;
})());
};
TreemapView.prototype.be = function () {
return ((function () {
var $ret = new Brush();
$ret.fill = "rgb(240, 240, 240)";
return $ret;
})());
};
TreemapView.prototype.a6 = function () {
return ((function () {
var $ret = new Brush();
$ret.fill = "rgb(102, 102, 102)";
return $ret;
})());
};
TreemapView.prototype.k = function () {
return this.f;
};
TreemapView.prototype.j = function () {
return this.e;
};
TreemapView.prototype.bc = function () {
return BrushUtil.j(153, 25, 25, 25);
};
TreemapView.prototype.bd = function () {
return BrushUtil.j(153, 45, 45, 45);
};
TreemapView.prototype.at = function () {
this.o = true;
this.ar();
if (this.c != null) {
this.c.at(this.ad.rootWrapper, "");
}
};
TreemapView.prototype.av = function () {
this.o = false;
if (this.c != null && this.ad != null) {
this.c.bh(this.ad.rootWrapper, "");
}
};
TreemapView.prototype.d = function () {
return new DOMExecutionContext(this.ad);
};
TreemapView.$t = markType(TreemapView, 'TreemapView');
return TreemapView;
}(Base));
export { TreemapView };
/**
* @hidden
*/
var TreemapViewRenderer = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TreemapViewRenderer, _super);
function TreemapViewRenderer() {
var _this = _super.call(this) || this;
_this.b = null;
_this.c = null;
_this.j = null;
_this.c = new List$1(TreemapVisual.$, 0);
_this.b = ((function () {
var $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;
})());
return _this;
}
TreemapViewRenderer.prototype.a = function () {
var a = new TreemapVisual();
this.c.add(a);
return a;
};
TreemapViewRenderer.prototype.g = function (a) {
a.x = 0;
};
TreemapViewRenderer.prototype.i = function (a) {
a.x = 1;
};
TreemapViewRenderer.prototype.h = function (a) {
this.c.remove(a);
};
TreemapViewRenderer.prototype.d = function (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());
}
};
TreemapViewRenderer.prototype.f = function (a, b, c, d) {
a.l(b.left, b.top, b.width, b.height);
if (c != null) {
for (var e = 0; e < c.count; e++) {
var f = c._inner[e];
this.d(f);
var g = f.c._inner[0];
var h = f.c._inner[1];
var i = f.c._inner[2];
var j = f.c._inner[3];
var 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.ae(f.a);
var 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.af(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.ag(f.p);
if (f.w == 0) {
if (!f.b) {
a.w(h);
}
}
a.x(i);
a.z();
}
}
};
TreemapViewRenderer.prototype.e = function (a, b, c) {
if (b != null) {
for (var d = 0; d < b.count; d++) {
var e = b._inner[d];
this.d(e);
var f = e.c._inner[0];
var g = e.c._inner[1];
var h = e.c._inner[2];
var i = e.c._inner[3];
var j = e.c._inner[4];
var 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);
var 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;
}(Base));
export { TreemapViewRenderer };
/**
* @hidden
*/
var TreemapLayoutCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TreemapLayoutCalculator, _super);
function TreemapLayoutCalculator() {
return _super !== null && _super.apply(this, arguments) || this;
}
TreemapLayoutCalculator.c = function (a, b, c, d) {
var e = a.e();
var f = d.f;
var g = f * f / (b.width * b.height);
if (e / c < g) {
return true;
}
return false;
};
TreemapLayoutCalculator.a = function (a, b, c, d, e) {
for (var f = 0; f < c.count; f++) {
var g = c._inner[f];
if (!a.contains(g)) {
return false;
}
}
return true;
};
TreemapLayoutCalculator.b = function (a, b) {
if (a.width < b.f || a.height < b.f) {
return true;
}
return false;
};
TreemapLayoutCalculator.prototype.h = function (a, b, c) {
return a.o(b);
};
TreemapLayoutCalculator.prototype.i = function (a, b, c) {
var d = a.o(b);
if (d.isEmpty) {
return d;
}
if (b.b != null && b.b.count > 0) {
var e = c.i;
var f = e.left + e.right;
var g = e.top + e.bottom;
var h = a.b(b);
if (!h) {
return d;
}
var i = new Rect(0, d.left - e.left, d.top - e.top, d.width + f, d.height + g);
return i;
}
else {
return d;
}
};
TreemapLayoutCalculator.prototype.g = function (a, b, c, d) {
if (b.b != null && b.b.count > 0) {
var e = d.i;
var f = e.left + e.right;
var g = e.top + e.bottom;
if (c.width < f || c.height < g) {
a.m(b, c);
return;
}
var 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);
}
};
TreemapLayoutCalculator.prototype.f = function (a, b, c, d, e, f) {
var e_1, _a;
if (!TreemapLayoutCalculator.a(a, b, c, e, f)) {
while (d > 0) {
var g = 0;
try {
for (var _b = (e_1 = void 0, __values(fromEnum(c))), _c = _b.next(); !_c.done; _c = _b.next()) {
var h = _c.value;
if (a.contains(h)) {
continue;
}
if (d > 0) {
var i = (d > 1) ? 1 : d;
var 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 {
var 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);
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
}
}
};
TreemapLayoutCalculator.prototype.e = function (a, b, c, d, e, f) {
var e_2, _a;
if (!TreemapLayoutCalculator.a(a, b, c, e, f)) {
while (d > 0) {
var g = 0;
try {
for (var _b = (e_2 = void 0, __values(fromEnum(c))), _c = _b.next(); !_c.done; _c = _b.next()) {
var h = _c.value;
if (a.contains(h)) {
continue;
}
if (d > 0) {
var i = (d > 1) ? 1 : d;
var 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 {
var 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);
}
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_2)
throw e_2.error;
}
}
}
}
};
TreemapLayoutCalculator.$t = markType(TreemapLayoutCalculator, 'TreemapLayoutCalculator');
return TreemapLayoutCalculator;
}(Base));
export { TreemapLayoutCalculator };
/**
* @hidden
*/
var StrippedCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(StrippedCalculator, _super);
function StrippedCalculator() {
return _super !== null && _super.apply(this, arguments) || this;
}
StrippedCalculator.prototype.d = function (a, b) {
a.g();
this.o(a, b.b.a, b.h, b, 0);
};
StrippedCalculator.prototype.q = function (a, b, c) {
return c.j;
};
StrippedCalculator.prototype.o = function (a, b, c, d, e) {
var e_3, _a;
if (d.g >= 0 && e > d.g) {
return;
}
if (b == d.c) {
d.d = true;
this.g(a, b, c, d);
var f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
c = f;
}
if (!d.d) {
try {
for (var _b = __values(fromEnum(b.b)), _c = _b.next(); !_c.done; _c = _b.next()) {
var g = _c.value;
this.o(a, g, c, d, e + 1);
}
}
catch (e_3_1) {
e_3 = { error: e_3_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_3)
throw e_3.error;
}
}
return;
}
var h = this.q(b, c, d);
var i = h.left + h.right;
var j = h.top + h.bottom;
var k = new Rect(0, c.left, c.top, c.width, c.height);
var 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;
var m = new HashSet$1(TreemapTreeNode.$, 0);
StrippedCalculator.p(m, d, b.b, k);
var n = 0;
for (var o = 0; o < b.b.count; o++) {
var p = b.b._inner[o];
if (!m.contains(p)) {
n += p.e();
}
}
var q = n;
var r = (k.width * k.height) / q;
var s = l == 0 ? k.width : k.height;
var t = new List$1(TreemapTreeNode.$, 0);
var u = new List$1(TreemapTreeNode.$, 0);
for (var v = 0; v < b.b.count; v++) {
var w = b.b._inner[v];
if (m.contains(w) || isNaN_(w.e())) {
continue;
}
var x = StrippedCalculator.j(u, s, r);
u.add(w);
var y = StrippedCalculator.j(u, s, r);
if (x < y) {
if (t.count > 0) {
var 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);
}
}
var aa = StrippedCalculator.j(t, s, r);
var ab = StrippedCalculator.j(u, s, r);
var ac = new List$1(TreemapTreeNode.$, 0);
ac.o(t);
ac.o(u);
var ad = StrippedCalculator.j(ac, s, r);
if (ad < (aa + ab) / 2 || k.height < d.f * 2) {
var ae = this.m(m, a, d, ac, r, k, l, true);
k = ae.p5;
}
else {
var af = this.m(m, a, d, t, r, k, l, false);
k = af.p5;
var ag = this.m(m, a, d, u, r, k, l, true);
k = ag.p5;
}
for (var ah = 0; ah < b.b.count; ah++) {
var ai = b.b._inner[ah];
if (m.contains(ai)) {
continue;
}
var aj = this.h(a, ai, d);
if (aj.isEmpty) {
continue;
}
var 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;
}
};
StrippedCalculator.prototype.m = function (a, b, c, d, e, f, g, h) {
if (d.count == 0) {
return {
p5: f
};
}
if (g == 0) {
var i = this.l(a, b, c, d, e, f, h);
f = i.p5;
}
else {
var j = this.n(a, b, c, d, e, f, h);
f = j.p5;
}
return {
p5: f
};
};
StrippedCalculator.prototype.l = function (a, b, c, d, e, f, g) {
var h = StrippedCalculator.k(d);
if (h <= 0) {
return {
p5: f
};
}
var i = f.width;
var j = (h * e) / i;
var k = f.x;
var l = 0;
for (var m = 0; m < d.count; ++m) {
var n = d._inner[m];
var o = Math.floor((n.e() / h) * i);
var 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
};
};
StrippedCalculator.prototype.n = function (a, b, c, d, e, f, g) {
var h = StrippedCalculator.k(d);
if (h <= 0) {
return {
p5: f
};
}
var i = f.height;
var j = (h * e) / i;
var k = f.y;
var l = 0;
for (var m = 0; m < d.count; ++m) {
var n = d._inner[m];
var o = Math.floor((n.e() / h) * i);
var 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
};
};
StrippedCalculator.j = function (a, b, c) {
if (a.count == 0) {
return 1.7976931348623157E+308;
}
var d = StrippedCalculator.k(a);
var e = (d * c) / b;
var f = 0;
for (var g = 0; g < a.count; g++) {
var h = a._inner[g];
var i = (h.e() / d) * b;
f += Math.max(i / e, e / i);
}
f /= a.count;
return f;
};
StrippedCalculator.k = function (a) {
var b = 0;
for (var c = 0; c < a.count; c++) {
var d = a._inner[c];
b += d.e();
}
return b;
};
StrippedCalculator.p = function (a, b, c, d) {
var e = 0;
for (var f = 0; f < c.count; f++) {
var g = c._inner[f];
}
var h = e;
var i = b.f * b.f / (d.width * d.height);
for (var j = 0; j < c.count; j++) {
var k = c._inner[j];
if (k.e() / h < i) {
a.add_1(k);
}
}
};
StrippedCalculator.$t = markType(StrippedCalculator, 'StrippedCalculator', TreemapLayoutCalculator.$);
return StrippedCalculator;
}(TreemapLayoutCalculator));
export { StrippedCalculator };
/**
* @hidden
*/
var SliceAndDiceCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(SliceAndDiceCalculator, _super);
function SliceAndDiceCalculator() {
return _super !== null && _super.apply(this, arguments) || this;
}
SliceAndDiceCalculator.prototype.d = function (a, b) {
a.g();
this.m(a, b.b.a, b.h, b, 0);
};
SliceAndDiceCalculator.prototype.o = function (a, b, c) {
return c.j;
};
SliceAndDiceCalculator.prototype.m = function (a, b, c, d, e) {
var e_4, _a;
if (d.g >= 0 && e > d.g) {
return;
}
if (b == d.c) {
d.d = true;
this.g(a, b, c, d);
var f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
c = f;
}
if (!d.d) {
try {
for (var _b = __values(fromEnum(b.b)), _c = _b.next(); !_c.done; _c = _b.next()) {
var g = _c.value;
this.m(a, g, c, d, e + 1);
}
}
catch (e_4_1) {
e_4 = { error: e_4_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_4)
throw e_4.error;
}
}
return;
}
var h = this.o(b, c, d);
var i = SliceAndDiceCalculator.j(b, d, e);
var j = h.left + h.right;
var k = h.top + h.bottom;
var 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;
var m = new Size(1, l.width, l.height);
var n = l.left;
var o = l.top;
var p = new HashSet$1(TreemapTreeNode.$, 0);
var q = SliceAndDiceCalculator.k(b.b, b, d, m, p);
if (q) {
SliceAndDiceCalculator.n(b.b, b, d, m, p);
}
var r = 0;
for (var s = 0; s < b.b.count; s++) {
var t = b.b._inner[s];
if (!p.contains(t)) {
r += t.e();
}
}
var u = (i == 0) ? m.height : m.width;
var v = new Rect(4);
for (var w = 0; w < b.b.count; w++) {
var x = b.b._inner[w];
if (p.contains(x) || isNaN_(x.e())) {
continue;
}
if (r <= 0 || u <= 0) {
break;
}
var 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();
var z = this.h(a, x, d);
if (z.isEmpty) {
continue;
}
var 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;
}
};
SliceAndDiceCalculator.j = function (a, b, c) {
var d = 0;
if (b.a == 0) {
d = (c % 2 == 0) ? 0 : 1;
}
else {
d = (c % 2 == 0) ? 1 : 0;
}
return d;
};
SliceAndDiceCalculator.k = function (a, b, c, d, e) {
var f = true;
var g = b.e();
var h = Math.min(d.width, d.height);
for (var i = 0; i < a.count; i++) {
var 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;
};
SliceAndDiceCalculator.n = function (a, b, c, d, e) {
var f = new List$1(TreemapTreeNode.$, 0);
f.o(a);
f.aa(function (g, h) {
if (g.e() > h.e()) {
return 1;
}
else if (g.e() < h.e()) {
return -1;
}
return 0;
});
var g = 0;
var h = Math.min(d.width, d.height);
for (var i = 0; i < f.count; i++) {
var 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;
}(TreemapLayoutCalculator));
export { SliceAndDiceCalculator };
/**
* @hidden
*/
var TreemapLayoutSettings = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TreemapLayoutSettings, _super);
function TreemapLayoutSettings() {
var _this = _super.call(this) || this;
_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;
return _this;
}
TreemapLayoutSettings.$t = markType(TreemapLayoutSettings, 'TreemapLayoutSettings');
return TreemapLayoutSettings;
}(Base));
export { TreemapLayoutSettings };
/**
* @hidden
*/
var SquarifiedCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(SquarifiedCalculator, _super);
function SquarifiedCalculator() {
return _super !== null && _super.apply(this, arguments) || this;
}
SquarifiedCalculator.prototype.n = function (a, b, c, d, e) {
var e_5, _a, e_6, _b, e_7, _c;
if (d.g >= 0 && e > d.g) {
return;
}
if (b == d.c) {
d.d = true;
this.g(a, b, c, d);
var f = new Rect(0, c.left, c.top + d.e, c.width, c.height - d.e);
c = f;
}
if (!d.d) {
try {
for (var _d = __values(fromEnum(b.b)), _e = _d.next(); !_e.done; _e = _d.next()) {
var g = _e.value;
this.n(a, g, c, d, e + 1);
}
}
catch (e_5_1) {
e_5 = { error: e_5_1 };
}
finally {
try {
if (_e && !_e.done && (_a = _d.return))
_a.call(_d);
}
finally {
if (e_5)
throw e_5.error;
}
}
return;
}
var h = this.o(b, c, d);
var i = new Rect(0, c.left, c.top, c.width, c.height);
var j = h.left + h.right;
var 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;
var l = i.left;
var m = i.top;
var n = new List$1(TreemapTreeNode.$, 0);
var o = b.e();
var p = new Rect(0, i.left, i.top, i.width, i.height);
var q = (i.width * i.height) / o;
var r = new List$1(TreemapTreeNode.$, 1, b.b);
r.aa(function (s, t) {
if (t.e() < s.e()) {
return -1;
}
if (t.e() > s.e()) {
return 1;
}
return 0;
});
var s = new AreaInfo();
s.b = i;
s.a = o;
var t = new HashSet$1(TreemapTreeNode.$, 0);
try {
for (var _f = __values(fromEnum(r)), _g = _f.next(); !_g.done; _g = _f.next()) {
var u = _g.value;
if (TreemapLayoutCalculator.c(u, p, o, d) || isNaN_(u.e())) {
t.add_1(u);
continue;
}
var v = Math.min(i.width, i.height);
var w = SquarifiedCalculator.j(n, v, q);
n.add(u);
var 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);
}
}
}
catch (e_6_1) {
e_6 = { error: e_6_1 };
}
finally {
try {
if (_g && !_g.done && (_b = _f.return))
_b.call(_f);
}
finally {
if (e_6)
throw e_6.error;
}
}
this.l(t, a, n, s, d);
i = s.b;
try {
for (var _h = __values(fromEnum(b.b)), _j = _h.next(); !_j.done; _j = _h.next()) {
var y = _j.value;
if (t.contains(y)) {
continue;
}
var z = this.h(a, y, d);
if (z.isEmpty) {
continue;
}
var 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);
}
}
catch (e_7_1) {
e_7 = { error: e_7_1 };
}
finally {
try {
if (_j && !_j.done && (_c = _h.return))
_c.call(_h);
}
finally {
if (e_7)
throw e_7.error;
}
}
if (b == d.c) {
d.d = false;
}
};
SquarifiedCalculator.prototype.o = function (a, b, c) {
return c.j;
};
SquarifiedCalculator.j = function (a, b, c) {
var e_8, _a;
if (a.count == 0) {
return 1.7976931348623157E+308;
}
var d = 0;
var e = 1.7976931348623157E+308;
var f = -1.7976931348623157E+308;
try {
for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
var g = _c.value;
var h = g.e() * c;
if (e > h) {
e = h;
}
if (f < h) {
f = h;
}
d += h;
}
}
catch (e_8_1) {
e_8 = { error: e_8_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_8)
throw e_8.error;
}
}
var i = (b * b * f) / (d * d);
var j = (d * d) / (b * b * e);
return Math.max(i, j);
};
SquarifiedCalculator.prototype.l = function (a, b, c, d, e) {
if (c.count < 1) {
return;
}
var f = 0;
for (var 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);
}
};
SquarifiedCalculator.prototype.m = function (a, b, c, d, e, f) {
var g = e.b;
var h = e.a;
var i = Math.round((d / h) * g.height);
var j = g.x;
for (var k = 0; k < c.count; ++k) {
var l = c._inner[k];
if (g.right < j) {
a.add_1(l);
continue;
}
var m = Math.floor((l.e() / d) * g.width);
var 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