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.sr = 0; this.ss = 0; this.ab = CategoryDateTimeXAxis.$; this.actualMinimumValue = (new Date()); this.actualMaximumValue = (new Date()); } al() { return new CategoryDateTimeXAxis(); } km(a) { super.km(a); this.kp(a, "ActualInterval"); this.kp(a, "ActualMinorInterval"); this.kp(a, "DisplayType"); this.kp(a, "UnevenlySpacedLabels"); } kp(a, b) { super.kp(a, b); let c = typeCast(CategoryDateTimeXAxis.$, a); if (c == null) { return; } if (b == "ActualInterval") { c.st = this.st; } if (b == "ActualMinorInterval") { c.sx = this.su; } if (b == "DisplayType") { c.sk = this.sk; } if (b == "UnevenlySpacedLabels") { c.sn = this.sn; } } get_di() { return this.sk == 0; } bo() { return new CategoryDateTimeXAxisView(this); } k6(a) { super.k6(a); this.sj = a; } get st() { return this.sr; } set st(a) { if (this.st != a) { let b = this.sr; this.sr = a; this.ls("ActualInterval", b, this.st); } } gi() { return this.st; } get sx() { return typeGetValue(this.c(CategoryDateTimeXAxis.s9)); } set sx(a) { this.h(CategoryDateTimeXAxis.s9, a); } get su() { return this.ss; } set su(a) { if (this.su != a) { let b = this.ss; this.ss = a; this.ls("ActualMinorInterval", b, this.su); } } ek(a, b, c) { let d = super.ek(a, b, c); if (!d) { return false; } return +(this.actualMinimumValue) != +(this.actualMaximumValue); } fr() { return this.st; } lz(a) { super.lz(a); let b = this.b7 != null ? this.b7.yr : Rect.empty; let c = !b.isEmpty ? this.o6 : Rect.empty; let d = this.o1(); let e = this.o0(); let f = new ScalerParams(0, b, c, this.dn, d); if ((this.rd == null || this.rd.count < 1) && !this.rj() && !this.rk()) { return; } if (!b.isEmpty && !c.isEmpty && (this.sk != 1 || this.rd != 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.l4(g, h, b, c, d, c.top, c.bottom); g = j.p0; h = j.p1; } } if (isNaN_(g)) { g = 0; } this.k4(this.bp.ba(), g, c, this.bp.f(), true); this.a1.bl = h; let k = this.bp.bd(); let l = this.bp.g(); let m = this.bp.bb(); let n = this.bp.bc(); let o = this.bp.h(); if (this.sk == 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.rm == null ? s : this.rm._inner[s]; let u = this.f6(this.rd.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.mb(m, u, c, l, false); this.pt.add(u); if (this.pm != null && s < this.pm.count) { let v = this.pm.item(t); let w = super.hw(v); if (!isNaN_(u) && !isInfinity(u) && w != null) { if ((typeof w === 'string') && Base.equalsStatic(w, "")) { } else { this.eq.add1(w); this.er.add(new LabelPosition(0, u)); } } } } } else { let x = this.f9(e.left, f); let y = this.f9(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.gm(), this.sq()); let ac = this.rh ? this.sp() : ab.g; this.s5(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.f6(this.actualMinimumValue.getTime() + ad * ac, f) + af; for (let aj = ad; aj <= ae; aj++) { let ak = this.f6(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.mc(k, ai, ak, c); } this.mb(m, ai, c, l, false); this.pt.add(ai); if (this.ea) { let am = this.sv(); if (am > 0 && am < ac) { if (ac / am < 20) { let an = ai; let ao = Math.abs(this.f6(this.actualMinimumValue.getTime() + am, f) - this.f6(this.actualMinimumValue.getTime(), f)); while (an + ao < ak) { if (Math.abs(an + ao - ak) < 0.0001) { break; } an += ao; if (an > 0) { this.mb(n, an, c, o, false); } } this.s6(am); } } else { if (ab.j >= 1) { for (let ap = 1; ap < ab.j; ++ap) { let aq = this.f6(this.actualMinimumValue.getTime() + aj * ac + (ap * ac) / ab.j, f) + af; this.mb(n, aq, c, o, false); } } if (ab.j > 0) { this.s6(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.hw(as); if (at != null) { this.eq.add1(at); this.er.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.pr(); } } this.a1.be = this.eq; this.a1.bf = this.er; this.q0(); } } sq() { return -1; } sp() { return this.st; } sv() { return this.sx; } s5(a) { this.st = a; } s6(a) { this.su = a; } sm() { return this.sw != 0; } sl() { return this.st == 0; } so(a) { return this.rd == null ? dateMinValue() : this.rd.item(a); } s4(a, b) { if (a > b || this.pm == null || this.pm.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.za = new Rect(0, c, this.b7.za.y, d - c, this.b7.za.height); } la(a, b, c, d) { super.la(a, b, c, d); switch (b) { case CategoryDateTimeXAxis.$$p[0]: this.d0 = true; this.a1.an = this.sk == 1 || this.sn; this.ly(false); break; case CategoryDateTimeXAxis.$$p[1]: this.d0 = true; this.ly(false); break; case CategoryDateTimeXAxis.$$p[2]: this.a1.an = this.sk == 1 || this.sn; break; } } r9() { super.r9(); if (this.sm()) { this.st = this.sw; let a = this.b7 != null ? this.b7.yr : Rect.empty; let b = !a.isEmpty ? this.o6 : Rect.empty; let c = Math.abs(this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); this.rh = this.sl() || (this.sk == 1) || (1 * c / this.sp() > (b.width / a.width)) ? false : true; } else { this.rh = false; } } r7(a, b) { let c = b.getTime() - a.getTime(); let timeOffset_ = truncate(Math.round(intDivide(c, this.qa) / 2)); return timeOffset_ == 0 ? timeSpanFromMilliseconds(1) : timeSpanFromMilliseconds(timeOffset_); } get_dg() { return true; } 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; } } CategoryDateTimeXAxis.$t = /*@__PURE__*/ markType(CategoryDateTimeXAxis, 'CategoryDateTimeXAxis', TimeAxisBase.$); CategoryDateTimeXAxis.s9 = /*@__PURE__*/ DependencyProperty.i("MinorInterval", Number_$type, CategoryDateTimeXAxis.$, /*@__PURE__*/ new PropertyMetadata(2, 0, (a, b) => { (typeCast(CategoryDateTimeXAxis.$, a)).ls("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryDateTimeXAxis.$, a)).ly(false); })); CategoryDateTimeXAxis.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryDateTimeXAxis, 'ls', ['DisplayType:sk:s7', [TimeAxisDisplayType_$type, /*@__PURE__*/ enumGetBox(TimeAxisDisplayType_$type, 0)], 'Interval:sw:s8', [1, 0], 'UnevenlySpacedLabels:sn:ta', [0, false]]); return CategoryDateTimeXAxis; })(); /** * @hidden */ export let CategoryDateTimeXAxisView = /*@__PURE__*/ (() => { class CategoryDateTimeXAxisView extends CategoryAxisBaseView { constructor(a) { super(a); this.bs = null; this.bs = a; } ar() { super.ar(); this.b.g6 = AxisDefaults.categoryAxis_TickLength; } v(a) { let b = this.t(dateFromTicks(truncate(a))); return b; } } CategoryDateTimeXAxisView.$t = /*@__PURE__*/ markType(CategoryDateTimeXAxisView, 'CategoryDateTimeXAxisView', CategoryAxisBaseView.$); return CategoryDateTimeXAxisView; })();