UNPKG

igniteui-react-charts

Version:

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

653 lines (652 loc) 22.1 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 { VerticalAnchoredCategorySeries } from "./VerticalAnchoredCategorySeries"; import { IBarSeries_$type } from "./IBarSeries"; import { DependencyProperty } from "igniteui-react-core"; import { Defaults } from "./Defaults"; import { Rect } from "igniteui-react-core"; import { typeCast, fromEnum, runOn, markType, markDep } from "igniteui-react-core"; import { ScalerParams } from "./ScalerParams"; import { List$1 } from "igniteui-react-core"; import { ChartSelection } from "./ChartSelection"; import { CategorySeriesView } from "./CategorySeriesView"; import { BarFramePreparer } from "./BarFramePreparer"; import { Pool$1 } from "igniteui-react-core"; import { Rectangle } from "igniteui-react-core"; import { AxisRange } from "./AxisRange"; import { CategoryBucketCalculator } from "./CategoryBucketCalculator"; import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView"; import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory"; import { BarTrendLineManager } from "./BarTrendLineManager"; import { PropertyMetadata } from "igniteui-react-core"; import { truncate, isNaN_, isInfinity } from "igniteui-react-core"; import { ISupportsMarkers_$type } from "./ISupportsMarkers"; import { Color } from "igniteui-react-core"; /** * @hidden */ export let BarSeries = /*@__PURE__*/ (() => { class BarSeries extends VerticalAnchoredCategorySeries { bk() { return new BarSeries(); } get_ez() { return true; } jn() { if (!isNaN_(this.jm)) { return super.jn(); } return Defaults.h; } get_fm() { return true; } ct() { return new BarSeriesView(this); } zf() { return 1; } cz() { if (this.c0 == 0) { return 2; } return super.cz(); } q8(a) { super.q8(a); this.ac1 = a; } get_ef() { return true; } wy(a) { if (this.xAxis == null || this.yAxis == null || this.y5.h.count == 0) { return Rect.empty; } let b = this.cw.ca; let c = this.cw.b9; let d = this.getEffectiveViewport1(this.cw); let e = new ScalerParams(0, b, c, this.xAxis.df, d); let f = this.wi(a); let g = this.ke(a, true); let h = this.kc(a, true); let i = truncate(Math.floor(g / this.z6(this.cw))); let j = truncate(Math.floor(h / this.z6(this.cw))); let k = i - this.z7(this.cw); let l = j - this.z7(this.cw); if (k < 0) { k = 0; } if (k > this.y5.h.count - 1) { k = this.y5.h.count - 1; } if (l < 0) { l = 0; } if (l > this.y5.h.count - 1) { l = this.y5.h.count - 1; } let m = this.y5.h._inner[k]; let n = this.y5.h._inner[l]; let o = Math.abs(f.y - m[0]); let p = Math.abs(f.y - n[0]); let q = this.abm(this.ze); let r = this.yAxis.ou(b, c, d); if (o < p) { let s = m[0] - 0.5 * r; let t = m[1]; let u = q; return new Rect(0, Math.min(u, t), s, Math.max(u, t) - Math.min(u, t), r); } else { let v = n[0] - 0.5 * r; let w = n[1]; let x = q; return new Rect(0, Math.min(x, w), v, Math.max(x, w) - Math.min(x, w), r); } } gx(a, b) { if (this.g0(a, b)) { return true; } if (this.xs(a, b)) { return true; } return false; } ak(a, b) { let c = new List$1(ChartSelection.$, 0); this.qa(a, c, b); return c.toArray(); } qa(a, b, c) { this.aaq(a, b, c, this.y4, 1); } constructor() { super(); this.ab = BarSeries.$; this.za = new BarFramePreparer(1, this, this.ac1, this, this, this.ac1.c9); } zb(a) { let b = typeCast(CategorySeriesView.$, a); if (b != null && b.t) { if (b.s) { return new BarFramePreparer(1, this, typeCast(ISupportsMarkers_$type, b), b, this, b.c9); } else { return new BarFramePreparer(1, this, typeCast(ISupportsMarkers_$type, b), this.dc.dp.o, this, b.c9); } } else { return this.za; } } ac() { super.ac(); } preferredCategoryMode(a) { return 2; } pb(a, b) { super.pb(a, b); let c = typeCast(BarSeriesView.$, b); if (a && c != null && c.du != null) { c.du.count = 0; } } z9() { if (this.bo != null) { let a = this.bo; return a.z9(); } let b = 0; for (let c of fromEnum(this.dc.series)) { if (c == this) { return b; } let d = typeCast(IBarSeries_$type, c); if (d != null && d.yAxis == this.yAxis && d.getPreferredCategoryMode() == 2) { b++; } } return -1; } abm(a) { let b = 0; let c = a.ca; let d = a.b9; let e = this.getEffectiveViewport1(a); if (!c.isEmpty && !d.isEmpty && this.xAxis != null) { let f = new ScalerParams(0, c, d, this.xAxis.df, e); b = this.xAxis.ft(this.xAxis.p5, f); } return b; } ay(a) { if (this.valueColumn == null || this.valueColumn.count == 0) { return null; } if (a == this.yAxis) { return new AxisRange(0, this.valueColumn.count - 1); } if (a == this.xAxis) { return new AxisRange(this.valueColumn.minimum, this.valueColumn.maximum); } return null; } ge(a) { let b = this.cw.ca; b = b.copy(); let c = this.cw.b9; let d = new Rect(0, 0, 0, 1, 1); let e = !b.isEmpty && !c.isEmpty && this.dp != null ? this.dp.indexOf(a) : -1; let f = this.ww(this.cw); let g = new ScalerParams(0, d, d, this.xAxis.df, f); let h = new ScalerParams(0, d, d, this.yAxis.df, f); let i = this.yAxis != null ? this.yAxis.ft(e, h) : NaN; let j = this.yAxis != null ? this.za.r(this.yAxis, d, d, f) : 0; i += j; let k = this.xAxis != null && this.valueColumn != null && e < this.valueColumn.count ? this.xAxis.ft(this.valueColumn.item(e), g) : NaN; if (!isNaN_(k)) { if (k < b.left + 0.1 * b.width) { k = k + 0.4 * b.width; b.x = k - 0.5 * b.width; } if (k > b.right - 0.1 * b.width) { k = k - 0.4 * b.width; b.x = k - 0.5 * b.width; } } if (!isNaN_(i)) { if (i < b.top + 0.1 * b.height) { i = i + 0.4 * b.height; b.y = i - 0.5 * b.height; } if (i > b.bottom - 0.1 * b.height) { i = i - 0.4 * b.height; b.y = i - 0.5 * b.height; } } if (this.c4 != null) { this.c4.au(this.dc, b, true); } return e >= 0; } iy() { return this.yAxis.ou(this.cw.ca, this.cw.b9, this.getEffectiveViewport1(this.cw)); } aay(a, b) { super.aay(a, b); let c = a.h; if (!b.r()) { return; } let d = b.ca; let e = b.b9; let f = this.getEffectiveViewport1(b); let g = new ScalerParams(0, d, e, this.xAxis.df, f); let h = this.yAxis; let i = new ScalerParams(0, d, e, this.yAxis.df, f); let j = this.xAxis; let k = j.ft(j.p5, g); let l = this.yAxis.ou(d, e, f); let m = typeCast(BarSeriesView.$, b); if (isNaN_(l) || isInfinity(l) || isNaN_(k)) { m.du.count = 0; return; } this.zd.a2(this, this.zx(), runOn(this, this.yx), this.z6(b), this.z7(b)); this.zd.r = this.ac2; this.zd.s = this.ac3; this.zd.k = this.ac2; this.zd.l = this.ac3; let n = false; let o = this.zd.b; if (o != null) { n = true; } let p = this.xAxis.dm; let q = p ? this.xAxis : null; let r = this.valueColumn.count; let s = this.z6(b); let t = 0; for (let u = 0; u < c.count; ++u) { let v = c._inner[u][0] - 0.5 * l; let w = c._inner[u][1]; let x = k; x = Math.max(x, -100); w = Math.min(w, e.right + 100); let y = Math.abs(w - x); if (isInfinity(y) || isNaN_(y)) { continue; } let z = m.du.item(t); t++; z.height = l; z.width = y; let aa = this.zd.aw(r, u)[0]; if (n) { this.aau(c, u, r, h, i, b.t, aa); } if (z.dataContext != null) { let ab = z.dataContext; if (s == 1) { if (aa >= 0 && aa < this.dp.count) { if (q != null && q.i$b != null && q.i$b.count > aa) { aa = q.i$b._inner[aa]; } ab.item = this.dp.item(aa); } } else { ab.item = null; } } this.zd.ad(z, false, false, false, false); z.ap = this.zd.k; z.aq = this.zd.l; m.dz(z, Math.min(w, x), v); } m.du.count = t; b.dg(a); } ph(a, b, c, d) { switch (a) { case 4: case 1: case 0: this.aa8.c9.g(this.ie); break; } if (this.aa8.dl) { this.aa8.dk.g$i(a, b, c, d); } if (this.aa8.aa.count > 0) { for (let e of fromEnum(this.aa8.aa)) { e.g$i(a, b, c, d); } } switch (a) { case 4: if (this.xAxis != null && !this.xAxis.d2()) { this.rz(true); } break; case 1: if (this.xAxis != null && !this.xAxis.d2()) { this.rz(true); } break; case 0: if (this.xAxis != null && !this.xAxis.d2()) { this.rz(true); } break; case 2: if (this.ab0 != null && this.aa8.c9.d > 0) { this.rz(true); } break; case 3: if (d == this.ab0) { if (this.xAxis != null && !this.xAxis.d2()) { this.rz(true); } } break; } } rh(a, b, c, d) { super.rh(a, b, c, d); switch (b) { case VerticalAnchoredCategorySeries.$$p[0]: if (c != null) { c.cq(this); } if (d != null) { d.du(this); } this.aa8.c9.g(this.ie); if (this.xAxis != null && this.xAxis.d2()) { this.rz(false); } break; case VerticalAnchoredCategorySeries.$$p[1]: if (c != null) { c.cq(this); } if (d != null) { d.du(this); } if (this.aa8.dl) { this.aa8.dk = CategoryTrendLineManagerFactory.a(this.aa8.dk, this.yAxis, this.s4, this, this.ds); } this.aa8.c9.g(this.ie); this.rz(false); break; case "FastItemsSource": if (this.xAxis != null && !this.xAxis.d2()) { this.aa8.c9.g(this.ie); this.rz(this.gh && c != null); } break; case "ValueColumn": if (this.xAxis != null && !this.xAxis.d2()) { this.aa8.c9.g(this.ie); this.rz(this.gh && this.d9); } break; case "SeriesViewer": if (c != null && d == null) { this.pi(this.xAxis); this.pi(this.yAxis); } if (c == null && d != null) { this.rp(this.xAxis); this.rp(this.yAxis); } this.aa8.c9.g(this.ie); this.rz(false); break; } } getPreferredCategoryMode() { return this.preferredCategoryMode(this.yAxis); } bd() { return new BarTrendLineManager(); } get useHighMarkerFidelity() { return this.z1; } } BarSeries.$t = /*@__PURE__*/ markType(BarSeries, 'BarSeries', VerticalAnchoredCategorySeries.$, [IBarSeries_$type]); BarSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, BarSeries, 'raisePropertyChanged', ['RadiusX:ac2:ac6', [1, 0], 'RadiusY:ac3:ac7', [1, 0]]); return BarSeries; })(); /** * @hidden */ export let BarBucketCalculator = /*@__PURE__*/ (() => { class BarBucketCalculator extends CategoryBucketCalculator { constructor(a) { super(a); this.i = null; this.h = null; this.j = 0; this.i = a; } g(a) { let b = this.c.ca; let c = this.c.b9; let d = this.c.db.dp; if (b.isEmpty || c.isEmpty || this.i.dt.yAxis == null || d == null || d.count == 0) { this.d = 0; return; } let e = typeCast(BarSeries.$, this.c.db); let f = e.wu(this.c); let g = e.getEffectiveViewport1(this.c); let h = new ScalerParams(0, b, c, e.yAxis.df, g); let i = Math.floor(e.yAxis.fx(f.top, h, 0)); let j = Math.ceil(e.yAxis.fx(f.bottom, h, 0)); if (!e.yAxis.df) { j = Math.ceil(e.yAxis.fx(f.top, h, 0)); i = Math.floor(e.yAxis.fx(f.bottom, h, 0)); } let k = Math.floor((j - i + 1) * a / f.height); this.d = truncate(Math.max(1, k)); this.e = truncate(Math.max(0, Math.floor(i / this.d) - 1)); this.f = truncate(Math.ceil(j / this.d)); } getBucketWithoutUnknowns(a) { let b = this.h; let c = this.j; let d = a * this.d; let e = d + this.d - 1; let f = c - 1; d = d < f ? d : f; e = e < f ? e : f; let g = 1.7976931348623157E+308; let h = -1.7976931348623157E+308; let i = true; for (let j = d; j <= e; ++j) { let k = b[j]; g = g < k ? g : k; h = h > k ? h : k; Math.max(h, k); i = false; } if (!i) { return [0.5 * (d + e), g, h]; } return [0.5 * (d + e), NaN, NaN]; } getBucket(a) { let b = this.h; let c = this.j; let d = a * this.d; let e = d + this.d - 1; let f = c - 1; d = d < f ? d : f; e = e < f ? e : f; let g = NaN; let h = NaN; for (let i = d; i <= e; ++i) { let j = b[i]; if (!isNaN_(g)) { if (!isNaN_(j)) { g = Math.min(g, j); h = Math.max(h, j); } } else { g = j; h = j; } } if (!isNaN_(g)) { return [0.5 * (d + e), g, h]; } return [0.5 * (d + e), NaN, NaN]; } cacheValues() { this.j = this.i.dt.valueColumn.count; this.h = this.i.dt.valueColumn.asArray(); } unCacheValues() { this.h = null; } } BarBucketCalculator.$t = /*@__PURE__*/ markType(BarBucketCalculator, 'BarBucketCalculator', CategoryBucketCalculator.$); return BarBucketCalculator; })(); /** * @hidden */ export let BarSeriesView = /*@__PURE__*/ (() => { class BarSeriesView extends AnchoredCategorySeriesView { constructor(a) { super(a); this.dt = null; this.du = null; this.dv = null; this.d0 = new Rectangle(); this.dt = a; this.du = ((() => { let $ret = new Pool$1(Rectangle.$); $ret.create = runOn(this, this.d1); $ret.activate = runOn(this, this.dw); $ret.disactivate = runOn(this, this.dy); $ret.destroy = runOn(this, this.dx); return $ret; })()); this.dk = new BarTrendLineManager(); } a4() { super.a4(); this.dv = new List$1(Rectangle.$, 0); if (!this.t) { this.dt.xl = Defaults.c; this.dt.jt = Defaults.i; } } d1() { let a = new Rectangle(); this.dv.add(a); a._visibility = 1; return a; } dw(a) { a._visibility = 0; } dy(a) { a._visibility = 1; } dx(a) { this.dv.remove(a); } dz(a, b, c) { if (!this.isDirty) { this.a2(); } a.o = c; a.n = b; } da() { return new BarBucketCalculator(this); } bt(a, b) { super.bt(a, b); let c = a; let d = this.b4(b); c._fill = d; c._stroke = d; c.ad = this.f.ig; } ak(a) { return this.dv._inner[a]; } aj(a) { let b = this.dv._inner[a]; this.d0.n = b.n; this.d0.o = b.o; this.d0.width = b.width; this.d0.height = b.height; let c = this.b4(a); this.d0._fill = c; this.d0._stroke = c; this.d0.ad = this.f.ig + 3; return this.d0; } bj(a, b) { super.bj(a, b); if (a.d) { for (let c = 0; c < this.dv.count; c++) { let d = this.ai(c, b); this.br(d, c, b); a.w(d); } } } ax(a) { super.ax(a); let b = 0; let c = new List$1(Rectangle.$, 0); for (let d of fromEnum(this.du.a)) { c.add(d); } c.aa((e, f) => { if (e.o > f.o) { return -1; } else if (e.o < f.o) { return 1; } else { return 0; } }); for (let e of fromEnum(c)) { this.f.bc.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]); } b++; } an() { let a = new Color(); a.colorString = "rgba(95,95,95,0.5)"; this.f.wc = a; this.f.jq = 5; this.f.jr = 5; this.f.js = -5; } } BarSeriesView.$t = /*@__PURE__*/ markType(BarSeriesView, 'BarSeriesView', AnchoredCategorySeriesView.$); return BarSeriesView; })();