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.s9(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.s9(a, b.e, b.d); } s9(a, b, c) { let d = this.ry; let e = this.rz; let f = this.ry - this.rz; 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.ry; let u = this.rz; let v = this.ry - this.rz; let w = this.rh(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.ta(c, NumericScaler.ac, b.c); return c; } return this.ta(a, b.e, b.d); } ta(a, b, c) { let d = b.left + (a - c.left) * b.width / c.width; if (this.dp) { d = 1 - d; } return this.rz + d * (this.ry - this.rz); } 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.sw = dateMaxValue(); this.sv = dateMinValue(); this.s2 = dateMaxValue(); this.s1 = dateMinValue(); this.sy = dateMaxValue(); this.sx = dateMinValue(); this.tc = null; this.tb = null; this.sr = 0; this.st = null; this.sp = null; this.tl = 0; this.s0 = dateMinValue(); this.sz = dateMaxValue(); this.visibleRangeChanged = null; FastItemDateTimeColumn.o(); this.sp = new TimeAxisLabelFormatCollection(); let a = this.sq; a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.tn)); this.rz = 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.su); this.su = null; } if (this.po != null) { this.su = TimeAxisBase.rk(this.dateTimeMemberPath, this); } break; case "DateTimeMemberPath": if (this.po != null) { this.po.deregisterColumn(this.su); this.su = TimeAxisBase.rk(this.dateTimeMemberPath, this); } break; case "DateTimeColumn": this.ee(); this.tl = this.tk(); break; case "MinimumValue": case "MaximumValue": this.ee(); this.lz(); break; case "LabellingMode": this.lz(); break; } } get actualMinimumValue() { return this.sw; } set actualMinimumValue(a) { this.sw = a; } get actualMaximumValue() { return this.sv; } set actualMaximumValue(a) { this.sv = a; } get visibleMinimum() { return this.s2; } set visibleMinimum(a) { this.s2 = a; } get visibleMaximum() { return this.s1; } set visibleMaximum(a) { this.s1 = a; } get s6() { return this.sy; } set s6(a) { this.sy = a; } get s5() { return this.sx; } set s5(a) { this.sx = a; } to() { if (this.su == null || this.su.count == 0 || this.su.count < this.rz - 1) { this.actualMinimumValue = dateMinValue(); this.actualMaximumValue = dateMaxValue(); return; } let a = Math.max(0, Math.min(this.rz, this.su.count - 1)); let b = Math.max(0, Math.min(this.ry, this.su.count - 1)); let c = +(this.actualMinimumValue) != +(this.su.item(a)) || +(this.actualMaximumValue) != +(this.su.item(b)); if (c) { let d = this.actualMinimumValue; let e = this.actualMaximumValue; this.actualMinimumValue = this.su.item(a); this.actualMaximumValue = this.su.item(b); this.tp(); } } tp() { if (this.su == null || this.su.count == 0 || this.b7 == null) { let a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue); this.visibleMinimum = this.actualMinimumValue; this.visibleMaximum = this.actualMaximumValue; this.s6 = this.visibleMinimum; this.s5 = this.visibleMaximum; if (a && this.visibleRangeChanged != null) { this.visibleRangeChanged(this, EventArgs.empty); } return; } let b = this.o2(); let c = new ScalerParams(1, this.b7.ze, this.b7.zd, 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.su.count ? this.su.item(f) : h; let k = g >= 0 && g < this.su.count ? this.su.item(g) : i; let l = j; let m = k; if (d > f) { let n = f + 1; let o = n >= 0 && n < this.su.count ? this.su.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.su.count ? this.su.item(q) : j; let s = dateSubtract(+k, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+k - +r)) * (g - e)))); m = s; } this.s6 = l; this.s5 = 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.tq(this.actualMinimumValue, false, this.actualMinimumValue, this.ss, this.tj, this.sq, this.hb); if (b != this.tc && this.eh) { this.l5(); } this.tc = b; super.l1(a); } get dateTimeMemberPath() { return this.tb; } set dateTimeMemberPath(a) { let b = this.dateTimeMemberPath; if (a != b) { this.tb = a; this.lu("DateTimeMemberPath", b, this.dateTimeMemberPath); } } get ss() { return this.sr; } set ss(a) { let b = this.ss; if (a != b) { this.sr = a; this.lu("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.ss)); } } get_dr() { return true; } get su() { return this.st; } set su(a) { if (this.st != a) { let b = this.st; this.st = a; this.lu("DateTimeColumn", b, this.st); } } mg(a, b) { super.mg(a, b); this.tp(); } getWindowRectForSelection(a, b) { if (this.su == null) { return Rect.empty; } let c = a > b; let d = c ? b : a; let e = c ? a : b; let f = -1; while (++f < this.su.count && this.su.item(f) < d) { } let g = this.su.count; while (--g >= 0 && this.su.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.yz); 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 sq() { return this.sp; } tn(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.r0 != null) { if (typeCast(Date_$type, this.r0) !== null) { b = this.r0; c = true; } } let d = TimeXAxis.tl(a, c, b, this.ss, this.tj, this.sq, 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.qe - 1) { return super.ja(a); } let c = this.su.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.qe - 1) { b = this.qe - 1; } if (this.su == null) { return dateMinValue(); } let c = this.su.item(b); return c; } get tm() { return +(this.visibleMaximum) - +(this.visibleMinimum); } get tj() { return +(this.s5) - +(this.s6); } rj() { return this.su; } mf(a, b) { super.mf(a, b); this.tp(); } rs(a, b) { let c = this.categoryMode == 0 ? 0 : 0.5; return super.rs(a + c, b); } rr(a, b, c, d) { return b; } tk() { if (this.su == null || this.su.count < 2) { return (0); } return TimeXAxis.tw((a) => this.su.item(a), this.su.count); } itemLabelFormat() { return TimeXAxis.ts(this.tl); } get minimumValue() { return this.s0; } set minimumValue(a) { let b = this.minimumValue; if (+a != +b) { this.s0 = a; this.lc(this, "MinimumValue", b, this.minimumValue); } } get maximumValue() { return this.sz; } set maximumValue(a) { let b = this.maximumValue; if (+a != +b) { this.sz = 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.su == null) { return false; } let a = this.rz; if (+(this.minimumValue) != +(dateMinValue())) { let b = -1; while (b++ <= this.su.count) { if (this.su.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.su.item(d) <= this.maximumValue) { break; } } c = d; } if (a != this.rz || c != this.ry) { let e = new AxisRangeChangedEventArgs(0, this.rz, a, this.ry, c); this.rz = a; this.ry = c; this.lv(e); this.to(); this.qt(); return true; } return false; } q2(a) { super.q2(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; })();