UNPKG

igniteui-angular-charts

Version:

Ignite UI Angular charting components for building rich data visualizations for modern web apps.

391 lines (390 loc) 16.2 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-angular-core"; import { TimeAxisDisplayType_$type } from "./TimeAxisDisplayType"; import { Base, typeCast, enumGetBox, Number_$type, typeGetValue, markType, markDep } from "igniteui-angular-core"; import { Rect } from "igniteui-angular-core"; import { ScalerParams } from "./ScalerParams"; import { NumericYAxis } from "./NumericYAxis"; import { LinearNumericSnapper } from "./LinearNumericSnapper"; import { LabelPosition } from "./LabelPosition"; import { PropertyMetadata } from "igniteui-angular-core"; import { truncate, intDivide, isNaN_, isInfinity } from "igniteui-angular-core"; import { dateMinValue, dateFromTicks } from "igniteui-angular-core"; import { timeSpanFromMilliseconds } from "igniteui-angular-core"; import { CategoryAxisBaseView } from "./CategoryAxisBaseView"; import { AxisDefaults } from "./AxisDefaults"; /** * @hidden */ export let CategoryDateTimeXAxis = /*@__PURE__*/ (() => { class CategoryDateTimeXAxis extends TimeAxisBase { constructor() { super(); this.so = 0; this.sp = 0; this.ab = CategoryDateTimeXAxis.$; this.actualMinimumValue = (new Date()); this.actualMaximumValue = (new Date()); } al() { return new CategoryDateTimeXAxis(); } kj(a) { super.kj(a); this.km(a, "ActualInterval"); this.km(a, "ActualMinorInterval"); this.km(a, "DisplayType"); this.km(a, "UnevenlySpacedLabels"); } km(a, b) { super.km(a, b); let c = typeCast(CategoryDateTimeXAxis.$, a); if (c == null) { return; } if (b == "ActualInterval") { c.sq = this.sq; } if (b == "ActualMinorInterval") { c.su = this.sr; } if (b == "DisplayType") { c.sh = this.sh; } if (b == "UnevenlySpacedLabels") { c.sk = this.sk; } } get_di() { return this.sh == 0; } bo() { return new CategoryDateTimeXAxisView(this); } k3(a) { super.k3(a); this.sg = a; } get sq() { return this.so; } set sq(a) { if (this.sq != a) { let b = this.so; this.so = a; this.lp("ActualInterval", b, this.sq); } } gh() { return this.sq; } get su() { return typeGetValue(this.c(CategoryDateTimeXAxis.s6)); } set su(a) { this.h(CategoryDateTimeXAxis.s6, a); } get sr() { return this.sp; } set sr(a) { if (this.sr != a) { let b = this.sp; this.sp = a; this.lp("ActualMinorInterval", b, this.sr); } } ej(a, b, c) { let d = super.ej(a, b, c); if (!d) { return false; } return +(this.actualMinimumValue) != +(this.actualMaximumValue); } fq() { return this.sq; } lw(a) { super.lw(a); let b = this.b2 != null ? this.b2.yr : Rect.empty; let c = !b.isEmpty ? this.o3 : Rect.empty; let d = this.oy(); let e = this.ox(); let f = new ScalerParams(0, b, c, this.dn, d); if ((this.ra == null || this.ra.count < 1) && !this.rg() && !this.rh()) { return; } if (!b.isEmpty && !c.isEmpty && (this.sh != 1 || this.ra != 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.l1(g, h, b, c, d, c.top, c.bottom); g = j.p0; h = j.p1; } } if (isNaN_(g)) { g = 0; } this.k1(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.sh == 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.rj == null ? s : this.rj._inner[s]; let u = this.f5(this.ra.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.l8(m, u, c, l, false); this.pq.add(u); if (this.pj != null && s < this.pj.count) { let v = this.pj.item(t); let w = super.hv(v); if (!isNaN_(u) && !isInfinity(u) && w != null) { if ((typeof w === 'string') && Base.equalsStatic(w, "")) { } else { this.ep.add1(w); this.eq.add(new LabelPosition(0, u)); } } } } } else { let x = this.f8(e.left, f); let y = this.f8(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.gl(), this.sn()); let ac = this.re ? this.sm() : ab.g; this.s2(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.f5(this.actualMinimumValue.getTime() + ad * ac, f) + af; for (let aj = ad; aj <= ae; aj++) { let ak = this.f5(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.l9(k, ai, ak, c); } this.l8(m, ai, c, l, false); this.pq.add(ai); if (this.d9) { let am = this.ss(); if (am > 0 && am < ac) { if (ac / am < 20) { let an = ai; let ao = Math.abs(this.f5(this.actualMinimumValue.getTime() + am, f) - this.f5(this.actualMinimumValue.getTime(), f)); while (an + ao < ak) { if (Math.abs(an + ao - ak) < 0.0001) { break; } an += ao; if (an > 0) { this.l8(n, an, c, o, false); } } this.s3(am); } } else { if (ab.j >= 1) { for (let ap = 1; ap < ab.j; ++ap) { let aq = this.f5(this.actualMinimumValue.getTime() + aj * ac + (ap * ac) / ab.j, f) + af; this.l8(n, aq, c, o, false); } } if (ab.j > 0) { this.s3(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.hv(as); if (at != null) { this.ep.add1(at); this.eq.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.b2.pr(); } } this.a1.be = this.ep; this.a1.bf = this.eq; this.qx(); } } sn() { return -1; } sm() { return this.sq; } ss() { return this.su; } s2(a) { this.sq = a; } s3(a) { this.sr = a; } sj() { return this.st != 0; } si() { return this.sq == 0; } sl(a) { return this.ra == null ? dateMinValue() : this.ra.item(a); } s1(a, b) { if (a > b || this.pj == null || this.pj.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.b2.za = new Rect(0, c, this.b2.za.y, d - c, this.b2.za.height); } k7(a, b, c, d) { super.k7(a, b, c, d); switch (b) { case CategoryDateTimeXAxis.$$p[0]: this.d0 = true; this.a1.an = this.sh == 1 || this.sk; this.lv(false); break; case CategoryDateTimeXAxis.$$p[1]: this.d0 = true; this.lv(false); break; case CategoryDateTimeXAxis.$$p[2]: this.a1.an = this.sh == 1 || this.sk; break; } } r6() { super.r6(); if (this.sj()) { this.sq = this.st; let a = this.b2 != null ? this.b2.yr : Rect.empty; let b = !a.isEmpty ? this.o3 : Rect.empty; let c = Math.abs(this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); this.re = this.si() || (this.sh == 1) || (1 * c / this.sm() > (b.width / a.width)) ? false : true; } else { this.re = false; } } r4(a, b) { let c = b.getTime() - a.getTime(); let timeOffset_ = truncate(Math.round(intDivide(c, this.p7) / 2)); return timeOffset_ == 0 ? timeSpanFromMilliseconds(1) : timeSpanFromMilliseconds(timeOffset_); } get_dg() { return true; } get isVertical() { return this.dy; } j$d(a, b) { return this.f8.apply(this, arguments); } j$c(a, b) { return this.f5.apply(this, arguments); } j$e(a, b, c, d, e) { this.kx.apply(this, arguments); } j$f(a, b, c, d) { this.ky.apply(this, arguments); } j$g(a, b, c, d) { this.kz.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 = markType(CategoryDateTimeXAxis, 'CategoryDateTimeXAxis', TimeAxisBase.$); CategoryDateTimeXAxis.s6 = DependencyProperty.i("MinorInterval", Number_$type, CategoryDateTimeXAxis.$, new PropertyMetadata(2, 0, (a, b) => { (typeCast(CategoryDateTimeXAxis.$, a)).lp("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryDateTimeXAxis.$, a)).lv(false); })); CategoryDateTimeXAxis.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryDateTimeXAxis, 'lp', ['DisplayType:sh:s4', [TimeAxisDisplayType_$type, enumGetBox(TimeAxisDisplayType_$type, 0)], 'Interval:st:s5', [1, 0], 'UnevenlySpacedLabels:sk:s7', [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.g5 = AxisDefaults.categoryAxis_TickLength; } v(a) { let b = this.t(dateFromTicks(truncate(a))); return b; } } CategoryDateTimeXAxisView.$t = markType(CategoryDateTimeXAxisView, 'CategoryDateTimeXAxisView', CategoryAxisBaseView.$); return CategoryDateTimeXAxisView; })();