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.re = null; this.rn = null; this.ri = false; this.rq = dateMaxValue(); this.rp = dateMinValue(); FastItemDateTimeColumn.o(); } i9() { return TimeAxisBase.$$p[0]; } i8(a) { let b = this.jp(a); if (b == TimeAxisBase.$$p[0]) { return this.dateTimeMemberPath; } return super.i8(a); } ag() { return [this.actualMinimumValue.getTime(), this.actualMaximumValue.getTime()]; } f7(a, b) { if (!b.c.isEmpty) { let c = this.rv(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.rv(a, b.e, b.d, b.c); } hw(a, b) { let c = this.jp(b); if (c == TimeAxisBase.$$p[0]) { return this.hx(a, b, this.dateTimeMemberPath); } return super.hw(a, b); } rv(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; } rw(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; } ga(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.sb(); } sb() { let a = this.b7 != null ? this.b7.ys : Rect.empty; let b = !a.isEmpty ? this.o8 : Rect.empty; let c = (new Date()); let d = (new Date()); let e = false; if (!a.isEmpty && !b.isEmpty && this.rf != null) { let f = typeCast(FastItemDateTimeColumn.$, this.rf); if (f != null) { if (this.ro == null) { this.sc(); } } else { this.ro = null; } if (this.rf.count > 0) { e = true; let g = this.ro == null ? 0 : this.ro._inner[0]; let h = this.ro == null ? this.rf.count - 1 : this.ro._inner[this.rf.count - 1]; c = this.rf.item(g); d = this.rf.item(h); this.rj = false; if (this.categoryMode == 2) { let i = this.r9(c, d); if (+c != +(dateMinValue())) { c = dateSubtract(+c, +i); } d = dateAdd(+d, +i); } } } if (this.rm()) { e = true; c = this.minimumValue; } if (this.rl()) { 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.sg(); } } sg() { } get rf() { return this.re; } set rf(a) { if (this.re != a) { let b = this.re; this.re = a; this.lu("DateTimeColumn", b, this.re); } } get ro() { return this.rn; } set ro(a) { this.rn = a; } get i$b() { if (this.ro == null) { let a = typeCast(FastItemDateTimeColumn.$, this.rf); if (a != null) { this.sc(); } else { this.ro = null; } } return this.ro; } sc() { if (this.rk) { this.ro = new List$1(Number_$type, 0); let a = this.ro; let b = this.rf.count; for (let c = 0; c < b; c++) { a.add(c); } } else { let d = typeCast(FastItemDateTimeColumn.$, this.rf); this.ro = d.h(); } } i$e(a, b, c, d) { return this.ry(a, b, c, d); } ry(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.ga(e.left, f); g = this.ga(e.right, f); } else { g = this.ga(e.left, f); h = this.ga(e.right, f); } let i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(g))); return this.rx(dateFromTicks(i)); } rx(a) { if (this.rf == null || this.ro.count != this.rf.count) { return -1; } let b = new SortedListView$1(Date_$type, this.rf, this.ro); let c = this.rz(a, b); if (c >= 0 && c < this.ro.count) { let d = this.rf.item(this.ro._inner[c]); if (d > a) { c--; if (c < 0) { c = 0; } } return c; } return this.ro.count - 1; } i$g(a, b, c, d) { return this.r1(a, b, c, d); } r1(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.ga(e.left, f); g = this.ga(e.right, f); } else { g = this.ga(e.left, f); h = this.ga(e.right, f); } let i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(h))); return this.r0(dateFromTicks(i)); } r0(a) { if (this.rf == null || this.ro.count != this.rf.count) { return -1; } let b = new SortedListView$1(Date_$type, this.rf, this.ro); let c = this.rz(a, b); if (c >= this.ro.count) { c = this.ro.count - 1; } if (c >= 0 && c < this.ro.count) { let d = this.rf.item(this.ro._inner[c]); if (d < a) { c++; if (c > this.ro.count - 1) { c = this.ro.count - 1; } } return c; } return 0; } i$d(a) { if (this.rf == null) { return NaN; } let b = this.re.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.rf, b.i$b); let ticks_ = a; let d = (new Date(ticks_)); let e = this.rz(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.o3(); if (e == b.i$b.count && this.b7 != null && this.f7(a, new ScalerParams(0, this.b7.ys, this.o8, this.dn, i)) < (this.o8.right + 2)) { return e - 1; } if (e == -1 && this.b7 != null && Math.abs(this.f7(a, new ScalerParams(0, this.b7.ys, this.o8, this.dn, i)) - this.o8.left) < 2) { return 0; } return -1; } rz(a, b) { let c = this; if (this.rf == 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.rf == null || b.i$b.count != this.rf.count) { return -1; } let c = new SortedListView$1(Date_$type, this.rf, b.i$b); let ticks_ = a; let d = (new Date(ticks_)); let e = this.rz(d, c); let f = this.o3(); 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.f7(a, new ScalerParams(0, this.b7.ys, this.o8, this.dn, f)) < (this.o8.right + 2)) { return e - 1; } if (e == -1 && this.b7 != null && Math.abs(this.f7(a, new ScalerParams(0, this.b7.ys, this.o8, this.dn, f)) - this.o8.left) < 2) { return 0; } return -1; } i$i() { this.ro = null; this.lz(); } get_rj() { return this.ri; } set_rj(a) { this.ri = a; } get rj() { return this.get_rj(); } set rj(a) { this.set_rj(a); } le(a) { super.le(a); this.dateTimeMemberPath = a; } lh(a) { super.lh(a); this.minimumValue = a; } lg(a) { super.lh(a); this.maximumValue = a; } eg() { if (this.d1 && this.eh) { this.b1 = this.b0(); } let a = this.actualMinimumValue.getTime(); let b = this.actualMaximumValue.getTime(); this.sb(); let c = !this.rm() ? this.actualMinimumValue.getTime() : this.minimumValue.getTime(); let d = !this.rl() ? this.actualMaximumValue.getTime() : this.maximumValue.getTime(); let e = new AxisRangeChangedEventArgs(0, a, c, b, d); this.lv(e); return true; } rm() { if (+(this.minimumValue) == +(dateMinValue())) { return false; } return (this.minimumValue != null); } rl() { if (+(this.maximumValue) == +(dateMaxValue())) { return false; } return (this.maximumValue != null); } get actualMinimumValue() { return this.rq; } set actualMinimumValue(a) { let b = +(this.rq) != +a; if (b) { let c = this.rq; this.rq = a; this.lu("ActualMinimumValue", c, a); } } h1() { return this.actualMinimumValue; } get actualMaximumValue() { return this.rp; } set actualMaximumValue(a) { let b = +(this.rp) != +a; if (b) { let c = this.rp; this.rp = a; this.lu("ActualMaximumValue", c, a); } } h0() { return this.maximumValue; } sd(a) { this.l1(a); if (this.po == null) { return; } for (let b of fromEnum(this.ep())) { b.r9(a); } } lc(a, b, c, d) { super.lc(a, b, c, d); switch (b) { case "FastItemsSource": let e = typeCast(IFastItemsSource_$type, c); if (e != null) { e.deregisterColumn(this.rf); this.rf = null; e.event = delegateRemove(e.event, runOn(this, this.sa)); } let f = typeCast(IFastItemsSource_$type, d); if (f != null) { this.ro = null; this.rf = this.rg(this.dateTimeMemberPath); f.event = delegateCombine(f.event, runOn(this, this.sa)); } this.sd(false); break; case TimeAxisBase.$$p[0]: if (this.po != null) { this.po.deregisterColumn(this.rf); this.rf = this.rg(this.dateTimeMemberPath); this.ro = null; } break; case TimeAxisBase.$$p[3]: this.ee(); this.sd(false); break; case TimeAxisBase.$$p[2]: this.ee(); this.sd(false); break; case "DateTimeColumn": this.sb(); break; } } sa(a, b) { this.ro = null; } rg(a) { return TimeAxisBase.rh(a, this); } static rh(a, b) { if (a == null) { return b.po.registerColumnDateTime(null, null, false); } let c = null; let d = SeriesViewer.de(a, b.coercionMethods); c = d.a; return b.po.registerColumnDateTime(a, c, b.expectFunctions); } a0() { if (this.ej) { return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel')); } else { return new HorizontalAxisLabelPanel(); } } get_bm() { return 0; } get bm() { return this.get_bm(); } l1(a) { super.l1(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.mc(); this.km(b); this.km(c); this.km(d); this.km(e); this.er.clear(); this.es.clear(); this.pv.clear(); this.a1.ae = this; let i = this.b7 != null ? this.b7.ys : Rect.empty; let j = !i.isEmpty ? this.o8 : 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.bp.o()) { this.a1.ab.clear(); } if (this.a4 != null) { this.a4.registerAxis(this); } this.sb(); } get_dj() { return true; } startCursor() { } resetCursor() { } StartTimeCursor() { this.startCursor(); } ResetTimeCursor() { this.resetCursor(); } getCategorySize(a, b, c) { if (this.qc == 0) { return 0; } let d = this.o6(b, c); return d.width / (this.qc * a.width); } getGroupCenter(a, b, c, d) { return this.getCategorySize(b, c, d) * 0.5; } p1(a, b, c) { let d = this.p8(a, b, c); let e = 1 - 0.5 * d; let f = this.getCategorySize(a, b, c) * e; return f; } get_dw() { return true; } r9(a, b) { return (0); } preferredCategoryMode(a) { return this.dg ? 0 : 1; } hv(a) { let b = new ScalerParams(1, this.b7.zb, this.b7.za, this.dn); let c = this.ga(a, b); return dateFromTicks(truncate(c)); } get isVertical() { return this.dz; } j$d(a, b) { return this.ga.apply(this, arguments); } j$c(a, b) { return this.f7.apply(this, arguments); } j$e(a, b, c, d, e) { this.k2.apply(this, arguments); } j$f(a, b, c, d) { this.k3.apply(this, arguments); } j$g(a, b, c, d) { this.k4.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, 'lu', ['DateTimeMemberPath::sh', [2, null], 'IsDataPreSorted:rk:si', [0, false], 'MaximumValue::sj', [3, null], 'MinimumValue::sk', [3, null]]); return TimeAxisBase; })();