UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

749 lines (748 loc) 26.5 kB
/* 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 } from "tslib"; import { CategoryAxisBase } from "./CategoryAxisBase"; import { IZoomableCategoryAxis_$type } from "./IZoomableCategoryAxis"; import { DependencyProperty } from "igniteui-react-core"; import { Axis } from "./Axis"; import { Rect } from "igniteui-react-core"; import { Base, typeCast, Array_$type, Number_$type, markType, markDep } from "igniteui-react-core"; import { List$1 } from "igniteui-react-core"; import { ScalerParams } from "./ScalerParams"; import { NumericScaler } from "./NumericScaler"; import { VerticalAxisLabelPanel } from "./VerticalAxisLabelPanel"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { MathUtil } from "igniteui-react-core"; import { LinearCategorySnapper } from "./LinearCategorySnapper"; import { NumericXAxis } from "./NumericXAxis"; import { LabelPosition } from "./LabelPosition"; import { PropertyMetadata } from "igniteui-react-core"; import { truncate, isNaN_, isInfinity } from "igniteui-react-core"; import { CategoryAxisBaseView } from "./CategoryAxisBaseView"; import { AxisDefaults } from "./AxisDefaults"; /** * @hidden */ var CategoryYAxis = /** @class */ /*@__PURE__*/ (function (_super) { __extends(CategoryYAxis, _super); function CategoryYAxis() { var _this = _super.call(this) || this; _this.qa = 0; _this.qb = 0; _this.qk = 1; _this.qj = 1; _this.oo = new List$1(Number_$type, 0); _this.ab = CategoryYAxis.$; return _this; } CategoryYAxis.prototype.bm = function () { return new CategoryYAxisView(this); }; CategoryYAxis.prototype.kb = function (a) { _super.prototype.kb.call(this, a); this.p8 = a; }; CategoryYAxis.prototype.ak = function () { return new CategoryYAxis(); }; CategoryYAxis.prototype.jr = function (a) { _super.prototype.jr.call(this, a); this.ju(a, "ActualInterval"); this.ju(a, "ActualMinorInterval"); this.ju(a, "ZoomToItemSpan"); this.ju(a, "ZoomToCategoryStart"); this.ju(a, "ZoomToCategoryRange"); this.ju(a, "ZoomMaximumItemSpan"); this.ju(a, "ZoomMaximumCategoryRange"); }; CategoryYAxis.prototype.ju = function (a, b) { _super.prototype.ju.call(this, a, b); var c = typeCast(CategoryYAxis.$, a); if (c == null) { return; } var d = this; if (b == "ActualMinorInterval") { c.qi = Axis.gf(c.qf, d.qd); } if (b == "ActualInterval") { c.qh = Axis.gf(c.qe, d.qc); } if (b == "ZoomToItemSpan") { c.zoomToItemSpan = d.zoomToItemSpan; } if (b == "ZoomToCategoryStart") { c.zoomToCategoryStart = d.zoomToCategoryStart; } if (b == "ZoomToCategoryRange") { c.zoomToCategoryRange = d.zoomToCategoryRange; } if (b == "ZoomMaximumItemSpan") { c.zoomMaximumItemSpan = d.zoomMaximumItemSpan; } if (b == "ZoomMaximumCategoryRange") { c.zoomMaximumCategoryRange = d.zoomMaximumCategoryRange; } }; CategoryYAxis.prototype.get_dq = function () { return true; }; CategoryYAxis.prototype.fs = function () { return this.nv().height; }; CategoryYAxis.prototype.p5 = function (a, b, c) { return this.p6(a, b, c, true); }; CategoryYAxis.prototype.p7 = function (a) { if (typeCast(List$1.$.specialize(Array_$type), a) !== null) { return a.asArray(); } return null; }; CategoryYAxis.prototype.j5 = function (a, b, c, d, e) { var f; var g = e.e; var h = e.d; var i = e.c; var j = e.a; var k = !i.isEmpty; var l = this.categoryMode == 0 ? this.o5 - 1 : this.o5; if (l < 0) { l = 0; } var m = i.top; var n = i.height; var o = g.top; var p = g.height; var q = h.top; var r = h.height; var s = 0; var t = 1; var u = this.p7(a); var v = false; if (u != null) { v = true; } var w; for (var x = 0; x < b.count; x++) { w = b.item(x); for (var y = c; y < d; y++) { if (v) { f = u[y]; } else { f = a.item(y); } if (k) { var z = l >= 1 ? (f[w]) / (l) : l == 0 ? 0.5 : NaN; if (!j) { z = 1 - z; } z = m + n * (z - s) / t; var aa = (z - e.d.top) / e.d.height; aa = e.d.top + e.d.height * (aa - e.e.top) / e.e.height; f[w] = aa; } else { var ab = l >= 1 ? (f[w]) / (l) : l == 0 ? 0.5 : NaN; if (!j) { ab = 1 - ab; } ab = q + r * (ab - o) / p; f[w] = ab; } } } }; Object.defineProperty(CategoryYAxis.prototype, "qh", { get: function () { return this.c(CategoryYAxis.q4); }, set: function (a) { this.h(CategoryYAxis.q4, a); }, enumerable: false, configurable: true }); CategoryYAxis.prototype.p9 = function () { return !isNaN_(this.qh); }; Object.defineProperty(CategoryYAxis.prototype, "qc", { get: function () { return this.qa; }, set: function (a) { if (this.qc != a) { var b = this.qa; this.qa = a; this.kx("ActualInterval", b, this.qc); } }, enumerable: false, configurable: true }); CategoryYAxis.prototype.f5 = function () { return this.qc; }; Object.defineProperty(CategoryYAxis.prototype, "qi", { get: function () { return this.c(CategoryYAxis.q5); }, set: function (a) { this.h(CategoryYAxis.q5, a); }, enumerable: false, configurable: true }); Object.defineProperty(CategoryYAxis.prototype, "qd", { get: function () { return this.qb; }, set: function (a) { if (this.qd != a) { var b = this.qb; this.qb = a; this.kx("ActualMinorInterval", b, this.qd); } }, enumerable: false, configurable: true }); Object.defineProperty(CategoryYAxis.prototype, "qm", { get: function () { return this.qk; }, set: function (a) { this.qk = a; }, enumerable: false, configurable: true }); Object.defineProperty(CategoryYAxis.prototype, "ql", { get: function () { return this.qj; }, set: function (a) { this.qj = a; }, enumerable: false, configurable: true }); CategoryYAxis.prototype.ft = function (a, b) { if (!b.c.isEmpty) { var c = this.qg(a, NumericScaler.ac, b.c); c = (c - b.d.top) / b.d.height; c = b.d.top + b.d.height * (c - b.e.top) / b.e.height; return c; } return this.qg(a, b.e, b.d); }; CategoryYAxis.prototype.qg = function (a, b, c) { var d = this.categoryMode == 0 ? this.o5 - 1 : this.o5; if (d < 0) { d = 0; } var e = d >= 1 ? (a) / (d) : d == 0 ? 0.5 : NaN; if (!this.dg) { e = 1 - e; } return c.top + c.height * (e - b.top) / b.height; }; CategoryYAxis.prototype.fw = function (a, b) { if (!b.c.isEmpty) { var c = b.e.top + b.e.height * (a - b.d.top) / b.d.height; c = (c * b.d.height) + b.d.top; c = this.getUnscaledValue3(c, NumericScaler.ac, b.c, this.categoryMode); return c; } return this.getUnscaledValue3(a, b.e, b.d, this.categoryMode); }; CategoryYAxis.prototype.fx = function (a, b, c) { if (!b.c.isEmpty) { var d = b.e.top + b.e.height * (a - b.d.top) / b.d.height; d = (d * b.d.height) + b.d.top; d = this.getUnscaledValue3(d, NumericScaler.ac, b.c, c); return d; } return this.getUnscaledValue3(a, b.e, b.d, c); }; CategoryYAxis.prototype.getUnscaledValue3 = function (a, b, c, d) { var e = b.top + (a - c.top) * b.height / c.height; if (!this.dg) { e = 1 - e; } var f = d == 0 ? this.o5 - 1 : this.o5; if (f < 0) { f = 0; } return e * f; }; CategoryYAxis.prototype.qz = function (a, b) { if (isNaN_(a) || isNaN_(b) || this.oh == null || this.oh.count == 0) { return; } var c = a / this.oh.count; var d = b / this.oh.count; this.b0.x6 = new Rect(0, this.b0.x6.x, 1 - d, this.b0.x6.width, d - c); }; CategoryYAxis.prototype.az = function () { return new VerticalAxisLabelPanel(); }; CategoryYAxis.prototype.fe = function () { return this.qh; }; CategoryYAxis.prototype.getCategorySize = function (a, b, c) { var d = this.nz(b, c); return d.height / (this.o5 * a.height); }; CategoryYAxis.prototype.ou = function (a, b, c) { var d = this.o1(a, b, c); var e = 0; if (!isNaN_(this.o0)) { e = Math.min(this.o0, 1); } var f = 1 - 0.5 * d; var g = this.getCategorySize(a, b, c) * f / (this.o7 - (this.o7 - 1) * e); return g; }; CategoryYAxis.prototype.getGroupCenter = function (a, b, c, d) { var e = 0.5; if (this.o7 > 1) { var f = this.o1(b, c, d); var g = 0; if (!isNaN_(this.o0)) { g = Math.min(this.o0, 1); } var h = 1 - 0.5 * f; var i = h / (this.o7 - (this.o7 - 1) * g); var j = (h - i) / (this.o7 - 1); e = 0.25 * f + 0.5 * i + a * j; } return this.getCategorySize(b, c, d) * e; }; CategoryYAxis.prototype.qy = function (a) { var b = this.b0 != null ? this.b0.xn : Rect.empty; b = b.copy(); var c = this.n1; var d = new Rect(0, 0, 0, 1, 1); var e = this.ny(); var f = new ScalerParams(0, d, d, this.df, e); var g = !b.isEmpty && !c.isEmpty && this.oh != null ? this.oh.indexOf(a) : -1; var h = g > -1 ? this.ft(g, f) : NaN; if (!isNaN_(h) && this.b0.fx) { if (!isNaN_(h)) { if (h < b.top + 0.1 * b.height) { h = h + 0.4 * b.height; b.y = h - 0.5 * b.height; } if (h > b.bottom - 0.1 * b.height) { h = h - 0.4 * b.height; b.y = h - 0.5 * b.height; } } this.b0.tb(b, false, true); } }; CategoryYAxis.prototype.d4 = function () { if (this.dr && this.d5) { this.bu = this.bt(); } if (this.oh == null) { return false; } var a = false; var b = this.oh.count; if (b != this.ql) { var c = new AxisRangeChangedEventArgs(0, 1, 1, this.ql, b); this.ql = b; this.ky(c); a = true; } this.q1(); this.q0(); return a; }; CategoryYAxis.prototype.getWindowZoomFromCategories = function (a) { var b = MathUtil.a(a) && a > 0; var c = this.oh.count; if (c > 0 && b) { var d = this.b0.x5.height; var e = isNaN_(d) || isInfinity(d); if (e) { return NaN; } var f = new Rect(0, 0, 0, 1, 1); var g = this.b0.x5; var h = this.getCategorySize(f, g, g); var i = isNaN_(h) || isInfinity(h); if (i) { return NaN; } var j = h * a / d; if (j >= 0 && j <= 1) { return j; } } return NaN; }; CategoryYAxis.prototype.getWindowZoomFromItemSpan = function (a) { var b = MathUtil.a(a) && a > 0; var c = this.oh.count; if (c > 0 && b) { var d = this.b0.x5.height; var e = isNaN_(d) || isInfinity(d); if (e) { return NaN; } var f = new Rect(0, 0, 0, 1, 1); var g = this.b0.x5; var h = this.ou(f, g, g); var i = a / h; var j = Math.min(1, 1 / i); if (j > 0 && j <= 1) { return j; } } return NaN; }; CategoryYAxis.prototype.q1 = function () { if (this.oh == null || this.b0 == null) { return; } var a = !isNaN_(this.b0.jg) && !isNaN_(this.b0.ji); if (a) { return; } if (!isNaN_(this.zoomMaximumItemSpan) && !isInfinity(this.zoomMaximumItemSpan)) { var b = this.getWindowZoomFromItemSpan(this.zoomMaximumItemSpan); if (!isNaN_(b) && !isInfinity(b)) { this.b0.h6 = b; } } else if (!isNaN_(this.zoomMaximumCategoryRange) && !isInfinity(this.zoomMaximumCategoryRange)) { var c = this.getWindowZoomFromCategories(this.zoomMaximumCategoryRange); if (!isNaN_(c) && !isInfinity(c)) { this.b0.h6 = c; } } }; CategoryYAxis.prototype.q0 = function () { if (this.oh == null || this.b0 == null) { return; } var a = NaN; var b = NaN; var c = this.b0.id(); var d = this.b0.ie(); var e = false; if (MathUtil.a(this.zoomToItemSpan)) { e = true; d = this.getWindowZoomFromItemSpan(this.zoomToItemSpan); d = Math.max(d, this.b0.h6); } else if (MathUtil.a(this.zoomToCategoryRange)) { e = true; d = this.getWindowZoomFromCategories(this.zoomToCategoryRange); d = Math.max(d, this.b0.h6); } if (MathUtil.a(this.zoomToCategoryStart) && this.zoomToCategoryStart >= 0 && this.zoomToCategoryStart < this.o6) { e = true; b = this.getWindowZoomFromCategories(this.zoomToCategoryStart); var f = d + a - 1; var g = d - f; if (f > 0 && g > this.b0.h6) { d = g; d = Math.max(d, this.b0.h6); } } if (e) { this.b0.s9(a, b, c, d); } }; CategoryYAxis.prototype.kf = function (a, b, c, d) { _super.prototype.kf.call(this, a, b, c, d); switch (b) { case CategoryYAxis.$$p[2]: case CategoryYAxis.$$p[3]: this.q1(); break; case CategoryYAxis.$$p[4]: case CategoryYAxis.$$p[5]: case CategoryYAxis.$$p[6]: this.q0(); break; case CategoryYAxis.$$p[0]: case CategoryYAxis.$$p[1]: this.j1(b); break; } }; CategoryYAxis.prototype.j1 = function (a) { _super.prototype.j1.call(this, a); switch (a) { case CategoryYAxis.$$p[0]: case CategoryYAxis.$$p[1]: this.jw(a); break; } }; CategoryYAxis.prototype.ok = function (a) { if (a == null) { return false; } var b = this.bw(); if (b == null) { return false; } return b.synchronizeVertically; }; CategoryYAxis.prototype.k4 = function (a) { _super.prototype.k4.call(this, a); var b = this.b0 != null ? this.b0.xn : Rect.empty; var c = this.n1; var d = this.nw(); var e = this.nv(); var f = new ScalerParams(0, b, c, this.df, d); var g = this.bn.a4(); var h = this.bn.a7(); var i = this.bn.a5(); var j = this.bn.a6(); var k = this.bn.e(); var l = this.bn.f(); var m = this.bn.g(); this.lf(); this.jp(g); this.jp(h); this.jp(i); this.jp(j); this.ef.clear(); this.eg.clear(); this.oo.clear(); this.bn.az(this, b, c); if (b.isEmpty || c.isEmpty) { this.b9.count = 0; this.b8.count = 0; this.b7.count = 0; } if (this.b9.count == 0 && this.b8.count == 0 && this.bn.l()) { this.bn.ad(); } if (this.a3 != null) { this.a3.registerAxis(this); } if (this.itemsSource == null || this.oh == null || this.oh.count == 0) { this.b9.count = 0; this.b8.count = 0; this.b7.count = 0; this.bn.ad(); return; } if (!b.isEmpty && !c.isEmpty) { var n = this.fw(e.top, f); var o = this.fw(e.bottom, f); if (!this.df) { n = Math.ceil(n); o = Math.floor(o); } else { n = Math.floor(n); o = Math.ceil(o); } var p = c.left; var q = 0; if (this.am != null) { var r = typeCast(NumericXAxis.$, this.am); if (r != null) { var s = this.k9(p, q, b, c, d, c.left, c.right); p = s.p0; q = s.p1; } } this.lg(g, p, c, k, true); this.bn.au(q); var t = Math.min(n, o); var u = Math.max(n, o); var v = new LinearCategorySnapper(1, t, u, e.height, this.qh, this.categoryMode, this.f9()); var w = v.g; w = this.fb(w, this.p9(), b, c, d); if (v.g != w) { v = new LinearCategorySnapper(1, t, u, e.height, w, this.categoryMode, this.f9()); } var x = Math.floor((t - 0) / v.g); var y = Math.ceil((u - 0) / v.g); if (!isNaN_(x) && !isNaN_(y)) { var z = truncate(x); var aa = truncate(y); var ab = this.ft(0 + z * v.g, f); var ac = Math.abs(this.ft(v.g, f) - this.ft(0, f)); this.a0.bz = this.ft(v.g, f); for (var ad = z; ad <= aa; ++ad) { var ae = this.ft(0 + (ad + 1) * v.g, f); if (ab <= e.bottom) { if (ad % 2 == 0) { this.ka(h, ab, ae, c); } this.j9(i, ab, c, l, false); this.oo.add(ab); } if (this.categoryMode != 0 && this.o7 != 0 && this.dz) { if (this.qi > 0 && this.qi < v.g) { var af = ac * this.qi; if (!this.df) { var ag = ab; while (ag - af > ae) { ag -= af; if (Math.abs(ag - ae) < 0.0001) { break; } this.j9(j, ag, c, m, false); } } else { var ah = ab; while (ah + af < ae) { ah += af; if (Math.abs(ah - ae) < 0.0001) { break; } this.j9(j, ah, c, m, false); } } this.qd = this.qi; } else { for (var ai = 0; ai < truncate(v.g); ai++) { for (var aj = 0; aj < this.o7; aj++) { var ak = this.getGroupCenter(aj, b, c, d); if (!this.df) { ak = -ak; } var al = this.ft(ai + ad * v.g, f) + ak; this.j9(j, al, c, m, false); } } this.qd = 0.5; } } var am = ab; if (this.categoryMode != 0) { var an = this.ft(ad * v.g + 1, f); am = (ab + an) / 2; } if (am <= e.bottom && am >= e.top) { var ao = 0; if (v.g >= 1) { ao = ad * truncate(Math.floor(v.g)); } else { if ((ad * v.g) * 2 % 2 == 0) { ao = truncate(Math.floor(ad * v.g)); } else { ao = -1; } } if (this.oh != null && ao < this.oh.count && ao >= 0) { var ap = this.oh.item(ao); var aq = this.hf(ap); if (!isNaN_(am) && !isInfinity(am) && aq != null) { if ((typeof aq === 'string') && Base.equalsStatic(aq, "")) { } else { this.ef.add1(aq); this.eg.add(new LabelPosition(am)); } } } } ab = ae; } } this.qc = v.g; if ((this.a3 == null || this.a3.visibility == 0) && this.am != null) { if (this.a3 != null && (this.a3.location == 6 || this.a3.location == 7)) { this.b0.o2(); } } this.bn.a0(this.ef, this.eg); this.pv(); } }; CategoryYAxis.prototype.get_bk = function () { return 1; }; Object.defineProperty(CategoryYAxis.prototype, "bk", { get: function () { return this.get_bk(); }, enumerable: false, configurable: true }); Object.defineProperty(CategoryYAxis.prototype, "isVertical", { get: function () { return this.dq; }, enumerable: false, configurable: true }); CategoryYAxis.prototype.j$d = function (a, b) { return this.fw.apply(this, arguments); }; CategoryYAxis.prototype.j$c = function (a, b) { return this.ft.apply(this, arguments); }; CategoryYAxis.prototype.j$e = function (a, b, c, d, e) { this.j5.apply(this, arguments); }; CategoryYAxis.prototype.j$f = function (a, b, c, d) { this.j6.apply(this, arguments); }; CategoryYAxis.prototype.j$g = function (a, b, c, d) { this.j7.apply(this, arguments); }; Object.defineProperty(CategoryYAxis.prototype, "j$b", { get: function () { return this.df; }, enumerable: false, configurable: true }); CategoryYAxis.prototype.j$a = function () { return this.ag.apply(this, arguments); }; CategoryYAxis.$t = markType(CategoryYAxis, 'CategoryYAxis', CategoryAxisBase.$, [IZoomableCategoryAxis_$type]); CategoryYAxis.q4 = DependencyProperty.i("Interval", Number_$type, CategoryYAxis.$, new PropertyMetadata(2, NaN, function (a, b) { a.kx("Interval", b.oldValue, b.newValue); a.k3(false); })); CategoryYAxis.q5 = DependencyProperty.i("MinorInterval", Number_$type, CategoryYAxis.$, new PropertyMetadata(2, NaN, function (a, b) { (typeCast(CategoryYAxis.$, a)).kx("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryYAxis.$, a)).k3(false); })); CategoryYAxis.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryYAxis, 'kx', ['CompanionAxisInterval:qe:q2', [1, NaN], 'CompanionAxisMinorInterval:qf:q3', [1, NaN], 'ZoomMaximumCategoryRange::q6', [1, NaN], 'ZoomMaximumItemSpan::q7', [1, NaN], 'ZoomToCategoryRange::q8', [1, NaN], 'ZoomToCategoryStart::q9', [1, NaN], 'ZoomToItemSpan::ra', [1, NaN]]); return CategoryYAxis; }(CategoryAxisBase)); export { CategoryYAxis }; /** * @hidden */ var CategoryYAxisView = /** @class */ /*@__PURE__*/ (function (_super) { __extends(CategoryYAxisView, _super); function CategoryYAxisView(a) { var _this = _super.call(this, a) || this; _this.bm = null; _this.bm = a; return _this; } CategoryYAxisView.prototype.al = function () { _super.prototype.al.call(this); this.a.gt = AxisDefaults.categoryAxis_TickLength; }; CategoryYAxisView.$t = markType(CategoryYAxisView, 'CategoryYAxisView', CategoryAxisBaseView.$); return CategoryYAxisView; }(CategoryAxisBaseView)); export { CategoryYAxisView };