UNPKG

igniteui-react-charts

Version:

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

677 lines (676 loc) 22.6 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 { CategoryAxisBase } from "./CategoryAxisBase"; import { ISortingAxis_$type } from "./ISortingAxis"; import { IDateTimeAxis_$type } from "./IDateTimeAxis"; import { DependencyProperty } from "igniteui-react-core"; import { List$1 } from "igniteui-react-core"; import { typeCast, Number_$type, Date_$type, fromEnum, runOn, delegateRemove, delegateCombine, markType, markDep, TypeRegistrar } from "igniteui-react-core"; import { ScalerParams } from "./ScalerParams"; import { Rect } from "igniteui-react-core"; import { NumericScaler } from "./NumericScaler"; import { SeriesViewer } from "./SeriesViewer"; import { SortedListView$1 } from "./SortedListView$1"; import { ArrayExtension } from "igniteui-react-core"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { IFastItemsSource_$type } from "igniteui-react-core"; import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel"; import { PropertyMetadata } from "igniteui-react-core"; import { truncate, isNaN_ } from "igniteui-react-core"; import { dateMinValue, dateSubtract, dateAdd, dateMaxValue, dateFromTicks } from "igniteui-react-core"; /** * @hidden */ export let TimeAxisBase = /*@__PURE__*/ (() => { class TimeAxisBase extends CategoryAxisBase { constructor() { super(); this.rc = null; this.rl = null; this.rg = false; this.ro = dateMaxValue(); this.rn = dateMinValue(); FastItemDateTimeColumn.o(); } i7() { return TimeAxisBase.$$p[0]; } i6(a) { let b = this.jn(a); if (b == TimeAxisBase.$$p[0]) { return this.dateTimeMemberPath; } return super.i6(a); } ag() { return [this.actualMinimumValue.getTime(), this.actualMaximumValue.getTime()]; } f6(a, b) { if (!b.c.isEmpty) { let c = this.rt(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.rt(a, b.e, b.d, b.c); } hu(a, b) { let c = this.jn(b); if (c == TimeAxisBase.$$p[0]) { return this.hv(a, b, this.dateTimeMemberPath); } return super.hu(a, b); } rt(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.dn) { e = 1 - e; f = -f; } return c.left + c.width * (e - b.left) / b.width - f; } ru(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.dn) { d = 1 - d; e = -e; } return c.left + c.width * (d - b.left) / b.width - e; } f9(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.dn) { e = 1 - e; } return truncate(Math.floor(this.actualMinimumValue.getTime() + e * (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()))); } i$h() { this.r9(); } r9() { let a = this.b7 != null ? this.b7.yr : Rect.empty; let b = !a.isEmpty ? this.o6 : Rect.empty; let c = (new Date()); let d = (new Date()); let e = false; if (!a.isEmpty && !b.isEmpty && this.rd != null) { let f = typeCast(FastItemDateTimeColumn.$, this.rd); if (f != null) { if (this.rm == null) { this.sa(); } } else { this.rm = null; } if (this.rd.count > 0) { e = true; let g = this.rm == null ? 0 : this.rm._inner[0]; let h = this.rm == null ? this.rd.count - 1 : this.rm._inner[this.rd.count - 1]; c = this.rd.item(g); d = this.rd.item(h); this.rh = false; if (this.categoryMode == 2) { let i = this.r7(c, d); if (+c != +(dateMinValue())) { c = dateSubtract(+c, +i); } d = dateAdd(+d, +i); } } } if (this.rk()) { e = true; c = this.minimumValue; } if (this.rj()) { 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.se(); } } se() { } get rd() { return this.rc; } set rd(a) { if (this.rc != a) { let b = this.rc; this.rc = a; this.ls("DateTimeColumn", b, this.rc); } } get rm() { return this.rl; } set rm(a) { this.rl = a; } get i$b() { if (this.rm == null) { let a = typeCast(FastItemDateTimeColumn.$, this.rd); if (a != null) { this.sa(); } else { this.rm = null; } } return this.rm; } sa() { if (this.ri) { this.rm = new List$1(Number_$type, 0); let a = this.rm; let b = this.rd.count; for (let c = 0; c < b; c++) { a.add(c); } } else { let d = typeCast(FastItemDateTimeColumn.$, this.rd); this.rm = d.h(); } } i$e(a, b, c, d) { return this.rw(a, b, c, d); } rw(a, b, c, d) { if (b.isEmpty) { return -1; } let e = d; let f = new ScalerParams(0, a, b, this.dn, c); let g, h; if (this.dn) { h = this.f9(e.left, f); g = this.f9(e.right, f); } else { g = this.f9(e.left, f); h = this.f9(e.right, f); } let i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(g))); return this.rv(dateFromTicks(i)); } rv(a) { if (this.rd == null || this.rm.count != this.rd.count) { return -1; } let b = new SortedListView$1(Date_$type, this.rd, this.rm); let c = this.rx(a, b); if (c >= 0 && c < this.rm.count) { let d = this.rd.item(this.rm._inner[c]); if (d > a) { c--; if (c < 0) { c = 0; } } return c; } return this.rm.count - 1; } i$g(a, b, c, d) { return this.rz(a, b, c, d); } rz(a, b, c, d) { if (b.isEmpty) { return -1; } let e = d; let f = new ScalerParams(0, a, b, this.dn, c); let g, h; if (this.dn) { h = this.f9(e.left, f); g = this.f9(e.right, f); } else { g = this.f9(e.left, f); h = this.f9(e.right, f); } let i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(h))); return this.ry(dateFromTicks(i)); } ry(a) { if (this.rd == null || this.rm.count != this.rd.count) { return -1; } let b = new SortedListView$1(Date_$type, this.rd, this.rm); let c = this.rx(a, b); if (c >= this.rm.count) { c = this.rm.count - 1; } if (c >= 0 && c < this.rm.count) { let d = this.rd.item(this.rm._inner[c]); if (d < a) { c++; if (c > this.rm.count - 1) { c = this.rm.count - 1; } } return c; } return 0; } i$d(a) { if (this.rd == null) { return NaN; } let b = this.rc.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.rd, b.i$b); let ticks_ = a; let d = (new Date(ticks_)); let e = this.rx(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.o1(); if (e == b.i$b.count && this.b7 != null && this.f6(a, new ScalerParams(0, this.b7.yr, this.o6, this.dn, i)) < (this.o6.right + 2)) { return e - 1; } if (e == -1 && this.b7 != null && Math.abs(this.f6(a, new ScalerParams(0, this.b7.yr, this.o6, this.dn, i)) - this.o6.left) < 2) { return 0; } return -1; } rx(a, b) { let c = this; if (this.rd == 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.rd == null || b.i$b.count != this.rd.count) { return -1; } let c = new SortedListView$1(Date_$type, this.rd, b.i$b); let ticks_ = a; let d = (new Date(ticks_)); let e = this.rx(d, c); let f = this.o1(); 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.f6(a, new ScalerParams(0, this.b7.yr, this.o6, this.dn, f)) < (this.o6.right + 2)) { return e - 1; } if (e == -1 && this.b7 != null && Math.abs(this.f6(a, new ScalerParams(0, this.b7.yr, this.o6, this.dn, f)) - this.o6.left) < 2) { return 0; } return -1; } i$i() { this.rm = null; this.lx(); } get_rh() { return this.rg; } set_rh(a) { this.rg = a; } get rh() { return this.get_rh(); } set rh(a) { this.set_rh(a); } lc(a) { super.lc(a); this.dateTimeMemberPath = a; } lf(a) { super.lf(a); this.minimumValue = a; } le(a) { super.lf(a); this.maximumValue = a; } ef() { if (this.d0 && this.eg) { this.b1 = this.b0(); } let a = this.actualMinimumValue.getTime(); let b = this.actualMaximumValue.getTime(); this.r9(); let c = !this.rk() ? this.actualMinimumValue.getTime() : this.minimumValue.getTime(); let d = !this.rj() ? this.actualMaximumValue.getTime() : this.maximumValue.getTime(); let e = new AxisRangeChangedEventArgs(0, a, c, b, d); this.lt(e); return true; } rk() { if (+(this.minimumValue) == +(dateMinValue())) { return false; } return (this.minimumValue != null); } rj() { if (+(this.maximumValue) == +(dateMaxValue())) { return false; } return (this.maximumValue != null); } get actualMinimumValue() { return this.ro; } set actualMinimumValue(a) { let b = +(this.ro) != +a; if (b) { let c = this.ro; this.ro = a; this.ls("ActualMinimumValue", c, a); } } hz() { return this.actualMinimumValue; } get actualMaximumValue() { return this.rn; } set actualMaximumValue(a) { let b = +(this.rn) != +a; if (b) { let c = this.rn; this.rn = a; this.ls("ActualMaximumValue", c, a); } } hy() { return this.maximumValue; } sb(a) { this.lz(a); if (this.pm == null) { return; } for (let b of fromEnum(this.eo())) { b.r8(a); } } la(a, b, c, d) { super.la(a, b, c, d); switch (b) { case "FastItemsSource": let e = typeCast(IFastItemsSource_$type, c); if (e != null) { e.deregisterColumn(this.rd); this.rd = null; e.event = delegateRemove(e.event, runOn(this, this.r8)); } let f = typeCast(IFastItemsSource_$type, d); if (f != null) { this.rm = null; this.rd = this.re(this.dateTimeMemberPath); f.event = delegateCombine(f.event, runOn(this, this.r8)); } this.sb(false); break; case TimeAxisBase.$$p[0]: if (this.pm != null) { this.pm.deregisterColumn(this.rd); this.rd = this.re(this.dateTimeMemberPath); this.rm = null; } break; case TimeAxisBase.$$p[3]: this.ed(); this.sb(false); break; case TimeAxisBase.$$p[2]: this.ed(); this.sb(false); break; case "DateTimeColumn": this.r9(); break; } } r8(a, b) { this.rm = null; } re(a) { return TimeAxisBase.rf(a, this); } static rf(a, b) { if (a == null) { return b.pm.registerColumnDateTime(null, null, false); } let c = null; let d = SeriesViewer.de(a, b.coercionMethods); c = d.a; return b.pm.registerColumnDateTime(a, c, b.expectFunctions); } a0() { if (this.ei) { return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel')); } else { return new HorizontalAxisLabelPanel(); } } get_bm() { return 0; } get bm() { return this.get_bm(); } lz(a) { super.lz(a); let b = this.bp.ba(); let c = this.bp.bd(); let d = this.bp.bb(); let e = this.bp.bc(); let f = this.bp.f(); let g = this.bp.g(); let h = this.bp.h(); this.ma(); this.kk(b); this.kk(c); this.kk(d); this.kk(e); this.eq.clear(); this.er.clear(); this.pt.clear(); this.a1.ae = this; let i = this.b7 != null ? this.b7.yr : Rect.empty; let j = !i.isEmpty ? this.o6 : Rect.empty; this.a1.da = i; this.a1.c9 = 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.bp.n()) { this.a1.ab.clear(); } if (this.a4 != null) { this.a4.registerAxis(this); } this.r9(); } get_dj() { return true; } startCursor() { } resetCursor() { } StartTimeCursor() { this.startCursor(); } ResetTimeCursor() { this.resetCursor(); } getCategorySize(a, b, c) { if (this.qa == 0) { return 0; } let d = this.o4(b, c); return d.width / (this.qa * a.width); } getGroupCenter(a, b, c, d) { return this.getCategorySize(b, c, d) * 0.5; } pz(a, b, c) { let d = this.p6(a, b, c); let e = 1 - 0.5 * d; let f = this.getCategorySize(a, b, c) * e; return f; } get_dv() { return true; } r7(a, b) { return (0); } preferredCategoryMode(a) { return this.dg ? 0 : 1; } ht(a) { let b = new ScalerParams(1, this.b7.za, this.b7.y9, this.dn); let c = this.f9(a, b); return dateFromTicks(truncate(c)); } get isVertical() { return this.dy; } j$d(a, b) { return this.f9.apply(this, arguments); } j$c(a, b) { return this.f6.apply(this, arguments); } j$e(a, b, c, d, e) { this.k0.apply(this, arguments); } j$f(a, b, c, d) { this.k1.apply(this, arguments); } j$g(a, b, c, d) { this.k2.apply(this, arguments); } get j$b() { return this.dn; } j$a() { return this.ag.apply(this, arguments); } get i$a() { return this.dj; } } TimeAxisBase.$t = /*@__PURE__*/ markType(TimeAxisBase, 'TimeAxisBase', CategoryAxisBase.$, [ISortingAxis_$type, IDateTimeAxis_$type]); TimeAxisBase.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, TimeAxisBase, 'ls', ['DateTimeMemberPath::sf', [2, null], 'IsDataPreSorted:ri:sg', [0, false], 'MaximumValue::sh', [3, null], 'MinimumValue::si', [3, null]]); return TimeAxisBase; })();