UNPKG

igniteui-angular-charts

Version:

Ignite UI Angular charting components for building rich data visualizations for modern web apps.

537 lines (536 loc) 16.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-angular-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-angular-core"; import { ScalerParams } from "./ScalerParams"; import { NumericScaler } from "./NumericScaler"; import { EventArgs, runOn, delegateCombine, typeCast, enumGetBox, Date_$type, markType } from "igniteui-angular-core"; import { IFastItemsSource_$type } from "igniteui-angular-core"; import { TimeAxisBase } from "./TimeAxisBase"; import { TimeXAxis } from "./TimeXAxis"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { truncate } from "igniteui-angular-core"; import { dateMaxValue, dateMinValue, dateAdd, dateSubtract } from "igniteui-angular-core"; import { timeSpanFromMilliseconds, timeSpanTotalMilliseconds } from "igniteui-angular-core"; /** * @hidden */ export class OrdinalTimeXAxis extends CategoryXAxis { static { this.$t = markType(OrdinalTimeXAxis, 'OrdinalTimeXAxis', CategoryXAxis.$, [ITimeRangeSelectorAxis_$type, IOrdinalAxis_$type]); } gd(a, b, c) { return this.gc(a, new ScalerParams(0, b, c, this.dr, this.pf())); } gb(a, b, c) { return this.gc(a, b); } gc(a, b) { if (!b.c.isEmpty) { let c = this.tl(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.tl(a, b.e, b.d); } tl(a, b, c) { let d = this.sa; let e = this.sb; let f = this.sa - this.sb; let g = f >= 1 ? (a - e) / (d - e) : f == 0 ? 0.5 : NaN; if (this.ds) { g = 1 - g; } return c.left + c.width * (g - b.left) / b.width; } la(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.sa; let u = this.sb; let v = this.sa - this.sb; let w = this.rt(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; } } } } lb(a, b, c, d) { for (let e = b; e < c; e++) { a.item(e, this.gc(a.item(e), d)); } } gg(a, b, c) { return this.gf(a, new ScalerParams(0, b, this.pk, this.dr, this.pf())); } getUnscaledValue3(a, b, c, d) { return this.gf(a, new ScalerParams(0, b, this.pk, this.dr, this.pf())); } gf(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.tm(c, NumericScaler.ac, b.c); return c; } return this.tm(a, b.e, b.d); } tm(a, b, c) { let d = b.left + (a - c.left) * b.width / c.width; if (this.ds) { d = 1 - d; } return this.sb + d * (this.sa - this.sb); } ge(a, b, c) { return this.gf(a, b); } lc(a, b, c, d) { for (let e = b; e < c; e++) { a.item(e, this.gf(a.item(e), d)); } } constructor() { super(); this.s8 = dateMaxValue(); this.s7 = dateMinValue(); this.te = dateMaxValue(); this.td = dateMinValue(); this.ta = dateMaxValue(); this.s9 = dateMinValue(); this.to = null; this.tn = null; this.s3 = 0; this.s5 = null; this.s1 = null; this.tx = 0; this.tc = dateMinValue(); this.tb = dateMaxValue(); this.visibleRangeChanged = null; FastItemDateTimeColumn.o(); this.s1 = new TimeAxisLabelFormatCollection(); let a = this.s2; a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.tz)); this.sb = 0; } al() { return new OrdinalTimeXAxis(); } lk(a, b, c, d) { super.lk(a, b, c, d); switch (b) { case "FastItemsSource": let e = typeCast(IFastItemsSource_$type, c); if (e != null) { e.deregisterColumn(this.s6); this.s6 = null; } if (this.p0 != null) { this.s6 = TimeAxisBase.rv(this.dateTimeMemberPath, this); } break; case "DateTimeMemberPath": if (this.p0 != null) { this.p0.deregisterColumn(this.s6); this.s6 = TimeAxisBase.rv(this.dateTimeMemberPath, this); } break; case "DateTimeColumn": this.ei(); this.tx = this.tw(); break; case "MinimumValue": case "MaximumValue": this.ei(); this.l7(); break; case "LabellingMode": this.l7(); break; } } get actualMinimumValue() { return this.s8; } set actualMinimumValue(a) { this.s8 = a; } get actualMaximumValue() { return this.s7; } set actualMaximumValue(a) { this.s7 = a; } get visibleMinimum() { return this.te; } set visibleMinimum(a) { this.te = a; } get visibleMaximum() { return this.td; } set visibleMaximum(a) { this.td = a; } get ti() { return this.ta; } set ti(a) { this.ta = a; } get th() { return this.s9; } set th(a) { this.s9 = a; } t0() { if (this.s6 == null || this.s6.count == 0 || this.s6.count < this.sb - 1) { this.actualMinimumValue = dateMinValue(); this.actualMaximumValue = dateMaxValue(); return; } let a = Math.max(0, Math.min(this.sb, this.s6.count - 1)); let b = Math.max(0, Math.min(this.sa, this.s6.count - 1)); let c = +(this.actualMinimumValue) != +(this.s6.item(a)) || +(this.actualMaximumValue) != +(this.s6.item(b)); if (c) { let d = this.actualMinimumValue; let e = this.actualMaximumValue; this.actualMinimumValue = this.s6.item(a); this.actualMaximumValue = this.s6.item(b); this.t1(); } } t1() { if (this.s6 == null || this.s6.count == 0 || this.b7 == null) { let a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue); this.visibleMinimum = this.actualMinimumValue; this.visibleMaximum = this.actualMaximumValue; this.ti = this.visibleMinimum; this.th = this.visibleMaximum; if (a && this.visibleRangeChanged != null) { this.visibleRangeChanged(this, EventArgs.empty); } return; } let b = this.pe(); let c = new ScalerParams(1, this.b7.ze, this.b7.zd, this.dr); c.c = this.pf(); let d = this.gf(b.left, c); let e = this.gf(b.right, c); let f = truncate(Math.floor(d)); let g = truncate(Math.ceil(e)); let h = this.dr ? this.actualMaximumValue : this.actualMinimumValue; let i = this.dr ? this.actualMinimumValue : this.actualMaximumValue; let j = f >= 0 && f < this.s6.count ? this.s6.item(f) : h; let k = g >= 0 && g < this.s6.count ? this.s6.item(g) : i; let l = j; let m = k; if (d > f) { let n = f + 1; let o = n >= 0 && n < this.s6.count ? this.s6.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.s6.count ? this.s6.item(q) : j; let s = dateSubtract(+k, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+k - +r)) * (g - e)))); m = s; } this.ti = l; this.th = 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); } } l9(a) { let b = TimeXAxis.t3(this.actualMinimumValue, false, this.actualMinimumValue, this.s4, this.tv, this.s2, this.hf); if (b != this.to && this.el) { this.md(); } this.to = b; super.l9(a); } get dateTimeMemberPath() { return this.tn; } set dateTimeMemberPath(a) { let b = this.dateTimeMemberPath; if (a != b) { this.tn = a; this.l2("DateTimeMemberPath", b, this.dateTimeMemberPath); } } get s4() { return this.s3; } set s4(a) { let b = this.s4; if (a != b) { this.s3 = a; this.l2("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.s4)); } } get_dv() { return true; } get s6() { return this.s5; } set s6(a) { if (this.s5 != a) { let b = this.s5; this.s5 = a; this.l2("DateTimeColumn", b, this.s5); } } mo(a, b) { super.mo(a, b); this.t1(); } getWindowRectForSelection(a, b) { if (this.s6 == null) { return Rect.empty; } let c = a > b; let d = c ? b : a; let e = c ? a : b; let f = -1; while (++f < this.s6.count && this.s6.item(f) < d) { } let g = this.s6.count; while (--g >= 0 && this.s6.item(g) > e) { } let h = new ScalerParams(0, new Rect(0, 0, 0, 1, 1), new Rect(0, 0, 0, 1, 1), this.dr, this.b7.yz); let i = this.gc(f, h); let j = this.gc(g + 1, h); return new Rect(0, i, NaN, Math.max(0, j - i), NaN); } get s2() { return this.s1; } tz(a, b) { this.l8(false); } lm(a) { super.lm(a); this.dateTimeMemberPath = a; } h2(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.h2(a); } let b = dateMinValue(); let c = false; if (this.sc != null) { if (typeCast(Date_$type, this.sc) !== null) { b = this.sc; c = true; } } let d = TimeXAxis.ty(a, c, b, this.s4, this.tv, this.s2, this.hf); return d == null ? super.h2(a) : d; } jh(a) { let b = 0; if (this.categoryMode == 0) { b = truncate(Math.round(a)); } else { b = truncate(Math.floor(a)); } if (b < 0 || b > this.qq - 1) { return super.jh(a); } let c = this.s6.item(b); let d = this.h2(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.qq - 1) { b = this.qq - 1; } if (this.s6 == null) { return dateMinValue(); } let c = this.s6.item(b); return c; } get ty() { return +(this.visibleMaximum) - +(this.visibleMinimum); } get tv() { return +(this.th) - +(this.ti); } rv() { return this.s6; } mn(a, b) { super.mn(a, b); this.t1(); } r4(a, b) { let c = this.categoryMode == 0 ? 0 : 0.5; return super.r4(a + c, b); } r3(a, b, c, d) { return b; } tw() { if (this.s6 == null || this.s6.count < 2) { return (0); } return TimeXAxis.t9((a) => this.s6.item(a), this.s6.count); } itemLabelFormat() { return TimeXAxis.t5(this.tx); } get minimumValue() { return this.tc; } set minimumValue(a) { let b = this.minimumValue; if (+a != +b) { this.tc = a; this.lk(this, "MinimumValue", b, this.minimumValue); } } get maximumValue() { return this.tb; } set maximumValue(a) { let b = this.maximumValue; if (+a != +b) { this.tb = a; this.lk(this, "MaximumValue", b, this.maximumValue); } } ek() { if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) { return super.ek(); } if (this.d5 && this.el) { this.b1 = this.b0(); } if (this.p0 == null || this.s6 == null) { return false; } let a = this.sb; if (+(this.minimumValue) != +(dateMinValue())) { let b = -1; while (b++ <= this.s6.count) { if (this.s6.item(b) >= this.minimumValue) { break; } } a = b; } let c = this.categoryMode == 0 ? this.p0.count - 1 : this.p0.count; if (+(this.maximumValue) != +(dateMaxValue())) { let d = this.p0.count; while (d-- > 0) { if (this.s6.item(d) <= this.maximumValue) { break; } } c = d; } if (a != this.sb || c != this.sa) { let e = new AxisRangeChangedEventArgs(0, this.sb, a, this.sa, c); this.sb = a; this.sa = c; this.l3(e); this.t0(); this.q5(); return true; } return false; } re(a) { super.re(a); this.ej(true); } get isVertical() { return this.d3; } j$d(a, b) { return this.gf.apply(this, arguments); } j$c(a, b) { return this.gc.apply(this, arguments); } j$e(a, b, c, d, e) { this.la.apply(this, arguments); } j$f(a, b, c, d) { this.lb.apply(this, arguments); } j$g(a, b, c, d) { this.lc.apply(this, arguments); } get j$b() { return this.dr; } j$a() { return this.ag.apply(this, arguments); } }