UNPKG

igniteui-react-charts

Version:

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

725 lines (724 loc) 24.1 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, __values } from "tslib"; import { FastItemDateTimeColumn } from "igniteui-react-core"; import { CategoryAxisBase } from "./CategoryAxisBase"; import { ISortingAxis_$type } from "./ISortingAxis"; import { IDateTimeAxis_$type } from "./IDateTimeAxis"; import { DependencyProperty } from "igniteui-react-core"; import { List$1 } from "igniteui-react-core"; import { typeCast, Number_$type, Date_$type, fromEnum, runOn, delegateRemove, delegateCombine, markType, markDep, TypeRegistrar } from "igniteui-react-core"; import { ScalerParams } from "./ScalerParams"; import { Rect } from "igniteui-react-core"; import { NumericScaler } from "./NumericScaler"; import { SeriesViewer } from "./SeriesViewer"; import { SortedListView$1 } from "./SortedListView$1"; import { ArrayExtension } from "igniteui-react-core"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { IFastItemsSource_$type } from "igniteui-react-core"; import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel"; import { PropertyMetadata } from "igniteui-react-core"; import { truncate, isNaN_ } from "igniteui-react-core"; import { dateMinValue, dateSubtract, dateAdd, dateMaxValue, dateFromTicks } from "igniteui-react-core"; /** * @hidden */ var TimeAxisBase = /** @class */ /*@__PURE__*/ (function (_super) { __extends(TimeAxisBase, _super); function TimeAxisBase() { var _this = _super.call(this) || this; _this.p7 = null; _this.qg = null; _this.qb = false; _this.qj = dateMaxValue(); _this.qi = dateMinValue(); FastItemDateTimeColumn.o(); return _this; } TimeAxisBase.prototype.ag = function () { return [this.actualMinimumValue.getTime(), this.actualMaximumValue.getTime()]; }; TimeAxisBase.prototype.ft = function (a, b) { if (!b.c.isEmpty) { var c = this.qo(a, NumericScaler.ac, b.c, Rect.empty); 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.qo(a, b.e, b.d, b.c); }; TimeAxisBase.prototype.hd = function (a, b) { var c = this.ix(b); if (c == TimeAxisBase.$$p[0]) { return this.he(a, b, this.dateTimeMemberPath); } return _super.prototype.hd.call(this, a, b); }; TimeAxisBase.prototype.qo = function (a, b, c, d) { var e; if (+(this.actualMaximumValue) == +(this.actualMinimumValue)) { e = -1; } else { e = (a - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); } var f = 0; if (this.categoryMode == 2) { f = this.getGroupCenter(0, b, c, d); } if (this.df) { e = 1 - e; f = -f; } return c.left + c.width * (e - b.left) / b.width - f; }; TimeAxisBase.prototype.qp = function (a, b, c) { var d; if (+(this.actualMaximumValue) == +(this.actualMinimumValue)) { d = -1; } else { d = (a - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); } var e = 0; if (this.df) { d = 1 - d; e = -e; } return c.left + c.width * (d - b.left) / b.width - e; }; TimeAxisBase.prototype.fw = function (a, b) { if (!b.c.isEmpty) { var c = b.d.left; var d = b.d.width; if (this.categoryMode != 0) { var e = this.getCategorySize(b.e, b.d, b.c); c += e / 2; d -= e; } var f = b.e.left + b.e.width * (a - c) / b.d.width; f = (f * b.d.width) + b.d.left; f = this.getUnscaledValue3(f, NumericScaler.ac, b.c, this.categoryMode); return f; } return this.getUnscaledValue3(a, b.e, b.d, this.categoryMode); }; TimeAxisBase.prototype.getUnscaledValue3 = function (a, b, c, d) { var e = b.left + b.width * (a - c.left) / c.width; if (this.df) { e = 1 - e; } return truncate(Math.floor(this.actualMinimumValue.getTime() + e * (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()))); }; TimeAxisBase.prototype.i$h = function () { this.q4(); }; TimeAxisBase.prototype.q4 = function () { var a = this.b0 != null ? this.b0.xn : Rect.empty; var b = !a.isEmpty ? this.n1 : Rect.empty; var c = (new Date()); var d = (new Date()); var e = false; if (!a.isEmpty && !b.isEmpty && this.p8 != null) { var f = typeCast(FastItemDateTimeColumn.$, this.p8); if (f != null) { if (this.qh == null) { this.q5(); } } else { this.qh = null; } if (this.p8.count > 0) { e = true; var g = this.qh == null ? 0 : this.qh._inner[0]; var h = this.qh == null ? this.p8.count - 1 : this.qh._inner[this.p8.count - 1]; c = this.p8.item(g); d = this.p8.item(h); this.qc = false; if (this.categoryMode == 2) { var i = this.q2(c, d); if (+c != +(dateMinValue())) { c = dateSubtract(+c, +i); } d = dateAdd(+d, +i); } } } if (this.qf()) { e = true; c = this.minimumValue; } if (this.qe()) { e = true; d = this.maximumValue; } var j = +(this.actualMinimumValue) != +c || +(this.actualMaximumValue) != +d; if (e && j) { var k = this.actualMinimumValue; var l = this.actualMaximumValue; this.actualMinimumValue = c; this.actualMaximumValue = d; this.q9(); } }; TimeAxisBase.prototype.q9 = function () { }; Object.defineProperty(TimeAxisBase.prototype, "p8", { get: function () { return this.p7; }, set: function (a) { if (this.p7 != a) { var b = this.p7; this.p7 = a; this.kx("DateTimeColumn", b, this.p7); } }, enumerable: false, configurable: true }); Object.defineProperty(TimeAxisBase.prototype, "qh", { get: function () { return this.qg; }, set: function (a) { this.qg = a; }, enumerable: false, configurable: true }); Object.defineProperty(TimeAxisBase.prototype, "i$b", { get: function () { if (this.qh == null) { var a = typeCast(FastItemDateTimeColumn.$, this.p8); if (a != null) { this.q5(); } else { this.qh = null; } } return this.qh; }, enumerable: false, configurable: true }); TimeAxisBase.prototype.q5 = function () { if (this.qd) { this.qh = new List$1(Number_$type, 0); var a = this.qh; var b = this.p8.count; for (var c = 0; c < b; c++) { a.add(c); } } else { var d = typeCast(FastItemDateTimeColumn.$, this.p8); this.qh = d.h(); } }; TimeAxisBase.prototype.i$e = function (a, b, c, d) { return this.qr(a, b, c, d); }; TimeAxisBase.prototype.qr = function (a, b, c, d) { if (b.isEmpty) { return -1; } var e = d; var f = new ScalerParams(0, a, b, this.df, c); var g, h; if (this.df) { h = this.fw(e.left, f); g = this.fw(e.right, f); } else { g = this.fw(e.left, f); h = this.fw(e.right, f); } var i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(g))); return this.qq(dateFromTicks(i)); }; TimeAxisBase.prototype.qq = function (a) { if (this.p8 == null || this.qh.count != this.p8.count) { return -1; } var b = new SortedListView$1(Date_$type, this.p8, this.qh); var c = this.qs(a, b); if (c >= 0 && c < this.qh.count) { var d = this.p8.item(this.qh._inner[c]); if (d > a) { c--; if (c < 0) { c = 0; } } return c; } return this.qh.count - 1; }; TimeAxisBase.prototype.i$g = function (a, b, c, d) { return this.qu(a, b, c, d); }; TimeAxisBase.prototype.qu = function (a, b, c, d) { if (b.isEmpty) { return -1; } var e = d; var f = new ScalerParams(0, a, b, this.df, c); var g, h; if (this.df) { h = this.fw(e.left, f); g = this.fw(e.right, f); } else { g = this.fw(e.left, f); h = this.fw(e.right, f); } var i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(h))); return this.qt(dateFromTicks(i)); }; TimeAxisBase.prototype.qt = function (a) { if (this.p8 == null || this.qh.count != this.p8.count) { return -1; } var b = new SortedListView$1(Date_$type, this.p8, this.qh); var c = this.qs(a, b); if (c >= this.qh.count) { c = this.qh.count - 1; } if (c >= 0 && c < this.qh.count) { var d = this.p8.item(this.qh._inner[c]); if (d < a) { c++; if (c > this.qh.count - 1) { c = this.qh.count - 1; } } return c; } return 0; }; TimeAxisBase.prototype.i$d = function (a) { if (this.p8 == null) { return NaN; } var b = this.p7.item(a); var c = b.getTime(); var d = c; return d; }; TimeAxisBase.prototype.i$c = function (a) { var b = this; if (b.i$b == null) { return -1; } var c = new SortedListView$1(Date_$type, this.p8, b.i$b); var ticks_ = a; var d = (new Date(ticks_)); var e = this.qs(d, c); if (e >= 0 && e < b.i$b.count && e - 1 >= 0 && e - 1 < b.i$b.count) { var diff1_ = d.getTime() - c.item(e - 1).getTime(); var diff2_ = c.item(e).getTime() - d.getTime(); var f = e - 1; var g = e; if (f < 0 && g >= 0) { return g; } if (g > b.i$b.count - 1 && f < b.i$b.count) { return f; } if (f < 0 && g < 0) { return -1; } if (f > b.i$b.count - 1 && g > b.i$b.count - 1) { return -1; } var h = diff1_ / (diff1_ + diff2_); if (isNaN_(h)) { h = 0; } return f + h; } if (e >= 0 && e < b.i$b.count) { return e; } var i = this.nw(); if (e == b.i$b.count && this.b0 != null && this.ft(a, new ScalerParams(0, this.b0.xn, this.n1, this.df, i)) < (this.n1.right + 2)) { return e - 1; } if (e == -1 && this.b0 != null && Math.abs(this.ft(a, new ScalerParams(0, this.b0.xn, this.n1, this.df, i)) - this.n1.left) < 2) { return 0; } return -1; }; TimeAxisBase.prototype.qs = function (a, b) { var c = this; if (this.p8 == null || c.i$b == null) { return -1; } var d = -1; var e = ArrayExtension.binarySearch$11(Date_$type, b, function (f) { if (a < f) { return -1; } if (a > f) { return 1; } return 0; }); if (e >= 0) { d = e; } else { d = ~e; } while (d >= 0 && d < b.count && d - 1 >= 0 && +(b.item(d)) == +(b.item(d - 1))) { d--; } return d; }; TimeAxisBase.prototype.i$f = function (a) { var b = this; if (b.i$b == null || this.p8 == null || b.i$b.count != this.p8.count) { return -1; } var c = new SortedListView$1(Date_$type, this.p8, b.i$b); var ticks_ = a; var d = (new Date(ticks_)); var e = this.qs(d, c); var f = this.nw(); if (e >= 0 && e < b.i$b.count && e - 1 >= 0 && e - 1 < b.i$b.count) { var g = +d - +(c.item(e - 1)); var h = +(c.item(e)) - +d; if (g < h) { e = e - 1; } } if (e >= 0 && e < b.i$b.count) { return b.i$b._inner[e]; } if (e == b.i$b.count && this.b0 != null && this.ft(a, new ScalerParams(0, this.b0.xn, this.n1, this.df, f)) < (this.n1.right + 2)) { return e - 1; } if (e == -1 && this.b0 != null && Math.abs(this.ft(a, new ScalerParams(0, this.b0.xn, this.n1, this.df, f)) - this.n1.left) < 2) { return 0; } return -1; }; TimeAxisBase.prototype.i$i = function () { this.qh = null; this.k2(); }; TimeAxisBase.prototype.get_qc = function () { return this.qb; }; TimeAxisBase.prototype.set_qc = function (a) { this.qb = a; }; Object.defineProperty(TimeAxisBase.prototype, "qc", { get: function () { return this.get_qc(); }, set: function (a) { this.set_qc(a); }, enumerable: false, configurable: true }); TimeAxisBase.prototype.kh = function (a) { _super.prototype.kh.call(this, a); this.dateTimeMemberPath = a; }; TimeAxisBase.prototype.kk = function (a) { _super.prototype.kk.call(this, a); this.minimumValue = a; }; TimeAxisBase.prototype.kj = function (a) { _super.prototype.kk.call(this, a); this.maximumValue = a; }; TimeAxisBase.prototype.d4 = function () { if (this.dr && this.d5) { this.bu = this.bt(); } var a = this.actualMinimumValue.getTime(); var b = this.actualMaximumValue.getTime(); this.q4(); var c = !this.qf() ? this.actualMinimumValue.getTime() : this.minimumValue.getTime(); var d = !this.qe() ? this.actualMaximumValue.getTime() : this.maximumValue.getTime(); var e = new AxisRangeChangedEventArgs(0, a, c, b, d); this.ky(e); return true; }; TimeAxisBase.prototype.qf = function () { if (+(this.minimumValue) == +(dateMinValue())) { return false; } return (this.minimumValue != null); }; TimeAxisBase.prototype.qe = function () { if (+(this.maximumValue) == +(dateMaxValue())) { return false; } return (this.maximumValue != null); }; Object.defineProperty(TimeAxisBase.prototype, "actualMinimumValue", { get: function () { return this.qj; }, set: function (a) { var b = +(this.qj) != +a; if (b) { var c = this.qj; this.qj = a; this.kx("ActualMinimumValue", c, a); } }, enumerable: false, configurable: true }); TimeAxisBase.prototype.hi = function () { return this.actualMinimumValue; }; Object.defineProperty(TimeAxisBase.prototype, "actualMaximumValue", { get: function () { return this.qi; }, set: function (a) { var b = +(this.qi) != +a; if (b) { var c = this.qi; this.qi = a; this.kx("ActualMaximumValue", c, a); } }, enumerable: false, configurable: true }); TimeAxisBase.prototype.hh = function () { return this.maximumValue; }; TimeAxisBase.prototype.q6 = function (a) { var e_1, _a; this.k4(a); if (this.oh == null) { return; } try { for (var _b = __values(fromEnum(this.ed())), _c = _b.next(); !_c.done; _c = _b.next()) { var b = _c.value; b.rz(a); } } 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; } } }; TimeAxisBase.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.p8); this.p8 = null; e.event = delegateRemove(e.event, runOn(this, this.q3)); } var f = typeCast(IFastItemsSource_$type, d); if (f != null) { this.qh = null; this.p8 = this.p9(this.dateTimeMemberPath); f.event = delegateCombine(f.event, runOn(this, this.q3)); } this.q6(false); break; case TimeAxisBase.$$p[0]: if (this.oh != null) { this.oh.deregisterColumn(this.p8); this.p8 = this.p9(this.dateTimeMemberPath); this.qh = null; } break; case TimeAxisBase.$$p[3]: this.d2(); this.q6(false); break; case TimeAxisBase.$$p[2]: this.d2(); this.q6(false); break; case "DateTimeColumn": this.q4(); break; } }; TimeAxisBase.prototype.q3 = function (a, b) { this.qh = null; }; TimeAxisBase.prototype.p9 = function (a) { return TimeAxisBase.qa(a, this); }; TimeAxisBase.qa = function (a, b) { if (a == null) { return b.oh.registerColumnDateTime(null, null, false); } var c = null; var d = SeriesViewer.c7(a, b.coercionMethods); c = d.a; return b.oh.registerColumnDateTime(a, c, b.expectFunctions); }; TimeAxisBase.prototype.az = function () { if (this.d7) { return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel')); } else { return new HorizontalAxisLabelPanel(); } }; TimeAxisBase.prototype.get_bk = function () { return 0; }; Object.defineProperty(TimeAxisBase.prototype, "bk", { get: function () { return this.get_bk(); }, enumerable: false, configurable: true }); TimeAxisBase.prototype.k4 = function (a) { _super.prototype.k4.call(this, a); var b = this.bn.a4(); var c = this.bn.a7(); var d = this.bn.a5(); var e = this.bn.a6(); var f = this.bn.e(); var g = this.bn.f(); var h = this.bn.g(); this.lf(); this.jp(b); this.jp(c); this.jp(d); this.jp(e); this.ef.clear(); this.eg.clear(); this.oo.clear(); this.a0.ad = this; var i = this.b0 != null ? this.b0.xn : Rect.empty; var j = !i.isEmpty ? this.n1 : Rect.empty; this.a0.c8 = i; this.a0.c7 = j; if (i.isEmpty || j.isEmpty) { this.b9.count = 0; this.b8.count = 0; this.b7.count = 0; } if (this.b9.count == 0 && this.bn.l()) { this.a0.ab.clear(); } if (this.a3 != null) { this.a3.registerAxis(this); } this.q4(); }; TimeAxisBase.prototype.get_dc = function () { return true; }; TimeAxisBase.prototype.startCursor = function () { }; TimeAxisBase.prototype.resetCursor = function () { }; TimeAxisBase.prototype.StartTimeCursor = function () { this.startCursor(); }; TimeAxisBase.prototype.ResetTimeCursor = function () { this.resetCursor(); }; TimeAxisBase.prototype.getCategorySize = function (a, b, c) { if (this.o5 == 0) { return 0; } var d = this.nz(b, c); return d.width / (this.o5 * a.width); }; TimeAxisBase.prototype.getGroupCenter = function (a, b, c, d) { return this.getCategorySize(b, c, d) * 0.5; }; TimeAxisBase.prototype.ou = function (a, b, c) { var d = this.o1(a, b, c); var e = 1 - 0.5 * d; var f = this.getCategorySize(a, b, c) * e; return f; }; TimeAxisBase.prototype.get_dm = function () { return true; }; TimeAxisBase.prototype.q2 = function (a, b) { return (0); }; TimeAxisBase.prototype.preferredCategoryMode = function (a) { return this.c9 ? 0 : 1; }; TimeAxisBase.prototype.hc = function (a) { var b = new ScalerParams(1, this.b0.x6, this.b0.x5, this.df); var c = this.fw(a, b); return dateFromTicks(truncate(c)); }; Object.defineProperty(TimeAxisBase.prototype, "isVertical", { get: function () { return this.dq; }, enumerable: false, configurable: true }); TimeAxisBase.prototype.j$d = function (a, b) { return this.fw.apply(this, arguments); }; TimeAxisBase.prototype.j$c = function (a, b) { return this.ft.apply(this, arguments); }; TimeAxisBase.prototype.j$e = function (a, b, c, d, e) { this.j5.apply(this, arguments); }; TimeAxisBase.prototype.j$f = function (a, b, c, d) { this.j6.apply(this, arguments); }; TimeAxisBase.prototype.j$g = function (a, b, c, d) { this.j7.apply(this, arguments); }; Object.defineProperty(TimeAxisBase.prototype, "j$b", { get: function () { return this.df; }, enumerable: false, configurable: true }); TimeAxisBase.prototype.j$a = function () { return this.ag.apply(this, arguments); }; Object.defineProperty(TimeAxisBase.prototype, "i$a", { get: function () { return this.dc; }, enumerable: false, configurable: true }); TimeAxisBase.$t = markType(TimeAxisBase, 'TimeAxisBase', CategoryAxisBase.$, [ISortingAxis_$type, IDateTimeAxis_$type]); TimeAxisBase.$$p = markDep(DependencyProperty, PropertyMetadata, TimeAxisBase, 'kx', ['DateTimeMemberPath::ra', [2, null], 'IsDataPreSorted:qd:rb', [0, false], 'MaximumValue::rc', [3, null], 'MinimumValue::rd', [3, null]]); return TimeAxisBase; }(CategoryAxisBase)); export { TimeAxisBase };