UNPKG

igniteui-angular-charts

Version:

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

734 lines (733 loc) 24.3 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 class CategoryYAxis extends CategoryAxisBase { static { this.$t = markType(CategoryYAxis, 'CategoryYAxis', CategoryAxisBase.$, [IZoomableCategoryAxis_$type]); } bo() { return new CategoryYAxisView(this); } lg(a) { super.lg(a); this.ru = a; } al() { return new CategoryYAxis(); } kw(a) { super.kw(a); this.kz(a, "ActualInterval"); this.kz(a, "ActualMinorInterval"); this.kz(a, "ZoomToItemSpan"); this.kz(a, "ZoomToCategoryStart"); this.kz(a, "ZoomToCategoryRange"); this.kz(a, "ZoomMaximumItemSpan"); this.kz(a, "ZoomMaximumCategoryRange"); } kz(a, b) { super.kz(a, b); let c = typeCast(CategoryYAxis.$, a); if (c == null) { return; } let d = this; if (b == "ActualMinorInterval") { c.r4 = Axis.gy(d.r1, d.rz); } if (b == "ActualInterval") { c.r3 = Axis.gy(d.r0, d.ry); } 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_d3() { return true; } ga() { return this.pe().height; } rr(a, b, c) { return this.rs(a, b, c, true); } rt(a) { if (typeCast(List$1.$.specialize(Array_$type), a) !== null) { return a.asArray(); } return null; } la(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.qp - 1 : this.qp; 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.rt(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; } } } } constructor() { super(); this.rw = 0; this.rx = 0; this.r6 = 1; this.r5 = 1; this.p8 = new List$1(Number_$type, 0); this.ab = CategoryYAxis.$; } static { this.sq = DependencyProperty.i("Interval", Number_$type, CategoryYAxis.$, new PropertyMetadata(2, NaN, (a, b) => { a.l2("Interval", b.oldValue, b.newValue); a.l8(false); })); } get r3() { return this.c(CategoryYAxis.sq); } set r3(a) { this.h(CategoryYAxis.sq, a); } rv() { return !isNaN_(this.r3); } get ry() { return this.rw; } set ry(a) { if (this.ry != a) { let b = this.rw; this.rw = a; this.l2("ActualInterval", b, this.ry); } } go() { return this.ry; } static { this.sr = DependencyProperty.i("MinorInterval", Number_$type, CategoryYAxis.$, new PropertyMetadata(2, NaN, (a, b) => { (typeCast(CategoryYAxis.$, a)).l2("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryYAxis.$, a)).l8(false); })); } get r4() { return this.c(CategoryYAxis.sr); } set r4(a) { this.h(CategoryYAxis.sr, a); } get rz() { return this.rx; } set rz(a) { if (this.rz != a) { let b = this.rx; this.rx = a; this.l2("ActualMinorInterval", b, this.rz); } } get r8() { return this.r6; } set r8(a) { this.r6 = a; } get r7() { return this.r5; } set r7(a) { this.r5 = a; } gc(a, b) { if (!b.c.isEmpty) { let c = this.r2(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.r2(a, b.e, b.d); } r2(a, b, c) { let d = this.categoryMode == 0 ? this.qp - 1 : this.qp; if (d < 0) { d = 0; } let e = d >= 1 ? (a) / (d) : d == 0 ? 0.5 : NaN; if (!this.ds) { e = 1 - e; } return c.top + c.height * (e - b.top) / b.height; } gf(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); } ge(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.ds) { e = 1 - e; } let f = d == 0 ? this.qp - 1 : this.qp; if (f < 0) { f = 0; } return e * f; } sl(a, b) { if (isNaN_(a) || isNaN_(b) || this.p0 == null || this.p0.count == 0) { return; } let c = a / this.p0.count; let d = b / this.p0.count; this.b7.ze = new Rect(0, this.b7.ze.x, 1 - d, this.b7.ze.width, d - c); } a0() { return new VerticalAxisLabelPanel(); } fw() { return this.r3; } getCategorySize(a, b, c) { let d = this.pi(b, c); return d.height / (this.qp * a.height); } qe(a, b, c) { let d = this.ql(a, b, c); let e = 0; if (!isNaN_(this.qk)) { e = Math.min(this.qk, 1); } let f = 1 - 0.5 * d; let g = this.getCategorySize(a, b, c) * f / (this.qr - (this.qr - 1) * e); return g; } getGroupCenter(a, b, c, d) { let e = 0.5; if (this.qr > 1) { let f = this.ql(b, c, d); let g = 0; if (!isNaN_(this.qk)) { g = Math.min(this.qk, 1); } let h = 1 - 0.5 * f; let i = h / (this.qr - (this.qr - 1) * g); let j = (h - i) / (this.qr - 1); e = 0.25 * f + 0.5 * i + a * j; } return this.getCategorySize(b, c, d) * e; } sk(a) { let b = this.b7 != null ? this.b7.yv : Rect.empty; b = b.copy(); let c = this.pk; let d = new Rect(0, 0, 0, 1, 1); let e = this.ph(); let f = new ScalerParams(0, d, d, this.dr, e); let g = !b.isEmpty && !c.isEmpty && this.p0 != null ? this.p0.indexOf(a) : -1; let h = g > -1 ? this.gc(g, f) : NaN; if (!isNaN_(h) && this.b7.gb) { 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.b7.uf(b, false, true); } } ek() { if (this.d5 && this.el) { this.b1 = this.b0(); } if (this.p0 == null) { return false; } let a = false; let b = this.p0.count; if (b != this.r7) { let c = new AxisRangeChangedEventArgs(0, 1, 1, this.r7, b); this.r7 = b; this.l3(c); a = true; } this.sn(); this.sm(); return a; } getWindowZoomFromCategories(a) { let b = MathUtil.b(a) && a > 0; let c = this.p0.count; if (c > 0 && b) { let d = this.b7.zd.height; let e = isNaN_(d) || isInfinity(d); if (e) { return NaN; } let f = new Rect(0, 0, 0, 1, 1); let g = this.b7.zd; 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.p0.count; if (c > 0 && b) { let d = this.b7.zd.height; let e = isNaN_(d) || isInfinity(d); if (e) { return NaN; } let f = new Rect(0, 0, 0, 1, 1); let g = this.b7.zd; let h = this.qe(f, g, g); let i = a / h; let j = Math.min(1, 1 / i); if (j > 0 && j <= 1) { return j; } } return NaN; } sn() { if (this.p0 == null || this.b7 == null) { return; } let a = !isNaN_(this.b7.jw) && !isNaN_(this.b7.jy); if (a) { return; } if (!isNaN_(this.zoomMaximumItemSpan) && !isInfinity(this.zoomMaximumItemSpan)) { let b = this.getWindowZoomFromItemSpan(this.zoomMaximumItemSpan); if (!isNaN_(b) && !isInfinity(b)) { this.b7.io = b; } } else if (!isNaN_(this.zoomMaximumCategoryRange) && !isInfinity(this.zoomMaximumCategoryRange)) { let c = this.getWindowZoomFromCategories(this.zoomMaximumCategoryRange); if (!isNaN_(c) && !isInfinity(c)) { this.b7.io = c; } } } sm() { if (this.p0 == null || this.b7 == null) { return; } let a = NaN; let b = NaN; let c = this.b7.iv(); let d = this.b7.iw(); let e = false; if (MathUtil.b(this.zoomToItemSpan)) { e = true; d = this.getWindowZoomFromItemSpan(this.zoomToItemSpan); d = Math.max(d, this.b7.io); } else if (MathUtil.b(this.zoomToCategoryRange)) { e = true; d = this.getWindowZoomFromCategories(this.zoomToCategoryRange); d = Math.max(d, this.b7.io); } if (MathUtil.b(this.zoomToCategoryStart) && this.zoomToCategoryStart >= 0 && this.zoomToCategoryStart < this.qq) { e = true; b = this.getWindowZoomFromCategories(this.zoomToCategoryStart); let f = d + a - 1; let g = d - f; if (f > 0 && g > this.b7.io) { d = g; d = Math.max(d, this.b7.io); } } if (e) { this.b7.uc(a, b, c, d); } } lk(a, b, c, d) { super.lk(a, b, c, d); switch (b) { case CategoryYAxis.$$p[2]: case CategoryYAxis.$$p[3]: this.sn(); break; case CategoryYAxis.$$p[4]: case CategoryYAxis.$$p[5]: case CategoryYAxis.$$p[6]: this.sm(); break; case CategoryYAxis.$$p[0]: case CategoryYAxis.$$p[1]: this.k6(b); break; } } k6(a) { super.k6(a); switch (a) { case CategoryYAxis.$$p[0]: case CategoryYAxis.$$p[1]: this.k1(a); break; } } p4(a) { if (a == null) { return false; } let b = this.b3(); if (b == null) { return false; } return b.synchronizeVertically; } l9(a) { super.l9(a); let b = this.b7 != null ? this.b7.yv : Rect.empty; let c = this.pk; let d = this.pf(); let e = this.pe(); let f = new ScalerParams(0, b, c, this.dr, d); let g = this.bp.bb(); let h = this.bp.be(); let i = this.bp.bc(); let j = this.bp.bd(); let k = this.bp.g(); let l = this.bp.h(); let m = this.bp.i(); this.mk(); this.ku(g); this.ku(h); this.ku(i); this.ku(j); this.ev.clear(); this.ew.clear(); this.p8.clear(); this.bp.a6(this, b, c); if (b.isEmpty || c.isEmpty) { this.ci.count = 0; this.ch.count = 0; this.cf.count = 0; this.ce.count = 0; this.cg.count = 0; } if (this.ci.count == 0 && this.ch.count == 0 && this.bp.o()) { this.bp.ak(); } if (this.a4 != null) { this.a4.registerAxis(this); } if (this.itemsSource == null || this.p0 == null || this.p0.count == 0) { this.ci.count = 0; this.ch.count = 0; this.cf.count = 0; this.ce.count = 0; this.cg.count = 0; this.bp.ak(); return; } if (!b.isEmpty && !c.isEmpty) { let n = this.gf(e.top, f); let o = this.gf(e.bottom, f); if (!this.dr) { 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.me(p, q, b, c, d, c.left, c.right); p = s.p0; q = s.p1; } } this.ml(g, p, c, k, true); this.bp.a1(q); let t = Math.min(n, o); let u = Math.max(n, o); let v = new LinearCategorySnapper(1, t, u, e.height, this.r3, this.categoryMode, this.gs()); let w = v.g; w = this.ft(w, this.rv(), b, c, d); if (v.g != w) { v = new LinearCategorySnapper(1, t, u, e.height, w, this.categoryMode, this.gs()); } 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.gc(0 + z * v.g, f); let ac = Math.abs(this.gc(v.g, f) - this.gc(0, f)); this.a1.b3 = this.gc(v.g, f); let ad = false; for (let ae = z; ae <= aa; ++ae) { let af = ae * v.g; if (this.p3 && this.p0 != null && this.p0.count > 0 && v.g >= 1) { let ag = this.p0.count - 1; let ah = ae * truncate(Math.floor(v.g)); let ai = (ae + 1) * truncate(Math.floor(v.g)); if (ah <= ag && ai > ag && ah != ag) { let aj = this.gc(ag, f); let ak = aj; if (this.categoryMode != 0) { let al = this.gc(ag + 1, f); ak = (aj + al) / 2; } if (ak <= e.bottom && ak >= e.top) { ab = aj; af = ag; ad = true; } } } let am = this.gc(0 + (ae + 1) * v.g, f); if (ab <= e.bottom) { if (ae % 2 == 0) { this.lf(h, ab, am, c); } this.le(i, ab, c, l, false); this.p8.add(ab); } if (this.categoryMode != 0 && this.qr != 0 && this.ef) { if (this.r4 > 0 && this.r4 < v.g) { let an = ac * this.r4; if (!this.dr) { let ao = ab; while (ao - an > am) { ao -= an; if (Math.abs(ao - am) < 0.0001) { break; } this.le(j, ao, c, m, false); } } else { let ap = ab; while (ap + an < am) { ap += an; if (Math.abs(ap - am) < 0.0001) { break; } this.le(j, ap, c, m, false); } } this.rz = this.r4; } else { for (let aq = 0; aq < truncate(v.g); aq++) { for (let ar = 0; ar < this.qr; ar++) { let as = this.getGroupCenter(ar, b, c, d); if (!this.dr) { as = -as; } let at = this.gc(aq + ae * v.g, f) + as; this.le(j, at, c, m, false); } } this.rz = 0.5; } } let au = ab; if (this.categoryMode != 0) { let av = this.gc(af + 1, f); au = (ab + av) / 2; } if (this.ct && au <= e.bottom && au >= e.top) { let aw = 0; if (ad) { aw = this.p0.count - 1; } else if (v.g >= 1) { aw = ae * truncate(Math.floor(v.g)); } else { if ((ae * v.g) * 2 % 2 == 0) { aw = truncate(Math.floor(ae * v.g)); } else { aw = -1; } } if (this.p0 != null && aw < this.p0.count && aw >= 0) { let ax = this.p0.item(aw); let ay = this.h2(ax); if (!isNaN_(au) && !isInfinity(au) && ay != null) { if ((typeof ay === 'string') && Base.equalsStatic(ay, "")) { } else { this.ev.add1(ay); this.ew.add(new LabelPosition(0, au)); } } } } ab = am; } if (ad && this.a1 != null) { this.a1.an = true; } } this.ry = 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.b7.pt(); } } this.bp.a7(this.ev, this.ew); this.rg(); } } get_bm() { return 1; } get bm() { return this.get_bm(); } 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); } static { this.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryYAxis, 'l2', ['CompanionAxisInterval:r0:so', [1, NaN], 'CompanionAxisMinorInterval:r1:sp', [1, NaN], 'ZoomMaximumCategoryRange::ss', [1, NaN], 'ZoomMaximumItemSpan::st', [1, NaN], 'ZoomToCategoryRange::su', [1, NaN], 'ZoomToCategoryStart::sv', [1, NaN], 'ZoomToItemSpan::sw', [1, NaN]]); } } /** * @hidden */ export class CategoryYAxisView extends CategoryAxisBaseView { static { this.$t = markType(CategoryYAxisView, 'CategoryYAxisView', CategoryAxisBaseView.$); } constructor(a) { super(a); this.bv = null; this.bv = a; } as() { super.as(); this.c.hc = AxisDefaults.categoryAxis_TickLength; } }