UNPKG

igniteui-react-charts

Version:

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

540 lines (539 loc) 18.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 { 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 */ export let OrdinalTimeXAxis = /*@__PURE__*/ (() => { class OrdinalTimeXAxis extends CategoryXAxis { f9(a, b, c) { return this.f7(a, new ScalerParams(0, b, c, this.dn, this.o3())); } f8(a, b, c) { return this.f7(a, b); } f7(a, b) { if (!b.c.isEmpty) { let c = this.s6(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.s6(a, b.e, b.d); } s6(a, b, c) { let d = this.rv; let e = this.rw; let f = this.rv - this.rw; let g = f >= 1 ? (a - e) / (d - e) : f == 0 ? 0.5 : NaN; if (this.dp) { g = 1 - g; } return c.left + c.width * (g - b.left) / b.width; } k2(a, b, c, d, e) { let f; let g = e.e; let h = e.d; let i = e.c; let j = e.a; let k = !i.isEmpty; let l = i.left; let m = i.width; let n = g.left; let o = g.width; let p = h.left; let q = h.width; let r = 0; let s = 1; let t = this.rv; let u = this.rw; let v = this.rv - this.rw; let w = this.re(a); let x = w != null; for (let y = 0; y < b.count; y++) { let z = b.item(y); for (let aa = c; aa < d; aa++) { f = x ? w[aa] : a.item(aa); if (k) { let ab = v >= 1 ? (f[z] - u) / (t - u) : v == 0 ? 0.5 : NaN; if (j) { ab = 1 - ab; } ab = l + m * (ab - r) / s; let ac = (ab - p) / q; ac = p + q * (ac - n) / o; f[z] = ac; } else { let 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; } } } } k3(a, b, c, d) { for (let e = b; e < c; e++) { a.item(e, this.f7(a.item(e), d)); } } gc(a, b, c) { return this.ga(a, new ScalerParams(0, b, this.o8, this.dn, this.o3())); } getUnscaledValue3(a, b, c, d) { return this.ga(a, new ScalerParams(0, b, this.o8, this.dn, this.o3())); } ga(a, b) { if (!b.c.isEmpty) { let c = b.e.left + b.e.width * (a - b.d.left) / b.d.width; c = (c * b.d.width) + b.d.left; c = this.s7(c, NumericScaler.ac, b.c); return c; } return this.s7(a, b.e, b.d); } s7(a, b, c) { let d = b.left + (a - c.left) * b.width / c.width; if (this.dp) { d = 1 - d; } return this.rw + d * (this.rv - this.rw); } gb(a, b, c) { return this.ga(a, b); } k4(a, b, c, d) { for (let e = b; e < c; e++) { a.item(e, this.ga(a.item(e), d)); } } constructor() { super(); this.st = dateMaxValue(); this.ss = dateMinValue(); this.sz = dateMaxValue(); this.sy = dateMinValue(); this.sv = dateMaxValue(); this.su = dateMinValue(); this.s9 = null; this.s8 = null; this.so = 0; this.sq = null; this.sm = null; this.ti = 0; this.sx = dateMinValue(); this.sw = dateMaxValue(); this.visibleRangeChanged = null; FastItemDateTimeColumn.o(); this.sm = new TimeAxisLabelFormatCollection(); let a = this.sn; a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.tk)); this.rw = 0; } al() { return new OrdinalTimeXAxis(); } lc(a, b, c, d) { super.lc(a, b, c, d); switch (b) { case "FastItemsSource": let e = typeCast(IFastItemsSource_$type, c); if (e != null) { e.deregisterColumn(this.sr); this.sr = null; } if (this.po != null) { this.sr = TimeAxisBase.rh(this.dateTimeMemberPath, this); } break; case "DateTimeMemberPath": if (this.po != null) { this.po.deregisterColumn(this.sr); this.sr = TimeAxisBase.rh(this.dateTimeMemberPath, this); } break; case "DateTimeColumn": this.ee(); this.ti = this.th(); break; case "MinimumValue": case "MaximumValue": this.ee(); this.lz(); break; case "LabellingMode": this.lz(); break; } } get actualMinimumValue() { return this.st; } set actualMinimumValue(a) { this.st = a; } get actualMaximumValue() { return this.ss; } set actualMaximumValue(a) { this.ss = a; } get visibleMinimum() { return this.sz; } set visibleMinimum(a) { this.sz = a; } get visibleMaximum() { return this.sy; } set visibleMaximum(a) { this.sy = a; } get s3() { return this.sv; } set s3(a) { this.sv = a; } get s2() { return this.su; } set s2(a) { this.su = a; } tl() { if (this.sr == null || this.sr.count == 0 || this.sr.count < this.rw - 1) { this.actualMinimumValue = dateMinValue(); this.actualMaximumValue = dateMaxValue(); return; } let a = Math.max(0, Math.min(this.rw, this.sr.count - 1)); let b = Math.max(0, Math.min(this.rv, this.sr.count - 1)); let c = +(this.actualMinimumValue) != +(this.sr.item(a)) || +(this.actualMaximumValue) != +(this.sr.item(b)); if (c) { let d = this.actualMinimumValue; let e = this.actualMaximumValue; this.actualMinimumValue = this.sr.item(a); this.actualMaximumValue = this.sr.item(b); this.tm(); } } tm() { if (this.sr == null || this.sr.count == 0 || this.b7 == null) { let a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue); this.visibleMinimum = this.actualMinimumValue; this.visibleMaximum = this.actualMaximumValue; this.s3 = this.visibleMinimum; this.s2 = this.visibleMaximum; if (a && this.visibleRangeChanged != null) { this.visibleRangeChanged(this, EventArgs.empty); } return; } let b = this.o2(); let c = new ScalerParams(1, this.b7.zb, this.b7.za, this.dn); c.c = this.o3(); let d = this.ga(b.left, c); let e = this.ga(b.right, c); let f = truncate(Math.floor(d)); let g = truncate(Math.ceil(e)); let h = this.dn ? this.actualMaximumValue : this.actualMinimumValue; let i = this.dn ? this.actualMinimumValue : this.actualMaximumValue; let j = f >= 0 && f < this.sr.count ? this.sr.item(f) : h; let k = g >= 0 && g < this.sr.count ? this.sr.item(g) : i; let l = j; let m = k; if (d > f) { let n = f + 1; let o = n >= 0 && n < this.sr.count ? this.sr.item(n) : k; let p = dateAdd(+j, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+o - +j)) * (d - f)))); l = p; } if (e < g) { let q = g - 1; let r = q >= 0 && q < this.sr.count ? this.sr.item(q) : j; let s = dateSubtract(+k, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+k - +r)) * (g - e)))); m = s; } this.s3 = l; this.s2 = m; let t = +(this.visibleMinimum) != +j || +(this.visibleMaximum) != +k; this.visibleMinimum = j; this.visibleMaximum = k; if (t && this.visibleRangeChanged != null) { this.visibleRangeChanged(this, EventArgs.empty); } } l1(a) { let b = TimeXAxis.tn(this.actualMinimumValue, false, this.actualMinimumValue, this.sp, this.tg, this.sn, this.hb); if (b != this.s9 && this.eh) { this.l5(); } this.s9 = b; super.l1(a); } get dateTimeMemberPath() { return this.s8; } set dateTimeMemberPath(a) { let b = this.dateTimeMemberPath; if (a != b) { this.s8 = a; this.lu("DateTimeMemberPath", b, this.dateTimeMemberPath); } } get sp() { return this.so; } set sp(a) { let b = this.sp; if (a != b) { this.so = a; this.lu("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.sp)); } } get_dr() { return true; } get sr() { return this.sq; } set sr(a) { if (this.sq != a) { let b = this.sq; this.sq = a; this.lu("DateTimeColumn", b, this.sq); } } mg(a, b) { super.mg(a, b); this.tm(); } getWindowRectForSelection(a, b) { if (this.sr == null) { return Rect.empty; } let c = a > b; let d = c ? b : a; let e = c ? a : b; let f = -1; while (++f < this.sr.count && this.sr.item(f) < d) { } let g = this.sr.count; while (--g >= 0 && this.sr.item(g) > e) { } let h = new ScalerParams(0, new Rect(0, 0, 0, 1, 1), new Rect(0, 0, 0, 1, 1), this.dn, this.b7.yw); let i = this.f7(f, h); let j = this.f7(g + 1, h); return new Rect(0, i, NaN, Math.max(0, j - i), NaN); } get sn() { return this.sm; } tk(a, b) { this.l0(false); } le(a) { super.le(a); this.dateTimeMemberPath = a; } hy(a) { if (this.az != null) { return this.az(a); } if (this.ai != null) { return this.ai.i(a); } if (!(typeCast(Date_$type, a) !== null)) { return super.hy(a); } let b = dateMinValue(); let c = false; if (this.rx != null) { if (typeCast(Date_$type, this.rx) !== null) { b = this.rx; c = true; } } let d = TimeXAxis.ti(a, c, b, this.sp, this.tg, this.sn, this.hb); return d == null ? super.hy(a) : d; } ja(a) { let b = 0; if (this.categoryMode == 0) { b = truncate(Math.round(a)); } else { b = truncate(Math.floor(a)); } if (b < 0 || b > this.qd - 1) { return super.ja(a); } let c = this.sr.item(b); let d = this.hy(c); if (d == null) { return null; } return d.toString(); } getDateTime(a) { let b = truncate(Math.round(a)); if (b < 0) { b = 0; } if (b > this.qd - 1) { b = this.qd - 1; } if (this.sr == null) { return dateMinValue(); } let c = this.sr.item(b); return c; } get tj() { return +(this.visibleMaximum) - +(this.visibleMinimum); } get tg() { return +(this.s2) - +(this.s3); } rg() { return this.sr; } mf(a, b) { super.mf(a, b); this.tm(); } rp(a, b) { let c = this.categoryMode == 0 ? 0 : 0.5; return super.rp(a + c, b); } ro(a, b, c, d) { return b; } th() { if (this.sr == null || this.sr.count < 2) { return (0); } return TimeXAxis.tt((a) => this.sr.item(a), this.sr.count); } itemLabelFormat() { return TimeXAxis.tp(this.ti); } get minimumValue() { return this.sx; } set minimumValue(a) { let b = this.minimumValue; if (+a != +b) { this.sx = a; this.lc(this, "MinimumValue", b, this.minimumValue); } } get maximumValue() { return this.sw; } set maximumValue(a) { let b = this.maximumValue; if (+a != +b) { this.sw = a; this.lc(this, "MaximumValue", b, this.maximumValue); } } eg() { if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) { return super.eg(); } if (this.d1 && this.eh) { this.b1 = this.b0(); } if (this.po == null || this.sr == null) { return false; } let a = this.rw; if (+(this.minimumValue) != +(dateMinValue())) { let b = -1; while (b++ <= this.sr.count) { if (this.sr.item(b) >= this.minimumValue) { break; } } a = b; } let c = this.categoryMode == 0 ? this.po.count - 1 : this.po.count; if (+(this.maximumValue) != +(dateMaxValue())) { let d = this.po.count; while (d-- > 0) { if (this.sr.item(d) <= this.maximumValue) { break; } } c = d; } if (a != this.rw || c != this.rv) { let e = new AxisRangeChangedEventArgs(0, this.rw, a, this.rv, c); this.rw = a; this.rv = c; this.lv(e); this.tl(); this.qr(); return true; } return false; } q0(a) { super.q0(a); this.ef(true); } get isVertical() { return this.dz; } j$d(a, b) { return this.ga.apply(this, arguments); } j$c(a, b) { return this.f7.apply(this, arguments); } j$e(a, b, c, d, e) { this.k2.apply(this, arguments); } j$f(a, b, c, d) { this.k3.apply(this, arguments); } j$g(a, b, c, d) { this.k4.apply(this, arguments); } get j$b() { return this.dn; } j$a() { return this.ag.apply(this, arguments); } } OrdinalTimeXAxis.$t = /*@__PURE__*/ markType(OrdinalTimeXAxis, 'OrdinalTimeXAxis', CategoryXAxis.$, [ITimeRangeSelectorAxis_$type, IOrdinalAxis_$type]); return OrdinalTimeXAxis; })();