UNPKG

igniteui-react-charts

Version:

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

391 lines (390 loc) 15.9 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 { TimeAxisBase } from "./TimeAxisBase"; import { DependencyProperty } from "igniteui-react-core"; import { TimeAxisDisplayType_$type } from "./TimeAxisDisplayType"; import { Base, typeCast, enumGetBox, Number_$type, typeGetValue, markType, markDep } from "igniteui-react-core"; import { Rect } from "igniteui-react-core"; import { ScalerParams } from "./ScalerParams"; import { NumericYAxis } from "./NumericYAxis"; import { LinearNumericSnapper } from "./LinearNumericSnapper"; import { LabelPosition } from "./LabelPosition"; import { PropertyMetadata } from "igniteui-react-core"; import { truncate, intDivide, isNaN_, isInfinity } from "igniteui-react-core"; import { dateMinValue, dateFromTicks } from "igniteui-react-core"; import { timeSpanFromMilliseconds } from "igniteui-react-core"; import { CategoryAxisBaseView } from "./CategoryAxisBaseView"; import { AxisDefaults } from "./AxisDefaults"; /** * @hidden */ export let CategoryDateTimeXAxis = /*@__PURE__*/ (() => { class CategoryDateTimeXAxis extends TimeAxisBase { constructor() { super(); this.st = 0; this.su = 0; this.ab = CategoryDateTimeXAxis.$; this.actualMinimumValue = (new Date()); this.actualMaximumValue = (new Date()); } al() { return new CategoryDateTimeXAxis(); } ko(a) { super.ko(a); this.kr(a, "ActualInterval"); this.kr(a, "ActualMinorInterval"); this.kr(a, "DisplayType"); this.kr(a, "UnevenlySpacedLabels"); } kr(a, b) { super.kr(a, b); let c = typeCast(CategoryDateTimeXAxis.$, a); if (c == null) { return; } if (b == "ActualInterval") { c.sv = this.sv; } if (b == "ActualMinorInterval") { c.sz = this.sw; } if (b == "DisplayType") { c.sm = this.sm; } if (b == "UnevenlySpacedLabels") { c.sp = this.sp; } } get_di() { return this.sm == 0; } bo() { return new CategoryDateTimeXAxisView(this); } k8(a) { super.k8(a); this.sl = a; } get sv() { return this.st; } set sv(a) { if (this.sv != a) { let b = this.st; this.st = a; this.lu("ActualInterval", b, this.sv); } } gk() { return this.sv; } get sz() { return typeGetValue(this.c(CategoryDateTimeXAxis.tb)); } set sz(a) { this.h(CategoryDateTimeXAxis.tb, a); } get sw() { return this.su; } set sw(a) { if (this.sw != a) { let b = this.su; this.su = a; this.lu("ActualMinorInterval", b, this.sw); } } el(a, b, c) { let d = super.el(a, b, c); if (!d) { return false; } return +(this.actualMinimumValue) != +(this.actualMaximumValue); } fs() { return this.sv; } l1(a) { super.l1(a); let b = this.b7 != null ? this.b7.ys : Rect.empty; let c = !b.isEmpty ? this.o8 : Rect.empty; let d = this.o3(); let e = this.o2(); let f = new ScalerParams(0, b, c, this.dn, d); if ((this.rf == null || this.rf.count < 1) && !this.rl() && !this.rm()) { return; } if (!b.isEmpty && !c.isEmpty && (this.sm != 1 || this.rf != null)) { let g = c.bottom; let h = g - c.top; if (this.an != null) { let i = typeCast(NumericYAxis.$, this.an); if (i != null) { let j = this.l6(g, h, b, c, d, c.top, c.bottom); g = j.p0; h = j.p1; } } if (isNaN_(g)) { g = 0; } this.k6(this.bp.bb(), g, c, this.bp.g(), true); this.a1.bn = h; let k = this.bp.be(); let l = this.bp.h(); let m = this.bp.bc(); let n = this.bp.bd(); let o = this.bp.i(); if (this.sm == 1) { let p = this.i$e(b, c, d, e); let q = this.i$g(b, c, d, e); if (p < 0 || q < 0) { return; } let r = NaN; for (let s = p; s <= q; s++) { let t = this.ro == null ? s : this.ro._inner[s]; let u = this.f7(this.rf.item(t).getTime(), f); if (u == r) { continue; } r = u; if (this.categoryMode == 2) { u += this.dn ? -this.getGroupCenter(s, b, c, d) : this.getGroupCenter(s, b, c, d); } if (u < e.left || u > e.right) { continue; } this.md(m, u, c, l, false); this.pv.add(u); if (this.po != null && s < this.po.count) { let v = this.po.item(t); let w = super.hy(v); if (!isNaN_(u) && !isInfinity(u) && w != null) { if ((typeof w === 'string') && Base.equalsStatic(w, "")) { } else { this.er.add1(w); this.es.add(new LabelPosition(0, u)); } } } } } else { let x = this.ga(e.left, f); let y = this.ga(e.right, f); let z = Math.min(x, y); let aa = Math.max(x, y); let ab = new LinearNumericSnapper(0, z, aa, e.width, this.go(), this.ss()); let ac = this.rj ? this.sr() : ab.g; this.s7(truncate(ac)); let ad = truncate(Math.floor((z - this.actualMinimumValue.getTime()) / ac)); let ae = truncate(Math.ceil((aa - this.actualMinimumValue.getTime()) / ac)); let af = 0; if (this.categoryMode == 2) { af = this.getGroupCenter(0, b, c, d); af = this.dn ? -af : af; } let ag = truncate(Math.ceil(e.right)); let ah = truncate(Math.floor(e.left)); let ai = this.f7(this.actualMinimumValue.getTime() + ad * ac, f) + af; for (let aj = ad; aj <= ae; aj++) { let ak = this.f7(this.actualMinimumValue.getTime() + (aj + 1) * ac, f) + af; if (!isNaN_(ai) && !isInfinity(ai)) { let al = truncate(Math.round(ai)); if (al <= ag) { if (aj % 2 == 0) { this.me(k, ai, ak, c); } this.md(m, ai, c, l, false); this.pv.add(ai); if (this.eb) { let am = this.sx(); if (am > 0 && am < ac) { if (ac / am < 20) { let an = ai; let ao = Math.abs(this.f7(this.actualMinimumValue.getTime() + am, f) - this.f7(this.actualMinimumValue.getTime(), f)); while (an + ao < ak) { if (Math.abs(an + ao - ak) < 0.0001) { break; } an += ao; if (an > 0) { this.md(n, an, c, o, false); } } this.s8(am); } } else { if (ab.j >= 1) { for (let ap = 1; ap < ab.j; ++ap) { let aq = this.f7(this.actualMinimumValue.getTime() + aj * ac + (ap * ac) / ab.j, f) + af; this.md(n, aq, c, o, false); } } if (ab.j > 0) { this.s8(truncate((ac / ab.j))); } } } } if (al >= ah && al <= ag) { let ar = this.actualMinimumValue.getTime() + aj * ac; let ticks_ = truncate(Math.floor(ar)); let as = (new Date(ticks_)); let at = this.hy(as); if (at != null) { this.er.add1(at); this.es.add(new LabelPosition(0, ai)); } } } ai = ak; } } if ((this.a4 == null || this.a4.visibility == 0) && this.an != null) { if (this.a4 != null && (this.a4.location == 4 || this.a4.location == 5)) { this.b7.ps(); } } this.a1.bg = this.er; this.a1.bh = this.es; this.q2(); } } ss() { return -1; } sr() { return this.sv; } sx() { return this.sz; } s7(a) { this.sv = a; } s8(a) { this.sw = a; } so() { return this.sy != 0; } sn() { return this.sv == 0; } sq(a) { return this.rf == null ? dateMinValue() : this.rf.item(a); } s6(a, b) { if (a > b || this.po == null || this.po.count == 0) { return; } let c = (a.getTime() - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); let d = (b.getTime() - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); this.b7.zb = new Rect(0, c, this.b7.zb.y, d - c, this.b7.zb.height); } lc(a, b, c, d) { super.lc(a, b, c, d); switch (b) { case CategoryDateTimeXAxis.$$p[0]: this.d1 = true; this.a1.an = this.sm == 1 || this.sp; this.l0(false); break; case CategoryDateTimeXAxis.$$p[1]: this.d1 = true; this.l0(false); break; case CategoryDateTimeXAxis.$$p[2]: this.a1.an = this.sm == 1 || this.sp; break; } } sb() { super.sb(); if (this.so()) { this.sv = this.sy; let a = this.b7 != null ? this.b7.ys : Rect.empty; let b = !a.isEmpty ? this.o8 : Rect.empty; let c = Math.abs(this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); this.rj = this.sn() || (this.sm == 1) || (1 * c / this.sr() > (b.width / a.width)) ? false : true; } else { this.rj = false; } } r9(a, b) { let c = b.getTime() - a.getTime(); let timeOffset_ = truncate(Math.round(intDivide(c, this.qc) / 2)); return timeOffset_ == 0 ? timeSpanFromMilliseconds(1) : timeSpanFromMilliseconds(timeOffset_); } get_dg() { return true; } 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; } } CategoryDateTimeXAxis.$t = /*@__PURE__*/ markType(CategoryDateTimeXAxis, 'CategoryDateTimeXAxis', TimeAxisBase.$); CategoryDateTimeXAxis.tb = /*@__PURE__*/ DependencyProperty.i("MinorInterval", Number_$type, CategoryDateTimeXAxis.$, /*@__PURE__*/ new PropertyMetadata(2, 0, (a, b) => { (typeCast(CategoryDateTimeXAxis.$, a)).lu("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryDateTimeXAxis.$, a)).l0(false); })); CategoryDateTimeXAxis.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryDateTimeXAxis, 'lu', ['DisplayType:sm:s9', [TimeAxisDisplayType_$type, /*@__PURE__*/ enumGetBox(TimeAxisDisplayType_$type, 0)], 'Interval:sy:ta', [1, 0], 'UnevenlySpacedLabels:sp:tc', [0, false]]); return CategoryDateTimeXAxis; })(); /** * @hidden */ export let CategoryDateTimeXAxisView = /*@__PURE__*/ (() => { class CategoryDateTimeXAxisView extends CategoryAxisBaseView { constructor(a) { super(a); this.bv = null; this.bv = a; } as() { super.as(); this.c.g8 = AxisDefaults.categoryAxis_TickLength; } w(a) { let b = this.u(dateFromTicks(truncate(a))); return b; } } CategoryDateTimeXAxisView.$t = /*@__PURE__*/ markType(CategoryDateTimeXAxisView, 'CategoryDateTimeXAxisView', CategoryAxisBaseView.$); return CategoryDateTimeXAxisView; })();