UNPKG

igniteui-angular-charts

Version:

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

811 lines (810 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 { Base, typeCast, Number_$type, Array_$type, markType, markDep, TypeRegistrar } from "igniteui-angular-core"; import { DependencyProperty } from "igniteui-angular-core"; import { Axis } from "./Axis"; import { List$1 } from "igniteui-angular-core"; import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel"; import { Rect } from "igniteui-angular-core"; import { ScalerParams } from "./ScalerParams"; import { NumericScaler } from "./NumericScaler"; import { LinearCategorySnapper } from "./LinearCategorySnapper"; import { NumericYAxis } from "./NumericYAxis"; import { LabelPosition } from "./LabelPosition"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { MathUtil } from "igniteui-angular-core"; 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 CategoryXAxis extends CategoryAxisBase { static { this.$t = markType(CategoryXAxis, 'CategoryXAxis', CategoryAxisBase.$, [IZoomableCategoryAxis_$type]); } bo() { return new CategoryXAxisView(this); } lg(a) { super.lg(a); this.ru = a; } al() { return new CategoryXAxis(); } 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(CategoryXAxis.$, a); if (c == null) { return; } let d = this; if (b == "ActualMinorInterval") { c.r7 = Axis.gy(d.r2, d.r0); } if (b == "ActualInterval") { c.r6 = Axis.gy(d.r1, d.rz); } 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; } } constructor() { super(); this.r9 = 1; this.r8 = 1; this.sc = null; this.rx = 0; this.ry = 0; this.p8 = new List$1(Number_$type, 0); this.ab = CategoryXAxis.$; } get sb() { return this.r9; } set sb(a) { this.r9 = a; } get sa() { return this.r8; } set sa(a) { this.r8 = a; } a0() { if (this.en) { return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel')); } else { return new HorizontalAxisLabelPanel(); } } getCategorySize(a, b, c) { let d = this.pi(b, c); return d.width / (this.qp * a.width); } qe(a, b, c) { let d = this.ql(a, b, c); let e = 0; if (!isNaN_(this.qk)) { e = Math.min(this.qk, 1); } else { e = 0; } ; let f = 1 - 0.5 * d; let g = this.qr == 0 ? 1 : this.qr; let h = this.getCategorySize(a, b, c) * f / (g - (g - 1) * e); return h; } 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; } fw() { return this.r6; } so(a) { let b = this.b7 != null ? this.b7.yv : Rect.empty; b = b.copy(); let c = this.pk; let d = this.ph(); let e = new Rect(0, 0, 0, 1, 1); let f = new ScalerParams(0, e, e, this.dr, d); 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.left + 0.1 * b.width) { h = h + 0.4 * b.width; b.x = h - 0.5 * b.width; } if (h > b.right - 0.1 * b.width) { h = h - 0.4 * b.width; b.x = h - 0.5 * b.width; } } this.b7.uf(b, false, true); } } gc(a, b) { if (!b.c.isEmpty) { let c = this.r5(a, NumericScaler.ac, b.c, this.categoryMode); c = (c - b.d.left) / b.d.width; c = b.d.left + b.d.width * (c - b.e.left) / b.e.width; return c; } return this.r5(a, b.e, b.d, this.categoryMode); } 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.left; let n = i.width; let o = g.left; let p = g.width; let q = h.left; let r = h.width; 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; z = (z - q) / r; let aa = q + r * (z - o) / p; 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; } } } } gb(a, b, c) { if (!b.c.isEmpty) { let d = this.r5(a, NumericScaler.ac, b.c, c); d = (d - b.d.left) / b.d.width; d = b.d.left + b.d.width * (d - b.e.left) / b.e.width; return d; } return this.r5(a, b.e, b.d, c); } r5(a, b, c, d) { let e = d == 0 ? this.qp - 1 : this.qp; if (e < 0) { e = 0; } let f = e >= 1 ? (a) / (e) : e == 0 ? 0.5 : NaN; if (this.ds) { f = 1 - f; } return c.left + c.width * (f - b.left) / b.width; } gf(a, b) { if (!b.c.isEmpty) { let c = b.e.left + b.e.width * (a - b.d.left) / b.d.width; c = (c * b.d.width) + b.d.left; 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.left + b.e.width * (a - b.d.left) / b.d.width; d = (d * b.d.width) + b.d.left; 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.left + (a - c.left) * b.width / c.width; if (this.ds) { e = 1 - e; } let f = d == 0 ? this.qp - 1 : this.qp; if (f < 0) { f = 0; } return e * f; } sp(a, b) { if (isNaN_(a) || isNaN_(b) || this.p0 == null || this.p0.count == 0) { return; } let c = a / this.p0.count; let d = (b + 1) / this.p0.count; this.b7.ze = new Rect(0, c, this.b7.ze.y, d - c, this.b7.ze.height); } 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(); let n = this.p0; let o = this.rv(); 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.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 || o == null || n.count == 0) { this.ci.count = 0; this.ch.count = 0; this.cf.count = 0; this.cg.count = 0; this.bp.ak(); return; } if (!b.isEmpty && !c.isEmpty) { let p = this.gf(e.left, f); let q = this.gf(e.right, f); let r = 0; let s = false; if (this.el) { let t = Math.abs(q - p); r = Math.ceil(t) + 1; if (this.dr) { if (Math.abs(q - Math.floor(q)) < Math.abs(p - Math.ceil(p))) { s = true; } } else { if (Math.abs(q - Math.ceil(q)) < Math.abs(p - Math.floor(p))) { s = true; } } } if (this.dr) { p = Math.ceil(p); q = Math.floor(q); } else { p = Math.floor(p); q = Math.ceil(q); } if (this.el) { if (Math.abs(q - p) < r) { if (this.dr) { if (s) { q--; } else { p++; } } else { if (s) { q++; } else { p--; } } } } let u = c.bottom; let v = u - c.top; if (this.an != null) { let w = typeCast(NumericYAxis.$, this.an); if (w != null) { let x = this.me(u, v, b, c, d, c.top, c.bottom); u = x.p0; v = x.p1; } } this.le(g, u, c, k, true); this.bp.a1(v); let y = Math.min(p, q); let z = Math.max(p, q); let aa = e.width; if (this.el) { let ab = this.gc(y, f); let ac = this.gc(z, f); if (ab != ac) { aa = Math.abs(ac - ab); } } let ad = new LinearCategorySnapper(1, y, z, aa, this.r6, this.categoryMode, this.gs()); let ae = ad.g; ae = this.ft(ae, this.rw(), b, c, d); if (ad.g != ae) { ad = new LinearCategorySnapper(1, y, z, aa, ae, this.categoryMode, this.gs()); } let af = Math.floor((y - 0) / ad.g); let ag = Math.ceil((z - 0) / ad.g); this.rz = ad.g; if (!isNaN_(af) && !isNaN_(ag)) { let ah = truncate(af); let ai = truncate(ag); let aj = this.r4(0 + ah * ad.g, f); let ak = this.gc(ad.g, f); let al = Math.abs(ak - this.gc(0, f)); this.bp.a2(ak); let am = truncate(Math.ceil(e.right)); let an = truncate(Math.floor(e.left)); let ao = this.r7; let ap = ao > 0 && ao < ad.g; let aq = c.right; let ar = this.p8; let as = ad.g; let at = truncate(as); let au = this.qr; let av = this.dr; let aw = this.categoryMode; let ax = false; this.sc = null; for (let ay = ah; ay <= ai; ++ay) { let az = ay * as; if (this.p3 && o != null && n.count > 0 && as >= 1) { let a0 = n.count - 1; let a1 = ay * truncate(Math.floor(as)); let a2 = (ay + 1) * truncate(Math.floor(as)); if (a1 <= a0 && a2 > a0 && a1 != a0) { let a3 = this.r4(a0, f); let a4 = this.r3(a0, a3, aw == 0, f); let a5 = truncate(Math.round(a4)); if (a5 >= an && a5 <= am) { aj = a3; az = a0; ax = true; } } } let a6 = this.r4(0 + (ay + 1) * ad.g, f); if (aj <= aq) { if (ay % 2 == 0) { this.mm(h, aj, a6, c); } this.ml(i, aj, c, l, false); ar.add(aj); } if (this.categoryMode != 0 && this.qr != 0 && this.ef) { if (ap) { let a7 = al * this.r7; if (this.dr) { let a8 = aj; while (a8 - a7 > a6) { a8 -= a7; if (Math.abs(a8 - a6) < 0.0001) { break; } this.ml(j, a8, c, m, false); } } else { let a9 = aj; while (a9 + a7 < a6) { a9 += a7; if (Math.abs(a9 - a6) < 0.0001) { break; } this.ml(j, a9, c, m, false); } } this.r0 = this.r7; } else { for (let ba = 0; ba < truncate(ad.g); ba++) { for (let bb = 0; bb < this.qr; bb++) { let bc = this.getGroupCenter(bb, b, c, d); if (this.dr) { bc = -bc; } let bd = this.gc(ba + ay * ad.g, f) + bc; this.ml(j, bd, c, m, false); } } this.r0 = 0.5; } } let be = this.r3(az, aj, aw == 0, f); let bf = truncate(Math.round(be)); if (this.ct && bf >= an && bf <= am) { let bg = 0; if (ax) { bg = n.count - 1; } else if (as >= 1) { bg = ay * truncate(Math.floor(as)); } else { if ((ay * as) * 2 % 2 == 0) { bg = truncate(Math.floor(ay * as)); } else { bg = -1; } } if (o != null && bg < n.count && bg >= 0) { let bh = o.getItem(bg); let bi = this.h2(bh); this.sc = bh; if (!isNaN_(be) && !isInfinity(be) && bi != null) { if ((typeof bi === 'string') && Base.equalsStatic(bi, "")) { } else { this.ev.add1(bi); this.ew.add(new LabelPosition(0, be)); } } } } aj = a6; } if (ax && this.a1 != null) { this.a1.an = true; } } this.sc = null; 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.bp.a7(this.ev, this.ew); this.rg(); } } 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.sa) { let c = new AxisRangeChangedEventArgs(0, 1, 1, this.sa, b); this.sa = b; this.l3(c); a = true; } this.sr(); this.sq(); 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.width; 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.width; 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; } sr() { if (this.p0 == null || this.b7 == null) { return; } let a = !isNaN_(this.b7.jx) && !isNaN_(this.b7.jz); if (a) { return; } if (!isNaN_(this.zoomMaximumItemSpan) && !isInfinity(this.zoomMaximumItemSpan)) { let b = this.getWindowZoomFromItemSpan(this.zoomMaximumItemSpan); if (!isNaN_(b) && !isInfinity(b)) { this.b7.ip = b; } } else if (!isNaN_(this.zoomMaximumCategoryRange) && !isInfinity(this.zoomMaximumCategoryRange)) { let c = this.getWindowZoomFromCategories(this.zoomMaximumCategoryRange); if (!isNaN_(c) && !isInfinity(c)) { this.b7.ip = c; } } } sq() { 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) && this.zoomToItemSpan > 0) { e = true; c = this.getWindowZoomFromItemSpan(this.zoomToItemSpan); c = Math.max(c, this.b7.ip); } else if (MathUtil.b(this.zoomToCategoryRange) && this.zoomToCategoryRange > 0 && this.zoomToCategoryRange <= this.qq) { e = true; c = this.getWindowZoomFromCategories(this.zoomToCategoryRange); c = Math.max(c, this.b7.ip); } if (MathUtil.b(this.zoomToCategoryStart) && this.zoomToCategoryStart >= 0 && this.zoomToCategoryStart < this.qq) { e = true; a = this.getWindowZoomFromCategories(this.zoomToCategoryStart); let f = c + a - 1; let g = c - f; if (f > 0 && g > this.b7.ip) { c = g; c = Math.max(c, this.b7.ip); } } if (e) { this.b7.uc(a, b, c, d); } } lk(a, b, c, d) { super.lk(a, b, c, d); switch (b) { case CategoryXAxis.$$p[2]: case CategoryXAxis.$$p[3]: this.sr(); break; case CategoryXAxis.$$p[4]: case CategoryXAxis.$$p[5]: case CategoryXAxis.$$p[6]: this.sq(); break; case CategoryXAxis.$$p[0]: case CategoryXAxis.$$p[1]: this.k6(b); break; } } k6(a) { super.k6(a); switch (a) { case CategoryXAxis.$$p[0]: case CategoryXAxis.$$p[1]: this.k1(a); break; } } static { this.su = DependencyProperty.i("Interval", Number_$type, CategoryXAxis.$, new PropertyMetadata(2, NaN, (a, b) => { a.l2("Interval", b.oldValue, b.newValue); a.l8(false); })); } get r6() { return this.c(CategoryXAxis.su); } set r6(a) { this.h(CategoryXAxis.su, a); } rw() { return !isNaN_(this.r6); } get rz() { return this.rx; } set rz(a) { if (this.rz != a) { let b = this.rx; this.rx = a; this.l2("ActualInterval", b, this.rz); } } go() { return this.rz; } static { this.sv = DependencyProperty.i("MinorInterval", Number_$type, CategoryXAxis.$, new PropertyMetadata(2, NaN, (a, b) => { (typeCast(CategoryXAxis.$, a)).l2("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryXAxis.$, a)).l8(false); })); } get r7() { return this.c(CategoryXAxis.sv); } set r7(a) { this.h(CategoryXAxis.sv, a); } get r0() { return this.ry; } set r0(a) { if (this.r0 != a) { let b = this.ry; this.ry = a; this.l2("ActualMinorInterval", b, this.r0); } } p4(a) { if (a == null) { return false; } let b = this.b3(); if (b == null) { return false; } return b.synchronizeHorizontally; } get_bm() { return 0; } get bm() { return this.get_bm(); } rv() { return this.p0; } r4(a, b) { return this.gc(a, b); } r3(a, b, c, d) { if (!c) { let e = this.r4(a + 1, d); return (b + e) / 2; } return b; } 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, CategoryXAxis, 'l2', ['CompanionAxisInterval:r1:ss', [1, NaN], 'CompanionAxisMinorInterval:r2:st', [1, NaN], 'ZoomMaximumCategoryRange::sw', [1, NaN], 'ZoomMaximumItemSpan::sx', [1, NaN], 'ZoomToCategoryRange::sy', [1, NaN], 'ZoomToCategoryStart::sz', [1, NaN], 'ZoomToItemSpan::s0', [1, NaN]]); } } /** * @hidden */ export class CategoryXAxisView extends CategoryAxisBaseView { static { this.$t = markType(CategoryXAxisView, 'CategoryXAxisView', CategoryAxisBaseView.$); } constructor(a) { super(a); this.bv = null; this.bv = a; } as() { super.as(); this.c.hc = AxisDefaults.categoryAxis_TickLength; } }