UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

710 lines (709 loc) 25.8 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-react-core"; import { Axis } from "./Axis"; import { Rect } from "igniteui-react-core"; import { Base, typeCast, Array_$type, Number_$type, markType, markDep } from "igniteui-react-core"; import { List$1 } from "igniteui-react-core"; import { ScalerParams } from "./ScalerParams"; import { NumericScaler } from "./NumericScaler"; import { VerticalAxisLabelPanel } from "./VerticalAxisLabelPanel"; import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs"; import { MathUtil } from "igniteui-react-core"; import { LinearCategorySnapper } from "./LinearCategorySnapper"; import { NumericXAxis } from "./NumericXAxis"; import { LabelPosition } from "./LabelPosition"; import { PropertyMetadata } from "igniteui-react-core"; import { truncate, isNaN_, isInfinity } from "igniteui-react-core"; import { CategoryAxisBaseView } from "./CategoryAxisBaseView"; import { AxisDefaults } from "./AxisDefaults"; /** * @hidden */ export let CategoryYAxis = /*@__PURE__*/ (() => { class CategoryYAxis extends CategoryAxisBase { bm() { return new CategoryYAxisView(this); } kb(a) { super.kb(a); this.p8 = a; } ak() { return new CategoryYAxis(); } jr(a) { super.jr(a); this.ju(a, "ActualInterval"); this.ju(a, "ActualMinorInterval"); this.ju(a, "ZoomToItemSpan"); this.ju(a, "ZoomToCategoryStart"); this.ju(a, "ZoomToCategoryRange"); this.ju(a, "ZoomMaximumItemSpan"); this.ju(a, "ZoomMaximumCategoryRange"); } ju(a, b) { super.ju(a, b); let c = typeCast(CategoryYAxis.$, a); if (c == null) { return; } let d = this; if (b == "ActualMinorInterval") { c.qi = Axis.gf(c.qf, d.qd); } if (b == "ActualInterval") { c.qh = Axis.gf(c.qe, d.qc); } 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_dq() { return true; } fs() { return this.nv().height; } p5(a, b, c) { return this.p6(a, b, c, true); } p7(a) { if (typeCast(List$1.$.specialize(Array_$type), a) !== null) { return a.asArray(); } return null; } j5(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.o5 - 1 : this.o5; 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.p7(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.qa = 0; this.qb = 0; this.qk = 1; this.qj = 1; this.oo = new List$1(Number_$type, 0); this.ab = CategoryYAxis.$; } get qh() { return this.c(CategoryYAxis.q4); } set qh(a) { this.h(CategoryYAxis.q4, a); } p9() { return !isNaN_(this.qh); } get qc() { return this.qa; } set qc(a) { if (this.qc != a) { let b = this.qa; this.qa = a; this.kx("ActualInterval", b, this.qc); } } f5() { return this.qc; } get qi() { return this.c(CategoryYAxis.q5); } set qi(a) { this.h(CategoryYAxis.q5, a); } get qd() { return this.qb; } set qd(a) { if (this.qd != a) { let b = this.qb; this.qb = a; this.kx("ActualMinorInterval", b, this.qd); } } get qm() { return this.qk; } set qm(a) { this.qk = a; } get ql() { return this.qj; } set ql(a) { this.qj = a; } ft(a, b) { if (!b.c.isEmpty) { let c = this.qg(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.qg(a, b.e, b.d); } qg(a, b, c) { let d = this.categoryMode == 0 ? this.o5 - 1 : this.o5; if (d < 0) { d = 0; } let e = d >= 1 ? (a) / (d) : d == 0 ? 0.5 : NaN; if (!this.dg) { e = 1 - e; } return c.top + c.height * (e - b.top) / b.height; } fw(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); } fx(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.dg) { e = 1 - e; } let f = d == 0 ? this.o5 - 1 : this.o5; if (f < 0) { f = 0; } return e * f; } qz(a, b) { if (isNaN_(a) || isNaN_(b) || this.oh == null || this.oh.count == 0) { return; } let c = a / this.oh.count; let d = b / this.oh.count; this.b0.x6 = new Rect(0, this.b0.x6.x, 1 - d, this.b0.x6.width, d - c); } az() { return new VerticalAxisLabelPanel(); } fe() { return this.qh; } getCategorySize(a, b, c) { let d = this.nz(b, c); return d.height / (this.o5 * a.height); } ou(a, b, c) { let d = this.o1(a, b, c); let e = 0; if (!isNaN_(this.o0)) { e = Math.min(this.o0, 1); } let f = 1 - 0.5 * d; let g = this.getCategorySize(a, b, c) * f / (this.o7 - (this.o7 - 1) * e); return g; } getGroupCenter(a, b, c, d) { let e = 0.5; if (this.o7 > 1) { let f = this.o1(b, c, d); let g = 0; if (!isNaN_(this.o0)) { g = Math.min(this.o0, 1); } let h = 1 - 0.5 * f; let i = h / (this.o7 - (this.o7 - 1) * g); let j = (h - i) / (this.o7 - 1); e = 0.25 * f + 0.5 * i + a * j; } return this.getCategorySize(b, c, d) * e; } qy(a) { let b = this.b0 != null ? this.b0.xn : Rect.empty; b = b.copy(); let c = this.n1; let d = new Rect(0, 0, 0, 1, 1); let e = this.ny(); let f = new ScalerParams(0, d, d, this.df, e); let g = !b.isEmpty && !c.isEmpty && this.oh != null ? this.oh.indexOf(a) : -1; let h = g > -1 ? this.ft(g, f) : NaN; if (!isNaN_(h) && this.b0.fx) { 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.b0.tb(b, false, true); } } d4() { if (this.dr && this.d5) { this.bu = this.bt(); } if (this.oh == null) { return false; } let a = false; let b = this.oh.count; if (b != this.ql) { let c = new AxisRangeChangedEventArgs(0, 1, 1, this.ql, b); this.ql = b; this.ky(c); a = true; } this.q1(); this.q0(); return a; } getWindowZoomFromCategories(a) { let b = MathUtil.a(a) && a > 0; let c = this.oh.count; if (c > 0 && b) { let d = this.b0.x5.height; let e = isNaN_(d) || isInfinity(d); if (e) { return NaN; } let f = new Rect(0, 0, 0, 1, 1); let g = this.b0.x5; 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.a(a) && a > 0; let c = this.oh.count; if (c > 0 && b) { let d = this.b0.x5.height; let e = isNaN_(d) || isInfinity(d); if (e) { return NaN; } let f = new Rect(0, 0, 0, 1, 1); let g = this.b0.x5; let h = this.ou(f, g, g); let i = a / h; let j = Math.min(1, 1 / i); if (j > 0 && j <= 1) { return j; } } return NaN; } q1() { if (this.oh == null || this.b0 == null) { return; } let a = !isNaN_(this.b0.jg) && !isNaN_(this.b0.ji); if (a) { return; } if (!isNaN_(this.zoomMaximumItemSpan) && !isInfinity(this.zoomMaximumItemSpan)) { let b = this.getWindowZoomFromItemSpan(this.zoomMaximumItemSpan); if (!isNaN_(b) && !isInfinity(b)) { this.b0.h6 = b; } } else if (!isNaN_(this.zoomMaximumCategoryRange) && !isInfinity(this.zoomMaximumCategoryRange)) { let c = this.getWindowZoomFromCategories(this.zoomMaximumCategoryRange); if (!isNaN_(c) && !isInfinity(c)) { this.b0.h6 = c; } } } q0() { if (this.oh == null || this.b0 == null) { return; } let a = NaN; let b = NaN; let c = this.b0.id(); let d = this.b0.ie(); let e = false; if (MathUtil.a(this.zoomToItemSpan)) { e = true; d = this.getWindowZoomFromItemSpan(this.zoomToItemSpan); d = Math.max(d, this.b0.h6); } else if (MathUtil.a(this.zoomToCategoryRange)) { e = true; d = this.getWindowZoomFromCategories(this.zoomToCategoryRange); d = Math.max(d, this.b0.h6); } if (MathUtil.a(this.zoomToCategoryStart) && this.zoomToCategoryStart >= 0 && this.zoomToCategoryStart < this.o6) { e = true; b = this.getWindowZoomFromCategories(this.zoomToCategoryStart); let f = d + a - 1; let g = d - f; if (f > 0 && g > this.b0.h6) { d = g; d = Math.max(d, this.b0.h6); } } if (e) { this.b0.s9(a, b, c, d); } } kf(a, b, c, d) { super.kf(a, b, c, d); switch (b) { case CategoryYAxis.$$p[2]: case CategoryYAxis.$$p[3]: this.q1(); break; case CategoryYAxis.$$p[4]: case CategoryYAxis.$$p[5]: case CategoryYAxis.$$p[6]: this.q0(); break; case CategoryYAxis.$$p[0]: case CategoryYAxis.$$p[1]: this.j1(b); break; } } j1(a) { super.j1(a); switch (a) { case CategoryYAxis.$$p[0]: case CategoryYAxis.$$p[1]: this.jw(a); break; } } ok(a) { if (a == null) { return false; } let b = this.bw(); if (b == null) { return false; } return b.synchronizeVertically; } k4(a) { super.k4(a); let b = this.b0 != null ? this.b0.xn : Rect.empty; let c = this.n1; let d = this.nw(); let e = this.nv(); let f = new ScalerParams(0, b, c, this.df, d); let g = this.bn.a4(); let h = this.bn.a7(); let i = this.bn.a5(); let j = this.bn.a6(); let k = this.bn.e(); let l = this.bn.f(); let m = this.bn.g(); this.lf(); this.jp(g); this.jp(h); this.jp(i); this.jp(j); this.ef.clear(); this.eg.clear(); this.oo.clear(); this.bn.az(this, b, c); if (b.isEmpty || c.isEmpty) { this.b9.count = 0; this.b8.count = 0; this.b7.count = 0; } if (this.b9.count == 0 && this.b8.count == 0 && this.bn.l()) { this.bn.ad(); } if (this.a3 != null) { this.a3.registerAxis(this); } if (this.itemsSource == null || this.oh == null || this.oh.count == 0) { this.b9.count = 0; this.b8.count = 0; this.b7.count = 0; this.bn.ad(); return; } if (!b.isEmpty && !c.isEmpty) { let n = this.fw(e.top, f); let o = this.fw(e.bottom, f); if (!this.df) { 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.am != null) { let r = typeCast(NumericXAxis.$, this.am); if (r != null) { let s = this.k9(p, q, b, c, d, c.left, c.right); p = s.p0; q = s.p1; } } this.lg(g, p, c, k, true); this.bn.au(q); let t = Math.min(n, o); let u = Math.max(n, o); let v = new LinearCategorySnapper(1, t, u, e.height, this.qh, this.categoryMode, this.f9()); let w = v.g; w = this.fb(w, this.p9(), b, c, d); if (v.g != w) { v = new LinearCategorySnapper(1, t, u, e.height, w, this.categoryMode, this.f9()); } 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.ft(0 + z * v.g, f); let ac = Math.abs(this.ft(v.g, f) - this.ft(0, f)); this.a0.bz = this.ft(v.g, f); for (let ad = z; ad <= aa; ++ad) { let ae = this.ft(0 + (ad + 1) * v.g, f); if (ab <= e.bottom) { if (ad % 2 == 0) { this.ka(h, ab, ae, c); } this.j9(i, ab, c, l, false); this.oo.add(ab); } if (this.categoryMode != 0 && this.o7 != 0 && this.dz) { if (this.qi > 0 && this.qi < v.g) { let af = ac * this.qi; if (!this.df) { let ag = ab; while (ag - af > ae) { ag -= af; if (Math.abs(ag - ae) < 0.0001) { break; } this.j9(j, ag, c, m, false); } } else { let ah = ab; while (ah + af < ae) { ah += af; if (Math.abs(ah - ae) < 0.0001) { break; } this.j9(j, ah, c, m, false); } } this.qd = this.qi; } else { for (let ai = 0; ai < truncate(v.g); ai++) { for (let aj = 0; aj < this.o7; aj++) { let ak = this.getGroupCenter(aj, b, c, d); if (!this.df) { ak = -ak; } let al = this.ft(ai + ad * v.g, f) + ak; this.j9(j, al, c, m, false); } } this.qd = 0.5; } } let am = ab; if (this.categoryMode != 0) { let an = this.ft(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.oh != null && ao < this.oh.count && ao >= 0) { let ap = this.oh.item(ao); let aq = this.hf(ap); if (!isNaN_(am) && !isInfinity(am) && aq != null) { if ((typeof aq === 'string') && Base.equalsStatic(aq, "")) { } else { this.ef.add1(aq); this.eg.add(new LabelPosition(am)); } } } } ab = ae; } } this.qc = v.g; if ((this.a3 == null || this.a3.visibility == 0) && this.am != null) { if (this.a3 != null && (this.a3.location == 6 || this.a3.location == 7)) { this.b0.o2(); } } this.bn.a0(this.ef, this.eg); this.pv(); } } get_bk() { return 1; } get bk() { return this.get_bk(); } get isVertical() { return this.dq; } j$d(a, b) { return this.fw.apply(this, arguments); } j$c(a, b) { return this.ft.apply(this, arguments); } j$e(a, b, c, d, e) { this.j5.apply(this, arguments); } j$f(a, b, c, d) { this.j6.apply(this, arguments); } j$g(a, b, c, d) { this.j7.apply(this, arguments); } get j$b() { return this.df; } j$a() { return this.ag.apply(this, arguments); } } CategoryYAxis.$t = /*@__PURE__*/ markType(CategoryYAxis, 'CategoryYAxis', CategoryAxisBase.$, [IZoomableCategoryAxis_$type]); CategoryYAxis.q4 = /*@__PURE__*/ DependencyProperty.i("Interval", Number_$type, CategoryYAxis.$, /*@__PURE__*/ new PropertyMetadata(2, NaN, (a, b) => { a.kx("Interval", b.oldValue, b.newValue); a.k3(false); })); CategoryYAxis.q5 = /*@__PURE__*/ DependencyProperty.i("MinorInterval", Number_$type, CategoryYAxis.$, /*@__PURE__*/ new PropertyMetadata(2, NaN, (a, b) => { (typeCast(CategoryYAxis.$, a)).kx("MinorInterval", b.oldValue, b.newValue); (typeCast(CategoryYAxis.$, a)).k3(false); })); CategoryYAxis.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryYAxis, 'kx', ['CompanionAxisInterval:qe:q2', [1, NaN], 'CompanionAxisMinorInterval:qf:q3', [1, NaN], 'ZoomMaximumCategoryRange::q6', [1, NaN], 'ZoomMaximumItemSpan::q7', [1, NaN], 'ZoomToCategoryRange::q8', [1, NaN], 'ZoomToCategoryStart::q9', [1, NaN], 'ZoomToItemSpan::ra', [1, NaN]]); return CategoryYAxis; })(); /** * @hidden */ export let CategoryYAxisView = /*@__PURE__*/ (() => { class CategoryYAxisView extends CategoryAxisBaseView { constructor(a) { super(a); this.bm = null; this.bm = a; } al() { super.al(); this.a.gt = AxisDefaults.categoryAxis_TickLength; } } CategoryYAxisView.$t = /*@__PURE__*/ markType(CategoryYAxisView, 'CategoryYAxisView', CategoryAxisBaseView.$); return CategoryYAxisView; })();