UNPKG

igniteui-angular-charts

Version:

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

535 lines (534 loc) 18.8 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 let OrdinalTimeXAxis = /*@__PURE__*/ (() => { class OrdinalTimeXAxis extends CategoryXAxis { constructor() { super(); this.nu = dateMaxValue(); this.nt = dateMinValue(); this.n0 = dateMaxValue(); this.nz = dateMinValue(); this.nw = dateMaxValue(); this.nv = dateMinValue(); this.oa = null; this.n9 = null; this.np = 0; this.nr = null; this.nn = null; this.oj = 0; this.ny = dateMinValue(); this.nx = dateMaxValue(); this.visibleRangeChanged = null; FastItemDateTimeColumn.o(); this.nn = new TimeAxisLabelFormatCollection(); let a = this.no; a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.ol)); this.m1 = 0; } en(a, b, c) { return this.el(a, new ScalerParams(0, b, c, this.ch, this.kc())); } em(a, b, c) { return this.el(a, b); } el(a, b) { if (!b.c.isEmpty) { let c = this.n7(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.n7(a, b.e, b.d); } n7(a, b, c) { let d = this.m0; let e = this.m1; let f = this.m0 - this.m1; let g = f >= 1 ? (a - e) / (d - e) : f == 0 ? 0.5 : NaN; if (this.ci) { g = 1 - g; } return c.left + c.width * (g - b.left) / b.width; } hp(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.m0; let u = this.m1; let v = this.m0 - this.m1; let w = this.ml(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; } } } } hq(a, b, c, d) { for (let e = b; e < c; e++) { a.item(e, this.el(a.item(e), d)); } } eq(a, b, c) { return this.eo(a, new ScalerParams(0, b, this.kh, this.ch, this.kc())); } getUnscaledValue3(a, b, c, d) { return this.eo(a, new ScalerParams(0, b, this.kh, this.ch, this.kc())); } eo(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.n8(c, NumericScaler.ac, b.c); return c; } return this.n8(a, b.e, b.d); } n8(a, b, c) { let d = b.left + (a - c.left) * b.width / c.width; if (this.ci) { d = 1 - d; } return this.m1 + d * (this.m0 - this.m1); } ep(a, b, c) { return this.eo(a, b); } hr(a, b, c, d) { for (let e = b; e < c; e++) { a.item(e, this.eo(a.item(e), d)); } } hz(a, b, c, d) { super.hz(a, b, c, d); switch (b) { case "FastItemsSource": let e = typeCast(IFastItemsSource_$type, c); if (e != null) { e.deregisterColumn(this.ns); this.ns = null; } if (this.kv != null) { this.ns = TimeAxisBase.mo(this.dateTimeMemberPath, this); } break; case "DateTimeMemberPath": if (this.kv != null) { this.kv.deregisterColumn(this.ns); this.ns = TimeAxisBase.mo(this.dateTimeMemberPath, this); } break; case "DateTimeColumn": this.c1(); this.oj = this.oi(); break; case "MinimumValue": case "MaximumValue": this.c1(); this.ia(); break; case "LabellingMode": this.ia(); break; } } get actualMinimumValue() { return this.nu; } set actualMinimumValue(a) { this.nu = a; } get actualMaximumValue() { return this.nt; } set actualMaximumValue(a) { this.nt = a; } get visibleMinimum() { return this.n0; } set visibleMinimum(a) { this.n0 = a; } get visibleMaximum() { return this.nz; } set visibleMaximum(a) { this.nz = a; } get n4() { return this.nw; } set n4(a) { this.nw = a; } get n3() { return this.nv; } set n3(a) { this.nv = a; } om() { if (this.ns == null || this.ns.count == 0 || this.ns.count < this.m1 - 1) { this.actualMinimumValue = dateMinValue(); this.actualMaximumValue = dateMaxValue(); return; } let a = Math.max(0, Math.min(this.m1, this.ns.count - 1)); let b = Math.max(0, Math.min(this.m0, this.ns.count - 1)); let c = +(this.actualMinimumValue) != +(this.ns.item(a)) || +(this.actualMaximumValue) != +(this.ns.item(b)); if (c) { let d = this.actualMinimumValue; let e = this.actualMaximumValue; this.actualMinimumValue = this.ns.item(a); this.actualMaximumValue = this.ns.item(b); this.on(); } } on() { if (this.ns == null || this.ns.count == 0 || this.bi == null) { let a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue); this.visibleMinimum = this.actualMinimumValue; this.visibleMaximum = this.actualMaximumValue; this.n4 = this.visibleMinimum; this.n3 = this.visibleMaximum; if (a && this.visibleRangeChanged != null) { this.visibleRangeChanged(this, EventArgs.empty); } return; } let b = this.kb(); let c = new ScalerParams(1, this.bi.wl, this.bi.wk, this.ch); c.c = this.kc(); let d = this.eo(b.left, c); let e = this.eo(b.right, c); let f = truncate(Math.floor(d)); let g = truncate(Math.ceil(e)); let h = f >= 0 && f < this.ns.count ? this.ns.item(f) : this.actualMinimumValue; let i = g >= 0 && g < this.ns.count ? this.ns.item(g) : this.actualMaximumValue; let j = h; let k = i; if (d > f) { let l = f + 1; let m = l >= 0 && l < this.ns.count ? this.ns.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.ns.count ? this.ns.item(o) : h; let q = dateSubtract(+i, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+i - +p)) * (g - e)))); k = q; } this.n4 = j; this.n3 = 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); } } ic(a) { let b = TimeXAxis.ot(this.actualMinimumValue, false, this.actualMinimumValue, this.nq, this.oh, this.no, this.fm); if (b != this.oa && this.c4) { this.ih(); } this.oa = b; super.ic(a); } get dateTimeMemberPath() { return this.n9; } set dateTimeMemberPath(a) { let b = this.dateTimeMemberPath; if (a != b) { this.n9 = a; this.h5("DateTimeMemberPath", b, this.dateTimeMemberPath); } } get nq() { return this.np; } set nq(a) { let b = this.nq; if (a != b) { this.np = a; this.h5("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.nq)); } } get_ck() { return true; } get ns() { return this.nr; } set ns(a) { if (this.nr != a) { let b = this.nr; this.nr = a; this.h5("DateTimeColumn", b, this.nr); } } it(a, b) { super.it(a, b); this.on(); } getWindowRectForSelection(a, b) { if (this.ns == null) { return Rect.empty; } let c = a > b; let d = c ? b : a; let e = c ? a : b; let f = -1; while (++f < this.ns.count && this.ns.item(f) < d) { } let g = this.ns.count; while (--g >= 0 && this.ns.item(g) > e) { } let h = new ScalerParams(0, new Rect(0, 0, 0, 1, 1), new Rect(0, 0, 0, 1, 1), this.ch, this.bi.v8); let i = this.el(f, h); let j = this.el(g + 1, h); return new Rect(0, i, NaN, Math.max(0, j - i), NaN); } get no() { return this.nn; } ol(a, b) { this.ib(false); } h1(a) { super.h1(a); this.dateTimeMemberPath = a; } f1(a) { if (this.au != null) { return this.au(a); } if (this.ai != null) { return this.ai.i(a); } if (!(typeCast(Date_$type, a) !== null)) { return super.f1(a); } let b = dateMinValue(); let c = false; if (this.m2 != null) { if (typeCast(Date_$type, this.m2) !== null) { b = this.m2; c = true; } } let d = TimeXAxis.oo(a, c, b, this.nq, this.oh, this.no, this.fm); return d == null ? super.f1(a) : d; } gf(a) { let b = 0; if (this.categoryMode == 0) { b = truncate(Math.round(a)); } else { b = truncate(Math.floor(a)); } if (b < 0 || b > this.lk - 1) { return super.gf(a); } let c = this.ns.item(b); let d = this.f1(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.lk - 1) { b = this.lk - 1; } if (this.ns == null) { return dateMinValue(); } let c = this.ns.item(b); return c; } get ok() { return +(this.visibleMaximum) - +(this.visibleMinimum); } get oh() { return +(this.n3) - +(this.n4); } mn() { return this.ns; } is(a, b) { super.is(a, b); this.on(); } mu(a, b) { let c = this.categoryMode == 0 ? 0 : 0.5; return super.mu(a + c, b); } mt(a, b, c, d) { return b; } oi() { if (this.ns == null || this.ns.count < 2) { return (0); } return TimeXAxis.oz((a) => this.ns.item(a), this.ns.count); } itemLabelFormat() { return TimeXAxis.ov(this.oj); } get minimumValue() { return this.ny; } set minimumValue(a) { let b = this.minimumValue; if (+a != +b) { this.ny = a; this.hz(this, "MinimumValue", b, this.minimumValue); } } get maximumValue() { return this.nx; } set maximumValue(a) { let b = this.maximumValue; if (+a != +b) { this.nx = a; this.hz(this, "MaximumValue", b, this.maximumValue); } } c3() { if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) { return super.c3(); } if (this.cq && this.c4) { this.bc = this.bb(); } if (this.kv == null || this.ns == null) { return false; } let a = this.m1; if (+(this.minimumValue) != +(dateMinValue())) { let b = -1; while (b++ <= this.ns.count) { if (this.ns.item(b) >= this.minimumValue) { break; } } a = b; } let c = this.categoryMode == 0 ? this.kv.count - 1 : this.kv.count; if (+(this.maximumValue) != +(dateMaxValue())) { let d = this.kv.count; while (d-- > 0) { if (this.ns.item(d) <= this.maximumValue) { break; } } c = d; } if (a != this.m1 || c != this.m0) { let e = new AxisRangeChangedEventArgs(0, this.m1, a, this.m0, c); this.m1 = a; this.m0 = c; this.h6(e); this.om(); this.ly(); return true; } return false; } l7(a) { super.l7(a); this.c2(true); } get isVertical() { return this.cp; } j$d(a, b) { return this.eo.apply(this, arguments); } j$c(a, b) { return this.el.apply(this, arguments); } j$e(a, b, c, d, e) { this.hp.apply(this, arguments); } j$f(a, b, c, d) { this.hq.apply(this, arguments); } j$g(a, b, c, d) { this.hr.apply(this, arguments); } get j$b() { return this.ch; } j$a() { return this.ag.apply(this, arguments); } } OrdinalTimeXAxis.$t = markType(OrdinalTimeXAxis, 'OrdinalTimeXAxis', CategoryXAxis.$, [ITimeRangeSelectorAxis_$type, IOrdinalAxis_$type]); return OrdinalTimeXAxis; })();