UNPKG

igniteui-react-charts

Version:

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

538 lines (537 loc) 18.3 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 { fv(a, b, c) { return this.ft(a, new ScalerParams(0, b, c, this.df, this.nw())); } fu(a, b, c) { return this.ft(a, b); } ft(a, b) { if (!b.c.isEmpty) { let 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); } rz(a, b, c) { let d = this.qo; let e = this.qp; let f = this.qo - this.qp; let 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; } j5(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.qo; let u = this.qp; let v = this.qo - this.qp; let w = this.p7(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; } } } } j6(a, b, c, d) { for (let e = b; e < c; e++) { a.item(e, this.ft(a.item(e), d)); } } fy(a, b, c) { return this.fw(a, new ScalerParams(0, b, this.n1, this.df, this.nw())); } getUnscaledValue3(a, b, c, d) { return this.fw(a, new ScalerParams(0, b, this.n1, this.df, this.nw())); } fw(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.r0(c, NumericScaler.ac, b.c); return c; } return this.r0(a, b.e, b.d); } r0(a, b, c) { let d = b.left + (a - c.left) * b.width / c.width; if (this.dg) { d = 1 - d; } return this.qp + d * (this.qo - this.qp); } fx(a, b, c) { return this.fw(a, b); } j7(a, b, c, d) { for (let e = b; e < c; e++) { a.item(e, this.fw(a.item(e), d)); } } constructor() { super(); 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(); let a = this.rg; a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.sd)); this.qp = 0; } ak() { return new OrdinalTimeXAxis(); } kf(a, b, c, d) { super.kf(a, b, c, d); switch (b) { case "FastItemsSource": let 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; } } get actualMinimumValue() { return this.rm; } set actualMinimumValue(a) { this.rm = a; } get actualMaximumValue() { return this.rl; } set actualMaximumValue(a) { this.rl = a; } get visibleMinimum() { return this.rs; } set visibleMinimum(a) { this.rs = a; } get visibleMaximum() { return this.rr; } set visibleMaximum(a) { this.rr = a; } get rw() { return this.ro; } set rw(a) { this.ro = a; } get rv() { return this.rn; } set rv(a) { this.rn = a; } se() { if (this.rk == null || this.rk.count == 0 || this.rk.count < this.qp - 1) { this.actualMinimumValue = dateMinValue(); this.actualMaximumValue = dateMaxValue(); return; } let a = Math.max(0, Math.min(this.qp, this.rk.count - 1)); let b = Math.max(0, Math.min(this.qo, this.rk.count - 1)); let c = +(this.actualMinimumValue) != +(this.rk.item(a)) || +(this.actualMaximumValue) != +(this.rk.item(b)); if (c) { let d = this.actualMinimumValue; let e = this.actualMaximumValue; this.actualMinimumValue = this.rk.item(a); this.actualMaximumValue = this.rk.item(b); this.sf(); } } sf() { if (this.rk == null || this.rk.count == 0 || this.b0 == null) { let 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; } let b = this.nv(); let c = new ScalerParams(1, this.b0.x6, this.b0.x5, this.df); c.c = this.nw(); let d = this.fw(b.left, c); let e = this.fw(b.right, c); let f = truncate(Math.floor(d)); let g = truncate(Math.ceil(e)); let h = f >= 0 && f < this.rk.count ? this.rk.item(f) : this.actualMinimumValue; let i = g >= 0 && g < this.rk.count ? this.rk.item(g) : this.actualMaximumValue; let j = h; let k = i; if (d > f) { let l = f + 1; let m = l >= 0 && l < this.rk.count ? this.rk.item(l) : i; let n = dateAdd(+h, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+m - +h)) * (d - f)))); j = n; } if (e < g) { let o = g - 1; let p = o >= 0 && o < this.rk.count ? this.rk.item(o) : h; let q = dateSubtract(+i, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+i - +p)) * (g - e)))); k = q; } this.rw = j; this.rv = k; let r = +(this.visibleMinimum) != +h || +(this.visibleMaximum) != +i; this.visibleMinimum = h; this.visibleMaximum = i; if (r && this.visibleRangeChanged != null) { this.visibleRangeChanged(this, EventArgs.empty); } } k4(a) { let 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.k4(a); } get dateTimeMemberPath() { return this.r1; } set dateTimeMemberPath(a) { let b = this.dateTimeMemberPath; if (a != b) { this.r1 = a; this.kx("DateTimeMemberPath", b, this.dateTimeMemberPath); } } get ri() { return this.rh; } set ri(a) { let b = this.ri; if (a != b) { this.rh = a; this.kx("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.ri)); } } get_di() { return true; } get rk() { return this.rj; } set rk(a) { if (this.rj != a) { let b = this.rj; this.rj = a; this.kx("DateTimeColumn", b, this.rj); } } lj(a, b) { super.lj(a, b); this.sf(); } getWindowRectForSelection(a, b) { if (this.rk == null) { return Rect.empty; } let c = a > b; let d = c ? b : a; let e = c ? a : b; let f = -1; while (++f < this.rk.count && this.rk.item(f) < d) { } let g = this.rk.count; while (--g >= 0 && this.rk.item(g) > e) { } let h = new ScalerParams(0, new Rect(0, 0, 0, 1, 1), new Rect(0, 0, 0, 1, 1), this.df, this.b0.xr); let i = this.ft(f, h); let j = this.ft(g + 1, h); return new Rect(0, i, NaN, Math.max(0, j - i), NaN); } get rg() { return this.rf; } sd(a, b) { this.k3(false); } kh(a) { super.kh(a); this.dateTimeMemberPath = a; } hf(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.hf(a); } let b = dateMinValue(); let c = false; if (this.qq != null) { if (typeCast(Date_$type, this.qq) !== null) { b = this.qq; c = true; } } let d = TimeXAxis.sa(a, c, b, this.ri, this.r9, this.rg, this.gw); return d == null ? super.hf(a) : d; } ih(a) { let 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.ih(a); } let c = this.rk.item(b); let d = this.hf(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.o6 - 1) { b = this.o6 - 1; } if (this.rk == null) { return dateMinValue(); } let c = this.rk.item(b); return c; } get sc() { return +(this.visibleMaximum) - +(this.visibleMinimum); } get r9() { return +(this.rv) - +(this.rw); } p9() { return this.rk; } li(a, b) { super.li(a, b); this.sf(); } qi(a, b) { let c = this.categoryMode == 0 ? 0 : 0.5; return super.qi(a + c, b); } qh(a, b, c, d) { return b; } sa() { if (this.rk == null || this.rk.count < 2) { return (0); } return TimeXAxis.sl((a) => this.rk.item(a), this.rk.count); } itemLabelFormat() { return TimeXAxis.sh(this.sb); } get minimumValue() { return this.rq; } set minimumValue(a) { let b = this.minimumValue; if (+a != +b) { this.rq = a; this.kf(this, "MinimumValue", b, this.minimumValue); } } get maximumValue() { return this.rp; } set maximumValue(a) { let b = this.maximumValue; if (+a != +b) { this.rp = a; this.kf(this, "MaximumValue", b, this.maximumValue); } } d4() { if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) { return super.d4(); } if (this.dr && this.d5) { this.bu = this.bt(); } if (this.oh == null || this.rk == null) { return false; } let a = this.qp; if (+(this.minimumValue) != +(dateMinValue())) { let b = -1; while (b++ <= this.rk.count) { if (this.rk.item(b) >= this.minimumValue) { break; } } a = b; } let c = this.categoryMode == 0 ? this.oh.count - 1 : this.oh.count; if (+(this.maximumValue) != +(dateMaxValue())) { let d = this.oh.count; while (d-- > 0) { if (this.rk.item(d) <= this.maximumValue) { break; } } c = d; } if (a != this.qp || c != this.qo) { let 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; } pt(a) { super.pt(a); this.d3(true); } get isVertical() { return this.dq; } j$d(a, b) { return this.fw.apply(this, arguments); } j$c(a, b) { return this.ft.apply(this, arguments); } j$e(a, b, c, d, e) { this.j5.apply(this, arguments); } j$f(a, b, c, d) { this.j6.apply(this, arguments); } j$g(a, b, c, d) { this.j7.apply(this, arguments); } get j$b() { return this.df; } j$a() { return this.ag.apply(this, arguments); } } OrdinalTimeXAxis.$t = /*@__PURE__*/ markType(OrdinalTimeXAxis, 'OrdinalTimeXAxis', CategoryXAxis.$, [ITimeRangeSelectorAxis_$type, IOrdinalAxis_$type]); return OrdinalTimeXAxis; })();