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_e0() { return true; } js() { if (!isNaN_(this.jr)) { return super.js(); } return Defaults.h; } get_fo() { return true; } ct() { return new BarSeriesView(this); } zp() { return 1; } cz() { if (this.c0 == 0) { return 2; } return super.cz(); } rh(a) { super.rh(a); this.adb = a; } get_ef() { return true; } w8(a) { if (this.xAxis == null || this.yAxis == null || this.zf.k.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.dn, d); let f = this.wr(a); let g = this.kj(a, true); let h = this.kh(a, true); let i = truncate(Math.floor(g / this.aag(this.cw))); let j = truncate(Math.floor(h / this.aag(this.cw))); let k = i - this.aah(this.cw); let l = j - this.aah(this.cw); if (k < 0) { k = 0; } if (k > this.zf.k.count - 1) { k = this.zf.k.count - 1; } if (l < 0) { l = 0; } if (l > this.zf.k.count - 1) { l = this.zf.k.count - 1; } let m = this.zf.k._inner[k]; let n = this.zf.k._inner[l]; let o = Math.abs(f.y - m[0]); let p = Math.abs(f.y - n[0]); let q = this.abw(this.zo); let r = this.yAxis.pz(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); } } g2(a, b) { if (this.g5(a, b)) { return true; } if (this.x2(a, b)) { return true; } return false; } ak(a, b) { let c = new List$1(ChartSelection.$, 0); this.qi(a, c, b); return c.toArray(); } qi(a, b, c) { this.aa0(a, b, c, this.ze, 1); } constructor() { super(); this.ab = BarSeries.$; this.zk = new BarFramePreparer(1, this, this.adb, this, this, this.adb.c9); } zl(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.dw.o, this, b.c9); } } else { return this.zk; } } ac() { super.ac(); } preferredCategoryMode(a) { return 2; } pi(a, b) { super.pi(a, b); let c = typeCast(BarSeriesView.$, b); if (a && c != null && c.du != null) { c.du.count = 0; } } aaj() { if (this.bo != null) { let a = this.bo; return a.aaj(); } let b = 0; for (let c of fromEnum(this.dc.b9)) { if (c == this) { return b; } let d = typeCast(IBarSeries_$type, c); if (d != null && d.yAxis == this.yAxis && d.getPreferredCategoryMode() == 2) { b++; } } return -1; } abw(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.dn, e); b = this.xAxis.f6(this.xAxis.rb, 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; } gj(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.w6(this.cw); let g = new ScalerParams(0, d, d, this.xAxis.dn, f); let h = new ScalerParams(0, d, d, this.yAxis.dn, f); let i = this.yAxis != null ? this.yAxis.f6(e, h) : NaN; let j = this.yAxis != null ? this.zk.r(this.yAxis, d, d, f) : 0; i += j; let k = this.xAxis != null && this.valueColumn != null && e < this.valueColumn.count ? this.xAxis.f6(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; } i3() { return this.yAxis.pz(this.cw.ca, this.cw.b9, this.getEffectiveViewport1(this.cw)); } aa8(a, b) { super.aa8(a, b); let c = a.k; 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.dn, f); let h = this.yAxis; let i = new ScalerParams(0, d, e, this.yAxis.dn, f); let j = this.xAxis; let k = j.f6(j.rb, g); let l = this.yAxis.pz(d, e, f); let m = typeCast(BarSeriesView.$, b); if (isNaN_(l) || isInfinity(l) || isNaN_(k)) { m.du.count = 0; return; } this.zn.a2(this, this.z7(), runOn(this, this.y7), this.aag(b), this.aah(b)); this.zn.r = this.adc; this.zn.s = this.add; this.zn.k = this.adc; this.zn.l = this.add; let n = false; let o = this.zn.b; if (o != null) { n = true; } let p = this.xAxis.dv; let q = p ? this.xAxis : null; let r = this.valueColumn.count; let s = this.aag(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.zn.aw(r, u)[0]; if (n) { this.aa4(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.zn.ad(z, false, false, false, false); z.ap = this.zn.k; z.aq = this.zn.l; m.dz(z, Math.min(w, x), v); } m.du.count = t; b.dg(a); } po(a, b, c, d) { switch (a) { case 4: case 1: case 0: this.abi.c9.g(this.ik); break; } if (this.abi.dl) { this.abi.dk.g$i(a, b, c, d); } if (this.abi.aa.count > 0) { for (let e of fromEnum(this.abi.aa)) { e.g$i(a, b, c, d); } } switch (a) { case 4: if (this.xAxis != null && !this.xAxis.ed()) { this.r8(true); } break; case 1: if (this.xAxis != null && !this.xAxis.ed()) { this.r8(true); } break; case 0: if (this.xAxis != null && !this.xAxis.ed()) { this.r8(true); } break; case 2: if (this.aca != null && this.abi.c9.d > 0) { this.r8(true); } break; case 3: if (d == this.aca) { if (this.xAxis != null && !this.xAxis.ed()) { this.r8(true); } } break; } } rq(a, b, c, d) { super.rq(a, b, c, d); switch (b) { case VerticalAnchoredCategorySeries.$$p[0]: if (c != null) { c.cx(this); } if (d != null) { d.d3(this); } this.abi.c9.g(this.ik); if (this.xAxis != null && this.xAxis.ed()) { this.r8(false); } break; case VerticalAnchoredCategorySeries.$$p[1]: if (c != null) { c.cx(this); } if (d != null) { d.d3(this); } if (this.abi.dl) { this.abi.dk = CategoryTrendLineManagerFactory.a(this.abi.dk, this.yAxis, this.td, this, this.ds); } this.abi.c9.g(this.ik); this.r8(false); break; case "FastItemsSource": if (this.xAxis != null && !this.xAxis.ed()) { this.abi.c9.g(this.ik); this.r8(this.gm && c != null); } break; case "ValueColumn": if (this.xAxis != null && !this.xAxis.ed()) { this.abi.c9.g(this.ik); this.r8(this.gm && this.d9); } break; case "SeriesViewer": if (c != null && d == null) { this.pp(this.xAxis); this.pp(this.yAxis); } if (c == null && d != null) { this.ry(this.xAxis); this.ry(this.yAxis); } this.abi.c9.g(this.ik); this.r8(false); break; } } getPreferredCategoryMode() { return this.preferredCategoryMode(this.yAxis); } bd() { return new BarTrendLineManager(); } get useHighMarkerFidelity() { return this.aab; } } BarSeries.$t = /*@__PURE__*/ markType(BarSeries, 'BarSeries', VerticalAnchoredCategorySeries.$, [IBarSeries_$type]); BarSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, BarSeries, 'raisePropertyChanged', ['RadiusX:adc:adg', [1, 0], 'RadiusY:add:adh', [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.w4(this.c); let g = e.getEffectiveViewport1(this.c); let h = new ScalerParams(0, b, c, e.yAxis.dn, g); let i = Math.floor(e.yAxis.ga(f.top, h, 0)); let j = Math.ceil(e.yAxis.ga(f.bottom, h, 0)); if (!e.yAxis.dn) { j = Math.ceil(e.yAxis.ga(f.top, h, 0)); i = Math.floor(e.yAxis.ga(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.xv = Defaults.c; this.dt.jy = 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.il; } 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.il + 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.wl = a; this.f.jv = 5; this.f.jw = 5; this.f.jx = -5; } } BarSeriesView.$t = /*@__PURE__*/ markType(BarSeriesView, 'BarSeriesView', AnchoredCategorySeriesView.$); return BarSeriesView; })();