UNPKG

igniteui-react-charts

Version:

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

389 lines (388 loc) 15.7 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.rm = 0; this.rn = 0; this.ab = CategoryDateTimeXAxis.$; this.actualMinimumValue = (new Date()); this.actualMaximumValue = (new Date()); } ak() { return new CategoryDateTimeXAxis(); } jr(a) { super.jr(a); this.ju(a, "ActualInterval"); this.ju(a, "ActualMinorInterval"); this.ju(a, "DisplayType"); this.ju(a, "UnevenlySpacedLabels"); } ju(a, b) { super.ju(a, b); let c = typeCast(CategoryDateTimeXAxis.$, a); if (c == null) { return; } if (b == "ActualInterval") { c.ro = this.ro; } if (b == "ActualMinorInterval") { c.rs = this.rp; } if (b == "DisplayType") { c.rf = this.rf; } if (b == "UnevenlySpacedLabels") { c.ri = this.ri; } } get_db() { return this.rf == 0; } bm() { return new CategoryDateTimeXAxisView(this); } kb(a) { super.kb(a); this.re = a; } get ro() { return this.rm; } set ro(a) { if (this.ro != a) { let b = this.rm; this.rm = a; this.kx("ActualInterval", b, this.ro); } } f5() { return this.ro; } get rs() { return typeGetValue(this.c(CategoryDateTimeXAxis.r4)); } set rs(a) { this.h(CategoryDateTimeXAxis.r4, a); } get rp() { return this.rn; } set rp(a) { if (this.rp != a) { let b = this.rn; this.rn = a; this.kx("ActualMinorInterval", b, this.rp); } } d9(a, b, c) { let d = super.d9(a, b, c); if (!d) { return false; } return +(this.actualMinimumValue) != +(this.actualMaximumValue); } fe() { return this.ro; } k4(a) { super.k4(a); let b = this.b0 != null ? this.b0.xn : Rect.empty; let c = !b.isEmpty ? this.n1 : Rect.empty; let d = this.nw(); let e = this.nv(); let f = new ScalerParams(0, b, c, this.df, d); if ((this.p8 == null || this.p8.count < 1) && !this.qe() && !this.qf()) { return; } if (!b.isEmpty && !c.isEmpty && (this.rf != 1 || this.p8 != null)) { let g = c.bottom; let h = g - c.top; if (this.am != null) { let i = typeCast(NumericYAxis.$, this.am); if (i != null) { let j = this.k9(g, h, b, c, d, c.top, c.bottom); g = j.p0; h = j.p1; } } if (isNaN_(g)) { g = 0; } this.j9(this.bn.a4(), g, c, this.bn.e(), true); this.a0.bj = h; let k = this.bn.a7(); let l = this.bn.f(); let m = this.bn.a5(); let n = this.bn.a6(); let o = this.bn.g(); if (this.rf == 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.qh == null ? s : this.qh._inner[s]; let u = this.ft(this.p8.item(t).getTime(), f); if (u == r) { continue; } r = u; if (this.categoryMode == 2) { u += this.df ? -this.getGroupCenter(s, b, c, d) : this.getGroupCenter(s, b, c, d); } if (u < e.left || u > e.right) { continue; } this.lg(m, u, c, l, false); this.oo.add(u); if (this.oh != null && s < this.oh.count) { let v = this.oh.item(t); let w = super.hf(v); if (!isNaN_(u) && !isInfinity(u) && w != null) { if ((typeof w === 'string') && Base.equalsStatic(w, "")) { } else { this.ef.add1(w); this.eg.add(new LabelPosition(u)); } } } } } else { let x = this.fw(e.left, f); let y = this.fw(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.f9(), this.rl()); let ac = this.qc ? this.rk() : ab.g; this.r0(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.df ? -af : af; } let ag = truncate(Math.ceil(e.right)); let ah = truncate(Math.floor(e.left)); let ai = this.ft(this.actualMinimumValue.getTime() + ad * ac, f) + af; for (let aj = ad; aj <= ae; aj++) { let ak = this.ft(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.lh(k, ai, ak, c); } this.lg(m, ai, c, l, false); this.oo.add(ai); if (this.dz) { let am = this.rq(); if (am > 0 && am < ac) { if (ac / am < 20) { let an = ai; let ao = Math.abs(this.ft(this.actualMinimumValue.getTime() + am, f) - this.ft(this.actualMinimumValue.getTime(), f)); while (an + ao < ak) { if (Math.abs(an + ao - ak) < 0.0001) { break; } an += ao; if (an > 0) { this.lg(n, an, c, o, false); } } this.r1(am); } } else { for (let ap = 1; ap < ab.j; ++ap) { let aq = this.ft(this.actualMinimumValue.getTime() + aj * ac + (ap * ac) / ab.j, f) + af; this.lg(n, aq, c, o, false); } if (ab.j > 0) { this.r1(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.hf(as); if (at != null) { this.ef.add1(at); this.eg.add(new LabelPosition(ai)); } } } ai = ak; } } if ((this.a3 == null || this.a3.visibility == 0) && this.am != null) { if (this.a3 != null && (this.a3.location == 4 || this.a3.location == 5)) { this.b0.o2(); } } this.a0.bc = this.ef; this.a0.bd = this.eg; this.pv(); } } rl() { return -1; } rk() { return this.ro; } rq() { return this.rs; } r0(a) { this.ro = a; } r1(a) { this.rp = a; } rh() { return this.rr != 0; } rg() { return this.ro == 0; } rj(a) { return this.p8 == null ? dateMinValue() : this.p8.item(a); } rz(a, b) { if (a > b || this.oh == null || this.oh.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.b0.x6 = new Rect(0, c, this.b0.x6.y, d - c, this.b0.x6.height); } kf(a, b, c, d) { super.kf(a, b, c, d); switch (b) { case CategoryDateTimeXAxis.$$p[0]: this.dr = true; this.a0.al = this.rf == 1 || this.ri; this.k3(false); break; case CategoryDateTimeXAxis.$$p[1]: this.dr = true; this.k3(false); break; case CategoryDateTimeXAxis.$$p[2]: this.a0.al = this.rf == 1 || this.ri; break; } } q4() { super.q4(); if (this.rh()) { this.ro = this.rr; let a = this.b0 != null ? this.b0.xn : Rect.empty; let b = !a.isEmpty ? this.n1 : Rect.empty; let c = Math.abs(this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); this.qc = this.rg() || (this.rf == 1) || (1 * c / this.rk() > (b.width / a.width)) ? false : true; } else { this.qc = false; } } q2(a, b) { let c = b.getTime() - a.getTime(); let timeOffset_ = truncate(Math.round(intDivide(c, this.o5) / 2)); return timeOffset_ == 0 ? timeSpanFromMilliseconds(1) : timeSpanFromMilliseconds(timeOffset_); } get_c9() { return true; } get isVertical() { return this.dq; } j$d(a, b) { return this.fw.apply(this, arguments); } j$c(a, b) { return this.ft.apply(this, arguments); } j$e(a, b, c, d, e) { this.j5.apply(this, arguments); } j$f(a, b, c, d) { this.j6.apply(this, arguments); } j$g(a, b, c, d) { this.j7.apply(this, arguments); } get j$b() { return this.df; } j$a() { return this.ag.apply(this, arguments); } get i$a() { return this.dc; } } CategoryDateTimeXAxis.$t = /*@__PURE__*/ markType(CategoryDateTimeXAxis, 'CategoryDateTimeXAxis', TimeAxisBase.$); CategoryDateTimeXAxis.r4 = /*@__PURE__*/ DependencyProperty.i("MinorInterval", Number_$type, CategoryDateTimeXAxis.$, /*@__PURE__*/ new PropertyMetadata(2, 0, (a, b) => { (typeCast(CategoryDateTimeXAxis.$, a)).kx("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryDateTimeXAxis.$, a)).k3(false); })); CategoryDateTimeXAxis.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryDateTimeXAxis, 'kx', ['DisplayType:rf:r2', [TimeAxisDisplayType_$type, /*@__PURE__*/ enumGetBox(TimeAxisDisplayType_$type, 0)], 'Interval:rr:r3', [1, 0], 'UnevenlySpacedLabels:ri:r5', [0, false]]); return CategoryDateTimeXAxis; })(); /** * @hidden */ export let CategoryDateTimeXAxisView = /*@__PURE__*/ (() => { class CategoryDateTimeXAxisView extends CategoryAxisBaseView { constructor(a) { super(a); this.bm = null; this.bm = a; } al() { super.al(); this.a.gt = AxisDefaults.categoryAxis_TickLength; } s(a) { let b = this.q(dateFromTicks(truncate(a))); return b; } } CategoryDateTimeXAxisView.$t = /*@__PURE__*/ markType(CategoryDateTimeXAxisView, 'CategoryDateTimeXAxisView', CategoryAxisBaseView.$); return CategoryDateTimeXAxisView; })();