UNPKG

igniteui-angular-charts

Version:

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

714 lines (713 loc) 26.6 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 { CategoryAxisBase } from "./CategoryAxisBase"; import { IZoomableCategoryAxis_$type } from "./IZoomableCategoryAxis"; import { DependencyProperty } from "igniteui-angular-core"; import { Axis } from "./Axis"; import { Rect } from "igniteui-angular-core"; import { Base, typeCast, Array_$type, Number_$type, markType, markDep } from "igniteui-angular-core"; import { List$1 } from "igniteui-angular-core"; import { ScalerParams } from "./ScalerParams"; import { NumericScaler } from "./NumericScaler"; import { VerticalAxisLabelPanel } from "./VerticalAxisLabelPanel"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { MathUtil } from "igniteui-angular-core"; import { LinearCategorySnapper } from "./LinearCategorySnapper"; import { NumericXAxis } from "./NumericXAxis"; import { LabelPosition } from "./LabelPosition"; import { PropertyMetadata } from "igniteui-angular-core"; import { truncate, isNaN_, isInfinity } from "igniteui-angular-core"; import { CategoryAxisBaseView } from "./CategoryAxisBaseView"; import { AxisDefaults } from "./AxisDefaults"; /** * @hidden */ export let CategoryYAxis = /*@__PURE__*/ (() => { class CategoryYAxis extends CategoryAxisBase { constructor() { super(); this.rc = 0; this.rd = 0; this.rm = 1; this.rl = 1; this.pq = new List$1(Number_$type, 0); this.ab = CategoryYAxis.$; } bo() { return new CategoryYAxisView(this); } k3(a) { super.k3(a); this.ra = a; } al() { return new CategoryYAxis(); } kj(a) { super.kj(a); this.km(a, "ActualInterval"); this.km(a, "ActualMinorInterval"); this.km(a, "ZoomToItemSpan"); this.km(a, "ZoomToCategoryStart"); this.km(a, "ZoomToCategoryRange"); this.km(a, "ZoomMaximumItemSpan"); this.km(a, "ZoomMaximumCategoryRange"); } km(a, b) { super.km(a, b); let c = typeCast(CategoryYAxis.$, a); if (c == null) { return; } let d = this; if (b == "ActualMinorInterval") { c.rk = Axis.gr(d.rh, d.rf); } if (b == "ActualInterval") { c.rj = Axis.gr(d.rg, d.re); } if (b == "ZoomToItemSpan") { c.zoomToItemSpan = d.zoomToItemSpan; } if (b == "ZoomToCategoryStart") { c.zoomToCategoryStart = d.zoomToCategoryStart; } if (b == "ZoomToCategoryRange") { c.zoomToCategoryRange = d.zoomToCategoryRange; } if (b == "ZoomMaximumItemSpan") { c.zoomMaximumItemSpan = d.zoomMaximumItemSpan; } if (b == "ZoomMaximumCategoryRange") { c.zoomMaximumCategoryRange = d.zoomMaximumCategoryRange; } } get_dy() { return true; } f4() { return this.ox().height; } q7(a, b, c) { return this.q8(a, b, c, true); } q9(a) { if (typeCast(List$1.$.specialize(Array_$type), a) !== null) { return a.asArray(); } return null; } kx(a, b, c, d, e) { let f; let g = e.e; let h = e.d; let i = e.c; let j = e.a; let k = !i.isEmpty; let l = this.categoryMode == 0 ? this.p7 - 1 : this.p7; if (l < 0) { l = 0; } let m = i.top; let n = i.height; let o = g.top; let p = g.height; let q = h.top; let r = h.height; let s = 0; let t = 1; let u = this.q9(a); let v = false; if (u != null) { v = true; } let w; for (let x = 0; x < b.count; x++) { w = b.item(x); for (let y = c; y < d; y++) { if (v) { f = u[y]; } else { f = a.item(y); } if (k) { let z = l >= 1 ? (f[w]) / (l) : l == 0 ? 0.5 : NaN; if (!j) { z = 1 - z; } z = m + n * (z - s) / t; let aa = (z - e.d.top) / e.d.height; aa = e.d.top + e.d.height * (aa - e.e.top) / e.e.height; f[w] = aa; } else { let ab = l >= 1 ? (f[w]) / (l) : l == 0 ? 0.5 : NaN; if (!j) { ab = 1 - ab; } ab = q + r * (ab - o) / p; f[w] = ab; } } } } get rj() { return this.c(CategoryYAxis.r6); } set rj(a) { this.h(CategoryYAxis.r6, a); } rb() { return !isNaN_(this.rj); } get re() { return this.rc; } set re(a) { if (this.re != a) { let b = this.rc; this.rc = a; this.lp("ActualInterval", b, this.re); } } gh() { return this.re; } get rk() { return this.c(CategoryYAxis.r7); } set rk(a) { this.h(CategoryYAxis.r7, a); } get rf() { return this.rd; } set rf(a) { if (this.rf != a) { let b = this.rd; this.rd = a; this.lp("ActualMinorInterval", b, this.rf); } } get ro() { return this.rm; } set ro(a) { this.rm = a; } get rn() { return this.rl; } set rn(a) { this.rl = a; } f5(a, b) { if (!b.c.isEmpty) { let c = this.ri(a, NumericScaler.ac, b.c); c = (c - b.d.top) / b.d.height; c = b.d.top + b.d.height * (c - b.e.top) / b.e.height; return c; } return this.ri(a, b.e, b.d); } ri(a, b, c) { let d = this.categoryMode == 0 ? this.p7 - 1 : this.p7; if (d < 0) { d = 0; } let e = d >= 1 ? (a) / (d) : d == 0 ? 0.5 : NaN; if (!this.dp) { e = 1 - e; } return c.top + c.height * (e - b.top) / b.height; } f8(a, b) { if (!b.c.isEmpty) { let c = b.e.top + b.e.height * (a - b.d.top) / b.d.height; c = (c * b.d.height) + b.d.top; c = this.getUnscaledValue3(c, NumericScaler.ac, b.c, this.categoryMode); return c; } return this.getUnscaledValue3(a, b.e, b.d, this.categoryMode); } f9(a, b, c) { if (!b.c.isEmpty) { let d = b.e.top + b.e.height * (a - b.d.top) / b.d.height; d = (d * b.d.height) + b.d.top; d = this.getUnscaledValue3(d, NumericScaler.ac, b.c, c); return d; } return this.getUnscaledValue3(a, b.e, b.d, c); } getUnscaledValue3(a, b, c, d) { let e = b.top + (a - c.top) * b.height / c.height; if (!this.dp) { e = 1 - e; } let f = d == 0 ? this.p7 - 1 : this.p7; if (f < 0) { f = 0; } return e * f; } r1(a, b) { if (isNaN_(a) || isNaN_(b) || this.pj == null || this.pj.count == 0) { return; } let c = a / this.pj.count; let d = b / this.pj.count; this.b2.za = new Rect(0, this.b2.za.x, 1 - d, this.b2.za.width, d - c); } a0() { return new VerticalAxisLabelPanel(); } fq() { return this.rj; } getCategorySize(a, b, c) { let d = this.o1(b, c); return d.height / (this.p7 * a.height); } pw(a, b, c) { let d = this.p3(a, b, c); let e = 0; if (!isNaN_(this.p2)) { e = Math.min(this.p2, 1); } let f = 1 - 0.5 * d; let g = this.getCategorySize(a, b, c) * f / (this.p9 - (this.p9 - 1) * e); return g; } getGroupCenter(a, b, c, d) { let e = 0.5; if (this.p9 > 1) { let f = this.p3(b, c, d); let g = 0; if (!isNaN_(this.p2)) { g = Math.min(this.p2, 1); } let h = 1 - 0.5 * f; let i = h / (this.p9 - (this.p9 - 1) * g); let j = (h - i) / (this.p9 - 1); e = 0.25 * f + 0.5 * i + a * j; } return this.getCategorySize(b, c, d) * e; } r0(a) { let b = this.b2 != null ? this.b2.yr : Rect.empty; b = b.copy(); let c = this.o3; let d = new Rect(0, 0, 0, 1, 1); let e = this.o0(); let f = new ScalerParams(0, d, d, this.dn, e); let g = !b.isEmpty && !c.isEmpty && this.pj != null ? this.pj.indexOf(a) : -1; let h = g > -1 ? this.f5(g, f) : NaN; if (!isNaN_(h) && this.b2.ga) { if (!isNaN_(h)) { if (h < b.top + 0.1 * b.height) { h = h + 0.4 * b.height; b.y = h - 0.5 * b.height; } if (h > b.bottom - 0.1 * b.height) { h = h - 0.4 * b.height; b.y = h - 0.5 * b.height; } } this.b2.ue(b, false, true); } } ee() { if (this.d0 && this.ef) { this.bw = this.bv(); } if (this.pj == null) { return false; } let a = false; let b = this.pj.count; if (b != this.rn) { let c = new AxisRangeChangedEventArgs(0, 1, 1, this.rn, b); this.rn = b; this.lq(c); a = true; } this.r3(); this.r2(); return a; } getWindowZoomFromCategories(a) { let b = MathUtil.b(a) && a > 0; let c = this.pj.count; if (c > 0 && b) { let d = this.b2.y9.height; let e = isNaN_(d) || isInfinity(d); if (e) { return NaN; } let f = new Rect(0, 0, 0, 1, 1); let g = this.b2.y9; let h = this.getCategorySize(f, g, g); let i = isNaN_(h) || isInfinity(h); if (i) { return NaN; } let j = h * a / d; if (j >= 0 && j <= 1) { return j; } } return NaN; } getWindowZoomFromItemSpan(a) { let b = MathUtil.b(a) && a > 0; let c = this.pj.count; if (c > 0 && b) { let d = this.b2.y9.height; let e = isNaN_(d) || isInfinity(d); if (e) { return NaN; } let f = new Rect(0, 0, 0, 1, 1); let g = this.b2.y9; let h = this.pw(f, g, g); let i = a / h; let j = Math.min(1, 1 / i); if (j > 0 && j <= 1) { return j; } } return NaN; } r3() { if (this.pj == null || this.b2 == null) { return; } let a = !isNaN_(this.b2.jv) && !isNaN_(this.b2.jx); if (a) { return; } if (!isNaN_(this.zoomMaximumItemSpan) && !isInfinity(this.zoomMaximumItemSpan)) { let b = this.getWindowZoomFromItemSpan(this.zoomMaximumItemSpan); if (!isNaN_(b) && !isInfinity(b)) { this.b2.im = b; } } else if (!isNaN_(this.zoomMaximumCategoryRange) && !isInfinity(this.zoomMaximumCategoryRange)) { let c = this.getWindowZoomFromCategories(this.zoomMaximumCategoryRange); if (!isNaN_(c) && !isInfinity(c)) { this.b2.im = c; } } } r2() { if (this.pj == null || this.b2 == null) { return; } let a = NaN; let b = NaN; let c = this.b2.iu(); let d = this.b2.iv(); let e = false; if (MathUtil.b(this.zoomToItemSpan)) { e = true; d = this.getWindowZoomFromItemSpan(this.zoomToItemSpan); d = Math.max(d, this.b2.im); } else if (MathUtil.b(this.zoomToCategoryRange)) { e = true; d = this.getWindowZoomFromCategories(this.zoomToCategoryRange); d = Math.max(d, this.b2.im); } if (MathUtil.b(this.zoomToCategoryStart) && this.zoomToCategoryStart >= 0 && this.zoomToCategoryStart < this.p8) { e = true; b = this.getWindowZoomFromCategories(this.zoomToCategoryStart); let f = d + a - 1; let g = d - f; if (f > 0 && g > this.b2.im) { d = g; d = Math.max(d, this.b2.im); } } if (e) { this.b2.ub(a, b, c, d); } } k7(a, b, c, d) { super.k7(a, b, c, d); switch (b) { case CategoryYAxis.$$p[2]: case CategoryYAxis.$$p[3]: this.r3(); break; case CategoryYAxis.$$p[4]: case CategoryYAxis.$$p[5]: case CategoryYAxis.$$p[6]: this.r2(); break; case CategoryYAxis.$$p[0]: case CategoryYAxis.$$p[1]: this.kt(b); break; } } kt(a) { super.kt(a); switch (a) { case CategoryYAxis.$$p[0]: case CategoryYAxis.$$p[1]: this.ko(a); break; } } pm(a) { if (a == null) { return false; } let b = this.by(); if (b == null) { return false; } return b.synchronizeVertically; } lw(a) { super.lw(a); let b = this.b2 != null ? this.b2.yr : Rect.empty; let c = this.o3; let d = this.oy(); let e = this.ox(); let f = new ScalerParams(0, b, c, this.dn, d); let g = this.bp.ba(); let h = this.bp.bd(); let i = this.bp.bb(); let j = this.bp.bc(); let k = this.bp.f(); let l = this.bp.g(); let m = this.bp.h(); this.l7(); this.kh(g); this.kh(h); this.kh(i); this.kh(j); this.ep.clear(); this.eq.clear(); this.pq.clear(); this.bp.a5(this, b, c); if (b.isEmpty || c.isEmpty) { this.cd.count = 0; this.cc.count = 0; this.ca.count = 0; this.b9.count = 0; this.cb.count = 0; } if (this.cd.count == 0 && this.cc.count == 0 && this.bp.n()) { this.bp.aj(); } if (this.a4 != null) { this.a4.registerAxis(this); } if (this.itemsSource == null || this.pj == null || this.pj.count == 0) { this.cd.count = 0; this.cc.count = 0; this.ca.count = 0; this.b9.count = 0; this.cb.count = 0; this.bp.aj(); return; } if (!b.isEmpty && !c.isEmpty) { let n = this.f8(e.top, f); let o = this.f8(e.bottom, f); if (!this.dn) { n = Math.ceil(n); o = Math.floor(o); } else { n = Math.floor(n); o = Math.ceil(o); } let p = c.left; let q = 0; if (this.an != null) { let r = typeCast(NumericXAxis.$, this.an); if (r != null) { let s = this.l1(p, q, b, c, d, c.left, c.right); p = s.p0; q = s.p1; } } this.l8(g, p, c, k, true); this.bp.a0(q); let t = Math.min(n, o); let u = Math.max(n, o); let v = new LinearCategorySnapper(1, t, u, e.height, this.rj, this.categoryMode, this.gl()); let w = v.g; w = this.fn(w, this.rb(), b, c, d); if (v.g != w) { v = new LinearCategorySnapper(1, t, u, e.height, w, this.categoryMode, this.gl()); } let x = Math.floor((t - 0) / v.g); let y = Math.ceil((u - 0) / v.g); if (!isNaN_(x) && !isNaN_(y)) { let z = truncate(x); let aa = truncate(y); let ab = this.f5(0 + z * v.g, f); let ac = Math.abs(this.f5(v.g, f) - this.f5(0, f)); this.a1.b1 = this.f5(v.g, f); for (let ad = z; ad <= aa; ++ad) { let ae = this.f5(0 + (ad + 1) * v.g, f); if (ab <= e.bottom) { if (ad % 2 == 0) { this.k2(h, ab, ae, c); } this.k1(i, ab, c, l, false); this.pq.add(ab); } if (this.categoryMode != 0 && this.p9 != 0 && this.d9) { if (this.rk > 0 && this.rk < v.g) { let af = ac * this.rk; if (!this.dn) { let ag = ab; while (ag - af > ae) { ag -= af; if (Math.abs(ag - ae) < 0.0001) { break; } this.k1(j, ag, c, m, false); } } else { let ah = ab; while (ah + af < ae) { ah += af; if (Math.abs(ah - ae) < 0.0001) { break; } this.k1(j, ah, c, m, false); } } this.rf = this.rk; } else { for (let ai = 0; ai < truncate(v.g); ai++) { for (let aj = 0; aj < this.p9; aj++) { let ak = this.getGroupCenter(aj, b, c, d); if (!this.dn) { ak = -ak; } let al = this.f5(ai + ad * v.g, f) + ak; this.k1(j, al, c, m, false); } } this.rf = 0.5; } } let am = ab; if (this.categoryMode != 0) { let an = this.f5(ad * v.g + 1, f); am = (ab + an) / 2; } if (am <= e.bottom && am >= e.top) { let ao = 0; if (v.g >= 1) { ao = ad * truncate(Math.floor(v.g)); } else { if ((ad * v.g) * 2 % 2 == 0) { ao = truncate(Math.floor(ad * v.g)); } else { ao = -1; } } if (this.pj != null && ao < this.pj.count && ao >= 0) { let ap = this.pj.item(ao); let aq = this.hv(ap); if (!isNaN_(am) && !isInfinity(am) && aq != null) { if ((typeof aq === 'string') && Base.equalsStatic(aq, "")) { } else { this.ep.add1(aq); this.eq.add(new LabelPosition(0, am)); } } } } ab = ae; } } this.re = v.g; if ((this.a4 == null || this.a4.visibility == 0) && this.an != null) { if (this.a4 != null && (this.a4.location == 6 || this.a4.location == 7)) { this.b2.pr(); } } this.bp.a6(this.ep, this.eq); this.qx(); } } get_bm() { return 1; } get bm() { return this.get_bm(); } 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); } } CategoryYAxis.$t = markType(CategoryYAxis, 'CategoryYAxis', CategoryAxisBase.$, [IZoomableCategoryAxis_$type]); CategoryYAxis.r6 = DependencyProperty.i("Interval", Number_$type, CategoryYAxis.$, new PropertyMetadata(2, NaN, (a, b) => { a.lp("Interval", b.oldValue, b.newValue); a.lv(false); })); CategoryYAxis.r7 = DependencyProperty.i("MinorInterval", Number_$type, CategoryYAxis.$, new PropertyMetadata(2, NaN, (a, b) => { (typeCast(CategoryYAxis.$, a)).lp("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryYAxis.$, a)).lv(false); })); CategoryYAxis.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryYAxis, 'lp', ['CompanionAxisInterval:rg:r4', [1, NaN], 'CompanionAxisMinorInterval:rh:r5', [1, NaN], 'ZoomMaximumCategoryRange::r8', [1, NaN], 'ZoomMaximumItemSpan::r9', [1, NaN], 'ZoomToCategoryRange::sa', [1, NaN], 'ZoomToCategoryStart::sb', [1, NaN], 'ZoomToItemSpan::sc', [1, NaN]]); return CategoryYAxis; })(); /** * @hidden */ export let CategoryYAxisView = /*@__PURE__*/ (() => { class CategoryYAxisView extends CategoryAxisBaseView { constructor(a) { super(a); this.bs = null; this.bs = a; } ar() { super.ar(); this.b.g5 = AxisDefaults.categoryAxis_TickLength; } } CategoryYAxisView.$t = markType(CategoryYAxisView, 'CategoryYAxisView', CategoryAxisBaseView.$); return CategoryYAxisView; })();