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.sw = 0; this.sx = 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.sy = this.sy; } if (b == "ActualMinorInterval") { c.s2 = this.sz; } if (b == "DisplayType") { c.sp = this.sp; } if (b == "UnevenlySpacedLabels") { c.ss = this.ss; } } get_di() { return this.sp == 0; } bo() { return new CategoryDateTimeXAxisView(this); } k8(a) { super.k8(a); this.so = a; } get sy() { return this.sw; } set sy(a) { if (this.sy != a) { let b = this.sw; this.sw = a; this.lu("ActualInterval", b, this.sy); } } gk() { return this.sy; } get s2() { return typeGetValue(this.c(CategoryDateTimeXAxis.te)); } set s2(a) { this.h(CategoryDateTimeXAxis.te, a); } get sz() { return this.sx; } set sz(a) { if (this.sz != a) { let b = this.sx; this.sx = a; this.lu("ActualMinorInterval", b, this.sz); } } el(a, b, c) { let d = super.el(a, b, c); if (!d) { return false; } return +(this.actualMinimumValue) != +(this.actualMaximumValue); } fs() { return this.sy; } l1(a) { super.l1(a); let b = this.b7 != null ? this.b7.yv : 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.ri == null || this.ri.count < 1) && !this.ro() && !this.rp()) { return; } if (!b.isEmpty && !c.isEmpty && (this.sp != 1 || this.ri != 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.sp == 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.rr == null ? s : this.rr._inner[s]; let u = this.f7(this.ri.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.pw.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.sv()); let ac = this.rm ? this.su() : ab.g; this.ta(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.pw.add(ai); if (this.eb) { let am = this.s0(); 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.tb(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.tb(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.pt(); } } this.a1.bg = this.er; this.a1.bh = this.es; this.q4(); } } sv() { return -1; } su() { return this.sy; } s0() { return this.s2; } ta(a) { this.sy = a; } tb(a) { this.sz = a; } sr() { return this.s1 != 0; } sq() { return this.sy == 0; } st(a) { return this.ri == null ? dateMinValue() : this.ri.item(a); } s9(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.ze = new Rect(0, c, this.b7.ze.y, d - c, this.b7.ze.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.sp == 1 || this.ss; this.l0(false); break; case CategoryDateTimeXAxis.$$p[1]: this.d1 = true; this.l0(false); break; case CategoryDateTimeXAxis.$$p[2]: this.a1.an = this.sp == 1 || this.ss; break; } } se() { super.se(); if (this.sr()) { this.sy = this.s1; let a = this.b7 != null ? this.b7.yv : Rect.empty; let b = !a.isEmpty ? this.o8 : Rect.empty; let c = Math.abs(this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); this.rm = this.sq() || (this.sp == 1) || (1 * c / this.su() > (b.width / a.width)) ? false : true; } else { this.rm = false; } } sc(a, b) { let c = b.getTime() - a.getTime(); let timeOffset_ = truncate(Math.round(intDivide(c, this.qd) / 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.te = /*@__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:sp:tc', [TimeAxisDisplayType_$type, /*@__PURE__*/ enumGetBox(TimeAxisDisplayType_$type, 0)], 'Interval:s1:td', [1, 0], 'UnevenlySpacedLabels:ss:tf', [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; })();