UNPKG

igniteui-react-charts

Version:

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

605 lines (604 loc) 20.9 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 { FastItemDateTimeColumn } from "igniteui-react-core"; import { CategoryXAxis } from "./CategoryXAxis"; import { ITimeRangeSelectorAxis_$type } from "./ITimeRangeSelectorAxis"; import { IOrdinalAxis_$type } from "./IOrdinalAxis"; import { TimeAxisLabellingMode_$type } from "./TimeAxisLabellingMode"; import { TimeAxisLabelFormatCollection } from "./TimeAxisLabelFormatCollection"; import { Rect } from "igniteui-react-core"; import { ScalerParams } from "./ScalerParams"; import { NumericScaler } from "./NumericScaler"; import { EventArgs, runOn, delegateCombine, typeCast, enumGetBox, Date_$type, markType } from "igniteui-react-core"; import { IFastItemsSource_$type } from "igniteui-react-core"; import { TimeAxisBase } from "./TimeAxisBase"; import { TimeXAxis } from "./TimeXAxis"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { truncate } from "igniteui-react-core"; import { dateMaxValue, dateMinValue, dateAdd, dateSubtract } from "igniteui-react-core"; import { timeSpanFromMilliseconds, timeSpanTotalMilliseconds } from "igniteui-react-core"; /** * @hidden */ var OrdinalTimeXAxis = /** @class */ /*@__PURE__*/ (function (_super) { __extends(OrdinalTimeXAxis, _super); function OrdinalTimeXAxis() { var _this = _super.call(this) || this; _this.rm = dateMaxValue(); _this.rl = dateMinValue(); _this.rs = dateMaxValue(); _this.rr = dateMinValue(); _this.ro = dateMaxValue(); _this.rn = dateMinValue(); _this.r2 = null; _this.r1 = null; _this.rh = 0; _this.rj = null; _this.rf = null; _this.sb = 0; _this.rq = dateMinValue(); _this.rp = dateMaxValue(); _this.visibleRangeChanged = null; FastItemDateTimeColumn.o(); _this.rf = new TimeAxisLabelFormatCollection(); var a = _this.rg; a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.sd)); _this.qp = 0; return _this; } OrdinalTimeXAxis.prototype.fv = function (a, b, c) { return this.ft(a, new ScalerParams(0, b, c, this.df, this.nw())); }; OrdinalTimeXAxis.prototype.fu = function (a, b, c) { return this.ft(a, b); }; OrdinalTimeXAxis.prototype.ft = function (a, b) { if (!b.c.isEmpty) { var c = this.rz(a, NumericScaler.ac, b.c); c = (c - b.d.left) / b.d.width; c = b.d.left + b.d.width * (c - b.e.left) / b.e.width; return c; } return this.rz(a, b.e, b.d); }; OrdinalTimeXAxis.prototype.rz = function (a, b, c) { var d = this.qo; var e = this.qp; var f = this.qo - this.qp; var g = f >= 1 ? (a - e) / (d - e) : f == 0 ? 0.5 : NaN; if (this.dg) { g = 1 - g; } return c.left + c.width * (g - b.left) / b.width; }; OrdinalTimeXAxis.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 = i.left; var m = i.width; var n = g.left; var o = g.width; var p = h.left; var q = h.width; var r = 0; var s = 1; var t = this.qo; var u = this.qp; var v = this.qo - this.qp; var w = this.p7(a); var x = w != null; for (var y = 0; y < b.count; y++) { var z = b.item(y); for (var aa = c; aa < d; aa++) { f = x ? w[aa] : a.item(aa); if (k) { var ab = v >= 1 ? (f[z] - u) / (t - u) : v == 0 ? 0.5 : NaN; if (j) { ab = 1 - ab; } ab = l + m * (ab - r) / s; var ac = (ab - p) / q; ac = p + q * (ac - n) / o; f[z] = ac; } else { var ad = v >= 1 ? (f[z] - u) / (t - u) : v == 0 ? 0.5 : NaN; if (j) { ad = 1 - ad; } ad = p + q * (ad - n) / o; f[z] = ad; } } } }; OrdinalTimeXAxis.prototype.j6 = function (a, b, c, d) { for (var e = b; e < c; e++) { a.item(e, this.ft(a.item(e), d)); } }; OrdinalTimeXAxis.prototype.fy = function (a, b, c) { return this.fw(a, new ScalerParams(0, b, this.n1, this.df, this.nw())); }; OrdinalTimeXAxis.prototype.getUnscaledValue3 = function (a, b, c, d) { return this.fw(a, new ScalerParams(0, b, this.n1, this.df, this.nw())); }; OrdinalTimeXAxis.prototype.fw = function (a, b) { if (!b.c.isEmpty) { var c = b.e.left + b.e.width * (a - b.d.left) / b.d.width; c = (c * b.d.width) + b.d.left; c = this.r0(c, NumericScaler.ac, b.c); return c; } return this.r0(a, b.e, b.d); }; OrdinalTimeXAxis.prototype.r0 = function (a, b, c) { var d = b.left + (a - c.left) * b.width / c.width; if (this.dg) { d = 1 - d; } return this.qp + d * (this.qo - this.qp); }; OrdinalTimeXAxis.prototype.fx = function (a, b, c) { return this.fw(a, b); }; OrdinalTimeXAxis.prototype.j7 = function (a, b, c, d) { for (var e = b; e < c; e++) { a.item(e, this.fw(a.item(e), d)); } }; OrdinalTimeXAxis.prototype.ak = function () { return new OrdinalTimeXAxis(); }; OrdinalTimeXAxis.prototype.kf = function (a, b, c, d) { _super.prototype.kf.call(this, a, b, c, d); switch (b) { case "FastItemsSource": var e = typeCast(IFastItemsSource_$type, c); if (e != null) { e.deregisterColumn(this.rk); this.rk = null; } if (this.oh != null) { this.rk = TimeAxisBase.qa(this.dateTimeMemberPath, this); } break; case "DateTimeMemberPath": if (this.oh != null) { this.oh.deregisterColumn(this.rk); this.rk = TimeAxisBase.qa(this.dateTimeMemberPath, this); } break; case "DateTimeColumn": this.d2(); this.sb = this.sa(); break; case "MinimumValue": case "MaximumValue": this.d2(); this.k2(); break; case "LabellingMode": this.k2(); break; } }; Object.defineProperty(OrdinalTimeXAxis.prototype, "actualMinimumValue", { get: function () { return this.rm; }, set: function (a) { this.rm = a; }, enumerable: false, configurable: true }); Object.defineProperty(OrdinalTimeXAxis.prototype, "actualMaximumValue", { get: function () { return this.rl; }, set: function (a) { this.rl = a; }, enumerable: false, configurable: true }); Object.defineProperty(OrdinalTimeXAxis.prototype, "visibleMinimum", { get: function () { return this.rs; }, set: function (a) { this.rs = a; }, enumerable: false, configurable: true }); Object.defineProperty(OrdinalTimeXAxis.prototype, "visibleMaximum", { get: function () { return this.rr; }, set: function (a) { this.rr = a; }, enumerable: false, configurable: true }); Object.defineProperty(OrdinalTimeXAxis.prototype, "rw", { get: function () { return this.ro; }, set: function (a) { this.ro = a; }, enumerable: false, configurable: true }); Object.defineProperty(OrdinalTimeXAxis.prototype, "rv", { get: function () { return this.rn; }, set: function (a) { this.rn = a; }, enumerable: false, configurable: true }); OrdinalTimeXAxis.prototype.se = function () { if (this.rk == null || this.rk.count == 0 || this.rk.count < this.qp - 1) { this.actualMinimumValue = dateMinValue(); this.actualMaximumValue = dateMaxValue(); return; } var a = Math.max(0, Math.min(this.qp, this.rk.count - 1)); var b = Math.max(0, Math.min(this.qo, this.rk.count - 1)); var c = +(this.actualMinimumValue) != +(this.rk.item(a)) || +(this.actualMaximumValue) != +(this.rk.item(b)); if (c) { var d = this.actualMinimumValue; var e = this.actualMaximumValue; this.actualMinimumValue = this.rk.item(a); this.actualMaximumValue = this.rk.item(b); this.sf(); } }; OrdinalTimeXAxis.prototype.sf = function () { if (this.rk == null || this.rk.count == 0 || this.b0 == null) { var a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue); this.visibleMinimum = this.actualMinimumValue; this.visibleMaximum = this.actualMaximumValue; this.rw = this.visibleMinimum; this.rv = this.visibleMaximum; if (a && this.visibleRangeChanged != null) { this.visibleRangeChanged(this, EventArgs.empty); } return; } var b = this.nv(); var c = new ScalerParams(1, this.b0.x6, this.b0.x5, this.df); c.c = this.nw(); var d = this.fw(b.left, c); var e = this.fw(b.right, c); var f = truncate(Math.floor(d)); var g = truncate(Math.ceil(e)); var h = f >= 0 && f < this.rk.count ? this.rk.item(f) : this.actualMinimumValue; var i = g >= 0 && g < this.rk.count ? this.rk.item(g) : this.actualMaximumValue; var j = h; var k = i; if (d > f) { var l = f + 1; var m = l >= 0 && l < this.rk.count ? this.rk.item(l) : i; var n = dateAdd(+h, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+m - +h)) * (d - f)))); j = n; } if (e < g) { var o = g - 1; var p = o >= 0 && o < this.rk.count ? this.rk.item(o) : h; var q = dateSubtract(+i, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+i - +p)) * (g - e)))); k = q; } this.rw = j; this.rv = k; var r = +(this.visibleMinimum) != +h || +(this.visibleMaximum) != +i; this.visibleMinimum = h; this.visibleMaximum = i; if (r && this.visibleRangeChanged != null) { this.visibleRangeChanged(this, EventArgs.empty); } }; OrdinalTimeXAxis.prototype.k4 = function (a) { var b = TimeXAxis.sf(this.actualMinimumValue, false, this.actualMinimumValue, this.ri, this.r9, this.rg, this.gw); if (b != this.r2 && this.d5) { this.k8(); } this.r2 = b; _super.prototype.k4.call(this, a); }; Object.defineProperty(OrdinalTimeXAxis.prototype, "dateTimeMemberPath", { get: function () { return this.r1; }, set: function (a) { var b = this.dateTimeMemberPath; if (a != b) { this.r1 = a; this.kx("DateTimeMemberPath", b, this.dateTimeMemberPath); } }, enumerable: false, configurable: true }); Object.defineProperty(OrdinalTimeXAxis.prototype, "ri", { get: function () { return this.rh; }, set: function (a) { var b = this.ri; if (a != b) { this.rh = a; this.kx("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.ri)); } }, enumerable: false, configurable: true }); OrdinalTimeXAxis.prototype.get_di = function () { return true; }; Object.defineProperty(OrdinalTimeXAxis.prototype, "rk", { get: function () { return this.rj; }, set: function (a) { if (this.rj != a) { var b = this.rj; this.rj = a; this.kx("DateTimeColumn", b, this.rj); } }, enumerable: false, configurable: true }); OrdinalTimeXAxis.prototype.lj = function (a, b) { _super.prototype.lj.call(this, a, b); this.sf(); }; OrdinalTimeXAxis.prototype.getWindowRectForSelection = function (a, b) { if (this.rk == null) { return Rect.empty; } var c = a > b; var d = c ? b : a; var e = c ? a : b; var f = -1; while (++f < this.rk.count && this.rk.item(f) < d) { } var g = this.rk.count; while (--g >= 0 && this.rk.item(g) > e) { } var h = new ScalerParams(0, new Rect(0, 0, 0, 1, 1), new Rect(0, 0, 0, 1, 1), this.df, this.b0.xr); var i = this.ft(f, h); var j = this.ft(g + 1, h); return new Rect(0, i, NaN, Math.max(0, j - i), NaN); }; Object.defineProperty(OrdinalTimeXAxis.prototype, "rg", { get: function () { return this.rf; }, enumerable: false, configurable: true }); OrdinalTimeXAxis.prototype.sd = function (a, b) { this.k3(false); }; OrdinalTimeXAxis.prototype.kh = function (a) { _super.prototype.kh.call(this, a); this.dateTimeMemberPath = a; }; OrdinalTimeXAxis.prototype.hf = function (a) { if (this.ay != null) { return this.ay(a); } if (this.ai != null) { return this.ai.i(a); } if (!(typeCast(Date_$type, a) !== null)) { return _super.prototype.hf.call(this, a); } var b = dateMinValue(); var c = false; if (this.qq != null) { if (typeCast(Date_$type, this.qq) !== null) { b = this.qq; c = true; } } var d = TimeXAxis.sa(a, c, b, this.ri, this.r9, this.rg, this.gw); return d == null ? _super.prototype.hf.call(this, a) : d; }; OrdinalTimeXAxis.prototype.ih = function (a) { var b = 0; if (this.categoryMode == 0) { b = truncate(Math.round(a)); } else { b = truncate(Math.floor(a)); } if (b < 0 || b > this.o6 - 1) { return _super.prototype.ih.call(this, a); } var c = this.rk.item(b); var d = this.hf(c); if (d == null) { return null; } return d.toString(); }; OrdinalTimeXAxis.prototype.getDateTime = function (a) { var b = truncate(Math.round(a)); if (b < 0) { b = 0; } if (b > this.o6 - 1) { b = this.o6 - 1; } if (this.rk == null) { return dateMinValue(); } var c = this.rk.item(b); return c; }; Object.defineProperty(OrdinalTimeXAxis.prototype, "sc", { get: function () { return +(this.visibleMaximum) - +(this.visibleMinimum); }, enumerable: false, configurable: true }); Object.defineProperty(OrdinalTimeXAxis.prototype, "r9", { get: function () { return +(this.rv) - +(this.rw); }, enumerable: false, configurable: true }); OrdinalTimeXAxis.prototype.p9 = function () { return this.rk; }; OrdinalTimeXAxis.prototype.li = function (a, b) { _super.prototype.li.call(this, a, b); this.sf(); }; OrdinalTimeXAxis.prototype.qi = function (a, b) { var c = this.categoryMode == 0 ? 0 : 0.5; return _super.prototype.qi.call(this, a + c, b); }; OrdinalTimeXAxis.prototype.qh = function (a, b, c, d) { return b; }; OrdinalTimeXAxis.prototype.sa = function () { var _this = this; if (this.rk == null || this.rk.count < 2) { return (0); } return TimeXAxis.sl(function (a) { return _this.rk.item(a); }, this.rk.count); }; OrdinalTimeXAxis.prototype.itemLabelFormat = function () { return TimeXAxis.sh(this.sb); }; Object.defineProperty(OrdinalTimeXAxis.prototype, "minimumValue", { get: function () { return this.rq; }, set: function (a) { var b = this.minimumValue; if (+a != +b) { this.rq = a; this.kf(this, "MinimumValue", b, this.minimumValue); } }, enumerable: false, configurable: true }); Object.defineProperty(OrdinalTimeXAxis.prototype, "maximumValue", { get: function () { return this.rp; }, set: function (a) { var b = this.maximumValue; if (+a != +b) { this.rp = a; this.kf(this, "MaximumValue", b, this.maximumValue); } }, enumerable: false, configurable: true }); OrdinalTimeXAxis.prototype.d4 = function () { if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) { return _super.prototype.d4.call(this); } if (this.dr && this.d5) { this.bu = this.bt(); } if (this.oh == null || this.rk == null) { return false; } var a = this.qp; if (+(this.minimumValue) != +(dateMinValue())) { var b = -1; while (b++ <= this.rk.count) { if (this.rk.item(b) >= this.minimumValue) { break; } } a = b; } var c = this.categoryMode == 0 ? this.oh.count - 1 : this.oh.count; if (+(this.maximumValue) != +(dateMaxValue())) { var d = this.oh.count; while (d-- > 0) { if (this.rk.item(d) <= this.maximumValue) { break; } } c = d; } if (a != this.qp || c != this.qo) { var e = new AxisRangeChangedEventArgs(0, this.qp, a, this.qo, c); this.qp = a; this.qo = c; this.ky(e); this.se(); this.pk(); return true; } return false; }; OrdinalTimeXAxis.prototype.pt = function (a) { _super.prototype.pt.call(this, a); this.d3(true); }; Object.defineProperty(OrdinalTimeXAxis.prototype, "isVertical", { get: function () { return this.dq; }, enumerable: false, configurable: true }); OrdinalTimeXAxis.prototype.j$d = function (a, b) { return this.fw.apply(this, arguments); }; OrdinalTimeXAxis.prototype.j$c = function (a, b) { return this.ft.apply(this, arguments); }; OrdinalTimeXAxis.prototype.j$e = function (a, b, c, d, e) { this.j5.apply(this, arguments); }; OrdinalTimeXAxis.prototype.j$f = function (a, b, c, d) { this.j6.apply(this, arguments); }; OrdinalTimeXAxis.prototype.j$g = function (a, b, c, d) { this.j7.apply(this, arguments); }; Object.defineProperty(OrdinalTimeXAxis.prototype, "j$b", { get: function () { return this.df; }, enumerable: false, configurable: true }); OrdinalTimeXAxis.prototype.j$a = function () { return this.ag.apply(this, arguments); }; OrdinalTimeXAxis.$t = markType(OrdinalTimeXAxis, 'OrdinalTimeXAxis', CategoryXAxis.$, [ITimeRangeSelectorAxis_$type, IOrdinalAxis_$type]); return OrdinalTimeXAxis; }(CategoryXAxis)); export { OrdinalTimeXAxis };