UNPKG

igniteui-angular-charts

Version:

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

385 lines (384 loc) 14.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 class CategoryDateTimeXAxis extends TimeAxisBase { static { this.$t = markType(CategoryDateTimeXAxis, 'CategoryDateTimeXAxis', TimeAxisBase.$); } constructor() { super(); this.s8 = 0; this.s9 = 0; this.ab = CategoryDateTimeXAxis.$; this.actualMinimumValue = (new Date()); this.actualMaximumValue = (new Date()); } al() { return new CategoryDateTimeXAxis(); } kw(a) { super.kw(a); this.kz(a, "ActualInterval"); this.kz(a, "ActualMinorInterval"); this.kz(a, "DisplayType"); this.kz(a, "UnevenlySpacedLabels"); } kz(a, b) { super.kz(a, b); let c = typeCast(CategoryDateTimeXAxis.$, a); if (c == null) { return; } if (b == "ActualInterval") { c.ta = this.ta; } if (b == "ActualMinorInterval") { c.te = this.tb; } if (b == "DisplayType") { c.s1 = this.s1; } if (b == "UnevenlySpacedLabels") { c.s4 = this.s4; } } get_dl() { return this.s1 == 0; } bo() { return new CategoryDateTimeXAxisView(this); } lg(a) { super.lg(a); this.s0 = a; } get ta() { return this.s8; } set ta(a) { if (this.ta != a) { let b = this.s8; this.s8 = a; this.l2("ActualInterval", b, this.ta); } } go() { return this.ta; } static { this.tq = DependencyProperty.i("MinorInterval", Number_$type, CategoryDateTimeXAxis.$, new PropertyMetadata(2, 0, (a, b) => { (typeCast(CategoryDateTimeXAxis.$, a)).l2("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryDateTimeXAxis.$, a)).l8(false); })); } get te() { return typeGetValue(this.c(CategoryDateTimeXAxis.tq)); } set te(a) { this.h(CategoryDateTimeXAxis.tq, a); } get tb() { return this.s9; } set tb(a) { if (this.tb != a) { let b = this.s9; this.s9 = a; this.l2("ActualMinorInterval", b, this.tb); } } ep(a, b, c) { let d = super.ep(a, b, c); if (!d) { return false; } return +(this.actualMinimumValue) != +(this.actualMaximumValue); } fw() { return this.ta; } l9(a) { super.l9(a); let b = this.b7 != null ? this.b7.yv : Rect.empty; let c = !b.isEmpty ? this.pk : Rect.empty; let d = this.pf(); let e = this.pe(); let f = new ScalerParams(0, b, c, this.dr, d); if ((this.ru == null || this.ru.count < 1) && !this.r0() && !this.r1()) { return; } if (!b.isEmpty && !c.isEmpty && (this.s1 != 1 || this.ru != 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.me(g, h, b, c, d, c.top, c.bottom); g = j.p0; h = j.p1; } } if (isNaN_(g)) { g = 0; } this.le(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.s1 == 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.r3 == null ? s : this.r3._inner[s]; let u = this.gc(this.ru.item(t).getTime(), f); if (u == r) { continue; } r = u; if (this.categoryMode == 2) { u += this.dr ? -this.getGroupCenter(s, b, c, d) : this.getGroupCenter(s, b, c, d); } if (u < e.left || u > e.right) { continue; } this.ml(m, u, c, l, false); this.p8.add(u); if (this.p0 != null && s < this.p0.count) { let v = this.p0.item(t); let w = super.h2(v); if (!isNaN_(u) && !isInfinity(u) && w != null) { if ((typeof w === 'string') && Base.equalsStatic(w, "")) { } else if (this.ct) { this.ev.add1(w); this.ew.add(new LabelPosition(0, u)); } } } } } else { let x = this.gf(e.left, f); let y = this.gf(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.gs(), this.s7()); let ac = this.ry ? this.s6() : ab.g; this.tm(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.dr ? -af : af; } let ag = truncate(Math.ceil(e.right)); let ah = truncate(Math.floor(e.left)); let ai = this.gc(this.actualMinimumValue.getTime() + ad * ac, f) + af; for (let aj = ad; aj <= ae; aj++) { let ak = this.gc(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.mm(k, ai, ak, c); } this.ml(m, ai, c, l, false); this.p8.add(ai); if (this.ef) { let am = this.tc(); if (am > 0 && am < ac) { if (ac / am < 20) { let an = ai; let ao = Math.abs(this.gc(this.actualMinimumValue.getTime() + am, f) - this.gc(this.actualMinimumValue.getTime(), f)); while (an + ao < ak) { if (Math.abs(an + ao - ak) < 0.0001) { break; } an += ao; if (an > 0) { this.ml(n, an, c, o, false); } } this.tn(am); } } else { if (ab.j >= 1) { for (let ap = 1; ap < ab.j; ++ap) { let aq = this.gc(this.actualMinimumValue.getTime() + aj * ac + (ap * ac) / ab.j, f) + af; this.ml(n, aq, c, o, false); } } if (ab.j > 0) { this.tn(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.h2(as); if (this.ct && at != null) { this.ev.add1(at); this.ew.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.ev; this.a1.bh = this.ew; this.rg(); } } s7() { return -1; } s6() { return this.ta; } tc() { return this.te; } tm(a) { this.ta = a; } tn(a) { this.tb = a; } s3() { return this.td != 0; } s2() { return this.ta == 0; } s5(a) { return this.ru == null ? dateMinValue() : this.ru.item(a); } tl(a, b) { if (a > b || this.p0 == null || this.p0.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); } lk(a, b, c, d) { super.lk(a, b, c, d); switch (b) { case CategoryDateTimeXAxis.$$p[0]: this.d5 = true; this.a1.an = this.s1 == 1 || this.s4; this.l8(false); break; case CategoryDateTimeXAxis.$$p[1]: this.d5 = true; this.l8(false); break; case CategoryDateTimeXAxis.$$p[2]: this.a1.an = this.s1 == 1 || this.s4; break; } } sq() { super.sq(); if (this.s3()) { this.ta = this.td; let a = this.b7 != null ? this.b7.yv : Rect.empty; let b = !a.isEmpty ? this.pk : Rect.empty; let c = Math.abs(this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()); this.ry = this.s2() || (this.s1 == 1) || (1 * c / this.s6() > (b.width / a.width)) ? false : true; } else { this.ry = false; } } so(a, b) { let c = b.getTime() - a.getTime(); let timeOffset_ = truncate(Math.round(intDivide(c, this.qp) / 2)); return timeOffset_ == 0 ? timeSpanFromMilliseconds(1) : timeSpanFromMilliseconds(timeOffset_); } get_dj() { return true; } get isVertical() { return this.d3; } j$d(a, b) { return this.gf.apply(this, arguments); } j$c(a, b) { return this.gc.apply(this, arguments); } j$e(a, b, c, d, e) { this.la.apply(this, arguments); } j$f(a, b, c, d) { this.lb.apply(this, arguments); } j$g(a, b, c, d) { this.lc.apply(this, arguments); } get j$b() { return this.dr; } j$a() { return this.ag.apply(this, arguments); } get i$a() { return this.dm; } static { this.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryDateTimeXAxis, 'l2', ['DisplayType:s1:to', [TimeAxisDisplayType_$type, enumGetBox(TimeAxisDisplayType_$type, 0)], 'Interval:td:tp', [1, 0], 'UnevenlySpacedLabels:s4:tr', [0, false]]); } } /** * @hidden */ export class CategoryDateTimeXAxisView extends CategoryAxisBaseView { static { this.$t = markType(CategoryDateTimeXAxisView, 'CategoryDateTimeXAxisView', CategoryAxisBaseView.$); } constructor(a) { super(a); this.bv = null; this.bv = a; } as() { super.as(); this.c.hc = AxisDefaults.categoryAxis_TickLength; } w(a) { let b = this.u(dateFromTicks(truncate(a))); return b; } }