UNPKG

igniteui-angular-charts

Version:

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

677 lines (676 loc) 20 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 { CategoryAxisBase } from "./CategoryAxisBase"; import { ISortingAxis_$type } from "./ISortingAxis"; import { IDateTimeAxis_$type } from "./IDateTimeAxis"; import { DependencyProperty } from "igniteui-angular-core"; import { List$1 } from "igniteui-angular-core"; import { typeCast, Number_$type, Date_$type, fromEnum, runOn, delegateRemove, delegateCombine, markType, markDep, TypeRegistrar } from "igniteui-angular-core"; import { ScalerParams } from "./ScalerParams"; import { Rect } from "igniteui-angular-core"; import { NumericScaler } from "./NumericScaler"; import { SeriesViewer } from "./SeriesViewer"; import { SortedListView$1 } from "./SortedListView$1"; import { ArrayExtension } from "igniteui-angular-core"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { IFastItemsSource_$type } from "igniteui-angular-core"; import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel"; import { PropertyMetadata } from "igniteui-angular-core"; import { truncate, isNaN_ } from "igniteui-angular-core"; import { dateMinValue, dateSubtract, dateAdd, dateMaxValue, dateFromTicks } from "igniteui-angular-core"; /** * @hidden */ export class TimeAxisBase extends CategoryAxisBase { static { this.$t = markType(TimeAxisBase, 'TimeAxisBase', CategoryAxisBase.$, [ISortingAxis_$type, IDateTimeAxis_$type]); } constructor() { super(); this.rt = null; this.r2 = null; this.rx = false; this.r5 = dateMaxValue(); this.r4 = dateMinValue(); FastItemDateTimeColumn.o(); } jg() { return TimeAxisBase.$$p[0]; } jf(a) { let b = this.jx(a); if (b == TimeAxisBase.$$p[0]) { return this.dateTimeMemberPath; } return super.jf(a); } ag() { return [this.actualMinimumValue.getTime(), this.actualMaximumValue.getTime()]; } gc(a, b) { if (!b.c.isEmpty) { let c = this.sa(a, NumericScaler.ac, b.c, Rect.empty); 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.sa(a, b.e, b.d, b.c); } h0(a, b) { let c = this.jx(b); if (c == TimeAxisBase.$$p[0]) { return this.h1(a, b, this.dateTimeMemberPath); } return super.h0(a, b); } sa(a, b, c, d) { let e; if (+(this.actualMaximumValue) == +(this.actualMinimumValue)) { e = -1; } else { e = (a - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); } let f = 0; if (this.categoryMode == 2) { f = this.getGroupCenter(0, b, c, d); } if (this.dr) { e = 1 - e; f = -f; } return c.left + c.width * (e - b.left) / b.width - f; } sb(a, b, c) { let d; if (+(this.actualMaximumValue) == +(this.actualMinimumValue)) { d = -1; } else { d = (a - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); } let e = 0; if (this.dr) { d = 1 - d; e = -e; } return c.left + c.width * (d - b.left) / b.width - e; } gf(a, b) { if (!b.c.isEmpty) { let c = b.d.left; let d = b.d.width; if (this.categoryMode != 0) { let e = this.getCategorySize(b.e, b.d, b.c); c += e / 2; d -= e; } let f = b.e.left + b.e.width * (a - c) / b.d.width; f = (f * b.d.width) + b.d.left; f = this.getUnscaledValue3(f, NumericScaler.ac, b.c, this.categoryMode); return f; } return this.getUnscaledValue3(a, b.e, b.d, this.categoryMode); } getUnscaledValue3(a, b, c, d) { let e = b.left + b.width * (a - c.left) / c.width; if (this.dr) { e = 1 - e; } return truncate(Math.floor(this.actualMinimumValue.getTime() + e * (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()))); } i$h() { this.sq(); } sq() { let a = this.b7 != null ? this.b7.yv : Rect.empty; let b = !a.isEmpty ? this.pk : Rect.empty; let c = (new Date()); let d = (new Date()); let e = false; if (!a.isEmpty && !b.isEmpty && this.ru != null) { let f = typeCast(FastItemDateTimeColumn.$, this.ru); if (f != null) { if (this.r3 == null) { this.sr(); } } else { this.r3 = null; } if (this.ru.count > 0) { e = true; let g = this.r3 == null ? 0 : this.r3._inner[0]; let h = this.r3 == null ? this.ru.count - 1 : this.r3._inner[this.ru.count - 1]; c = this.ru.item(g); d = this.ru.item(h); this.ry = false; if (this.categoryMode == 2) { let i = this.so(c, d); if (+c != +(dateMinValue())) { c = dateSubtract(+c, +i); } d = dateAdd(+d, +i); } } } if (this.r1()) { e = true; c = this.minimumValue; } if (this.r0()) { e = true; d = this.maximumValue; } let j = +(this.actualMinimumValue) != +c || +(this.actualMaximumValue) != +d; if (e && j) { let k = this.actualMinimumValue; let l = this.actualMaximumValue; this.actualMinimumValue = c; this.actualMaximumValue = d; this.sv(); } } sv() { } get ru() { return this.rt; } set ru(a) { if (this.rt != a) { let b = this.rt; this.rt = a; this.l2("DateTimeColumn", b, this.rt); } } get r3() { return this.r2; } set r3(a) { this.r2 = a; } get i$b() { if (this.r3 == null) { let a = typeCast(FastItemDateTimeColumn.$, this.ru); if (a != null) { this.sr(); } else { this.r3 = null; } } return this.r3; } sr() { if (this.rz) { this.r3 = new List$1(Number_$type, 0); let a = this.r3; let b = this.ru.count; for (let c = 0; c < b; c++) { a.add(c); } } else { let d = typeCast(FastItemDateTimeColumn.$, this.ru); this.r3 = d.h(); } } i$e(a, b, c, d) { return this.sd(a, b, c, d); } sd(a, b, c, d) { if (b.isEmpty) { return -1; } let e = d; let f = new ScalerParams(0, a, b, this.dr, c); let g, h; if (this.dr) { h = this.gf(e.left, f); g = this.gf(e.right, f); } else { g = this.gf(e.left, f); h = this.gf(e.right, f); } let i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(g))); return this.sc(dateFromTicks(i)); } sc(a) { if (this.ru == null || this.r3.count != this.ru.count) { return -1; } let b = new SortedListView$1(Date_$type, this.ru, this.r3); let c = this.se(a, b); if (c >= 0 && c < this.r3.count) { let d = this.ru.item(this.r3._inner[c]); if (d > a) { c--; if (c < 0) { c = 0; } } return c; } return this.r3.count - 1; } i$g(a, b, c, d) { return this.sg(a, b, c, d); } sg(a, b, c, d) { if (b.isEmpty) { return -1; } let e = d; let f = new ScalerParams(0, a, b, this.dr, c); let g, h; if (this.dr) { h = this.gf(e.left, f); g = this.gf(e.right, f); } else { g = this.gf(e.left, f); h = this.gf(e.right, f); } let i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(h))); return this.sf(dateFromTicks(i)); } sf(a) { if (this.ru == null || this.r3.count != this.ru.count) { return -1; } let b = new SortedListView$1(Date_$type, this.ru, this.r3); let c = this.se(a, b); if (c >= this.r3.count) { c = this.r3.count - 1; } if (c >= 0 && c < this.r3.count) { let d = this.ru.item(this.r3._inner[c]); if (d < a) { c++; if (c > this.r3.count - 1) { c = this.r3.count - 1; } } return c; } return 0; } i$d(a) { if (this.ru == null) { return NaN; } let b = this.rt.item(a); let c = b.getTime(); let d = c; return d; } i$c(a) { let b = this; if (b.i$b == null) { return -1; } let c = new SortedListView$1(Date_$type, this.ru, b.i$b); let ticks_ = a; let d = (new Date(ticks_)); let e = this.se(d, c); if (e >= 0 && e < b.i$b.count && e - 1 >= 0 && e - 1 < b.i$b.count) { let diff1_ = d.getTime() - c.item(e - 1).getTime(); let diff2_ = c.item(e).getTime() - d.getTime(); let f = e - 1; let g = e; if (f < 0 && g >= 0) { return g; } if (g > b.i$b.count - 1 && f < b.i$b.count) { return f; } if (f < 0 && g < 0) { return -1; } if (f > b.i$b.count - 1 && g > b.i$b.count - 1) { return -1; } let h = diff1_ / (diff1_ + diff2_); if (isNaN_(h)) { h = 0; } return f + h; } if (e >= 0 && e < b.i$b.count) { return e; } let i = this.pf(); if (e == b.i$b.count && this.b7 != null && this.gc(a, new ScalerParams(0, this.b7.yv, this.pk, this.dr, i)) < (this.pk.right + 2)) { return e - 1; } if (e == -1 && this.b7 != null && Math.abs(this.gc(a, new ScalerParams(0, this.b7.yv, this.pk, this.dr, i)) - this.pk.left) < 2) { return 0; } return -1; } se(a, b) { let c = this; if (this.ru == null || c.i$b == null) { return -1; } let d = -1; let e = ArrayExtension.binarySearch$11(Date_$type, b, (f) => { if (a < f) { return -1; } if (a > f) { return 1; } return 0; }); if (e >= 0) { d = e; } else { d = ~e; } while (d >= 0 && d < b.count && d - 1 >= 0 && +(b.item(d)) == +(b.item(d - 1))) { d--; } return d; } i$f(a) { let b = this; if (b.i$b == null || this.ru == null || b.i$b.count != this.ru.count) { return -1; } let c = new SortedListView$1(Date_$type, this.ru, b.i$b); let ticks_ = a; let d = (new Date(ticks_)); let e = this.se(d, c); let f = this.pf(); if (e >= 0 && e < b.i$b.count && e - 1 >= 0 && e - 1 < b.i$b.count) { let g = +d - +(c.item(e - 1)); let h = +(c.item(e)) - +d; if (g < h) { e = e - 1; } } if (e >= 0 && e < b.i$b.count) { return b.i$b._inner[e]; } if (e == b.i$b.count && this.b7 != null && this.gc(a, new ScalerParams(0, this.b7.yv, this.pk, this.dr, f)) < (this.pk.right + 2)) { return e - 1; } if (e == -1 && this.b7 != null && Math.abs(this.gc(a, new ScalerParams(0, this.b7.yv, this.pk, this.dr, f)) - this.pk.left) < 2) { return 0; } return -1; } i$i() { this.r3 = null; this.l7(); } get_ry() { return this.rx; } set_ry(a) { this.rx = a; } get ry() { return this.get_ry(); } set ry(a) { this.set_ry(a); } lm(a) { super.lm(a); this.dateTimeMemberPath = a; } lp(a) { super.lp(a); this.minimumValue = a; } lo(a) { super.lp(a); this.maximumValue = a; } ek() { if (this.d5 && this.el) { this.b1 = this.b0(); } let a = this.actualMinimumValue.getTime(); let b = this.actualMaximumValue.getTime(); this.sq(); let c = !this.r1() ? this.actualMinimumValue.getTime() : this.minimumValue.getTime(); let d = !this.r0() ? this.actualMaximumValue.getTime() : this.maximumValue.getTime(); let e = new AxisRangeChangedEventArgs(0, a, c, b, d); this.l3(e); return true; } r1() { if (+(this.minimumValue) == +(dateMinValue())) { return false; } return (this.minimumValue != null); } r0() { if (+(this.maximumValue) == +(dateMaxValue())) { return false; } return (this.maximumValue != null); } get actualMinimumValue() { return this.r5; } set actualMinimumValue(a) { let b = +(this.r5) != +a; if (b) { let c = this.r5; this.r5 = a; this.l2("ActualMinimumValue", c, a); } } h5() { return this.actualMinimumValue; } get actualMaximumValue() { return this.r4; } set actualMaximumValue(a) { let b = +(this.r4) != +a; if (b) { let c = this.r4; this.r4 = a; this.l2("ActualMaximumValue", c, a); } } h4() { return this.maximumValue; } ss(a) { this.l9(a); if (this.p0 == null) { return; } for (let b of fromEnum(this.et())) { b.sa(a); } } 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.ru); this.ru = null; e.event = delegateRemove(e.event, runOn(this, this.sp)); } let f = typeCast(IFastItemsSource_$type, d); if (f != null) { this.r3 = null; this.ru = this.rw(this.dateTimeMemberPath); f.event = delegateCombine(f.event, runOn(this, this.sp)); } this.ss(false); break; case TimeAxisBase.$$p[0]: if (this.p0 != null) { this.p0.deregisterColumn(this.ru); this.ru = this.rw(this.dateTimeMemberPath); this.r3 = null; } break; case TimeAxisBase.$$p[3]: this.ei(); this.ss(false); break; case TimeAxisBase.$$p[2]: this.ei(); this.ss(false); break; case "DateTimeColumn": this.sq(); break; } } sp(a, b) { this.r3 = null; } rw(a) { return TimeAxisBase.rv(a, this); } static rv(a, b) { if (a == null) { return b.p0.registerColumnDateTime(null, null, false); } let c = null; let d = SeriesViewer.de(a, b.coercionMethods); c = d.a; return b.p0.registerColumnDateTime(a, c, b.expectFunctions); } a0() { if (this.en) { return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel')); } else { return new HorizontalAxisLabelPanel(); } } get_bm() { return 0; } get bm() { return this.get_bm(); } l9(a) { super.l9(a); let b = this.bp.bb(); let c = this.bp.be(); let d = this.bp.bc(); let e = this.bp.bd(); let f = this.bp.g(); let g = this.bp.h(); let h = this.bp.i(); this.mk(); this.ku(b); this.ku(c); this.ku(d); this.ku(e); this.ev.clear(); this.ew.clear(); this.p8.clear(); this.a1.ae = this; let i = this.b7 != null ? this.b7.yv : Rect.empty; let j = !i.isEmpty ? this.pk : Rect.empty; this.a1.dc = i; this.a1.db = j; if (i.isEmpty || j.isEmpty) { this.ci.count = 0; this.ch.count = 0; this.cf.count = 0; this.cg.count = 0; } if (this.ci.count == 0 && this.ch.count == 0 && this.bp.o()) { this.a1.ab.clear(); } if (this.a4 != null) { if (this.a4.visibility != 0) { this.a1.ab.clear(); } this.a4.registerAxis(this); } this.sq(); } get_dm() { return true; } startCursor() { } resetCursor() { } StartTimeCursor() { this.startCursor(); } ResetTimeCursor() { this.resetCursor(); } getCategorySize(a, b, c) { if (this.qp == 0) { return 0; } let d = this.pi(b, c); return d.width / (this.qp * a.width); } getGroupCenter(a, b, c, d) { return this.getCategorySize(b, c, d) * 0.5; } qe(a, b, c) { let d = this.ql(a, b, c); let e = 1 - 0.5 * d; let f = this.getCategorySize(a, b, c) * e; return f; } get_d0() { return true; } so(a, b) { return (0); } preferredCategoryMode(a) { return this.dj ? 0 : 1; } hz(a) { let b = new ScalerParams(1, this.b7.ze, this.b7.zd, this.dr); let c = this.gf(a, b); return dateFromTicks(truncate(c)); } 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); } get i$a() { return this.dm; } static { this.$$p = markDep(DependencyProperty, PropertyMetadata, TimeAxisBase, 'l2', ['DateTimeMemberPath::sw', [2, null], 'IsDataPreSorted:rz:sx', [0, false], 'MaximumValue::sy', [3, null], 'MinimumValue::sz', [3, null]]); } }