UNPKG

igniteui-react-charts

Version:

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

648 lines (647 loc) 22 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_ey() { return true; } jk() { if (!isNaN_(this.jj)) { return super.jk(); } return Defaults.h; } get_fl() { return true; } ct() { return new BarSeriesView(this); } y6() { return 1; } cz() { if (this.c0 == 0) { return 2; } return super.cz(); } q1(a) { super.q1(a); this.acp = a; } get_ee() { return true; } wp(a) { if (this.xAxis == null || this.yAxis == null || this.yw.h.count == 0) { return Rect.empty; } let b = this.cw.b2; let c = this.cw.b1; let d = this.getEffectiveViewport1(this.cw); let e = new ScalerParams(0, b, c, this.xAxis.ch, d); let f = this.v9(a); let g = this.ka(a, true); let h = this.j8(a, true); let i = truncate(Math.floor(g / this.zx(this.cw))); let j = truncate(Math.floor(h / this.zx(this.cw))); let k = i - this.zy(this.cw); let l = j - this.zy(this.cw); if (k < 0) { k = 0; } if (k > this.yw.h.count - 1) { k = this.yw.h.count - 1; } if (l < 0) { l = 0; } if (l > this.yw.h.count - 1) { l = this.yw.h.count - 1; } let m = this.yw.h._inner[k]; let n = this.yw.h._inner[l]; let o = Math.abs(f.y - m[0]); let p = Math.abs(f.y - n[0]); let q = this.aba(this.y5); let r = this.yAxis.k8(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); } } gw(a, b) { if (this.gz(a, b)) { return true; } if (this.xj(a, b)) { return true; } return false; } ak(a, b) { let c = new List$1(ChartSelection.$, 0); this.p4(a, c, b); return c.toArray(); } p4(a, b, c) { this.aae(a, b, c, this.yv, 1); } constructor() { super(); this.ab = BarSeries.$; this.y1 = new BarFramePreparer(1, this, this.acp, this, this, this.acp.c0); } y2(a) { let b = typeCast(CategorySeriesView.$, a); if (b != null && b.r) { if (b.q) { return new BarFramePreparer(1, this, typeCast(ISupportsMarkers_$type, b), b, this, b.c0); } else { return new BarFramePreparer(1, this, typeCast(ISupportsMarkers_$type, b), this.dc.c9.o, this, b.c0); } } else { return this.y1; } } ac() { super.ac(); } preferredCategoryMode(a) { return 2; } o5(a, b) { super.o5(a, b); let c = typeCast(BarSeriesView.$, b); if (a && c != null && c.dk != null) { c.dk.count = 0; } } z0() { if (this.bo != null) { let a = this.bo; return a.z0(); } 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; } aba(a) { let b = 0; let c = a.b2; let d = a.b1; let e = this.getEffectiveViewport1(a); if (!c.isEmpty && !d.isEmpty && this.xAxis != null) { let f = new ScalerParams(0, c, d, this.xAxis.ch, e); b = this.xAxis.el(this.xAxis.me, 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; } gd(a) { let b = this.cw.b2; b = b.copy(); let c = this.cw.b1; 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.wn(this.cw); let g = new ScalerParams(0, d, d, this.xAxis.ch, f); let h = new ScalerParams(0, d, d, this.yAxis.ch, f); let i = this.yAxis != null ? this.yAxis.el(e, h) : NaN; let j = this.yAxis != null ? this.y1.r(this.yAxis, d, d, f) : 0; i += j; let k = this.xAxis != null && this.valueColumn != null && e < this.valueColumn.count ? this.xAxis.el(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; } iw() { return this.yAxis.k8(this.cw.b2, this.cw.b1, this.getEffectiveViewport1(this.cw)); } aam(a, b) { super.aam(a, b); let c = a.h; if (!b.p()) { return; } let d = b.b2; let e = b.b1; let f = this.getEffectiveViewport1(b); let g = new ScalerParams(0, d, e, this.xAxis.ch, f); let h = this.yAxis; let i = new ScalerParams(0, d, e, this.yAxis.ch, f); let j = this.xAxis; let k = j.el(j.me, g); let l = this.yAxis.k8(d, e, f); let m = typeCast(BarSeriesView.$, b); if (isNaN_(l) || isInfinity(l) || isNaN_(k)) { m.dk.count = 0; return; } this.y4.a2(this, this.zo(), runOn(this, this.yo), this.zx(b), this.zy(b)); this.y4.r = this.acq; this.y4.s = this.acr; this.y4.k = this.acq; this.y4.l = this.acr; let n = false; let o = this.y4.b; if (o != null) { n = true; } let p = this.xAxis.cn; let q = p ? this.xAxis : null; let r = this.valueColumn.count; let s = this.zx(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.dk.item(t); t++; z.height = l; z.width = y; let aa = this.y4.aw(r, u)[0]; if (n) { this.aai(c, u, r, h, i, b.r, 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.y4.ad(z, false, false, false, false); z.ap = this.y4.k; z.aq = this.y4.l; m.dq(z, Math.min(w, x), v); } m.dk.count = t; b.c7(a); } pb(a, b, c, d) { switch (a) { case 4: case 1: case 0: this.aaw.c0.g(this.id); break; } if (this.aaw.dc) { this.aaw.db.g$i(a, b, c, d); } switch (a) { case 4: if (this.xAxis != null && !this.xAxis.c1()) { this.rs(true); } break; case 1: if (this.xAxis != null && !this.xAxis.c1()) { this.rs(true); } break; case 0: if (this.xAxis != null && !this.xAxis.c1()) { this.rs(true); } break; case 2: if (this.abo != null && this.aaw.c0.d > 0) { this.rs(true); } break; case 3: if (d == this.abo) { if (this.xAxis != null && !this.xAxis.c1()) { this.rs(true); } } break; } } ra(a, b, c, d) { super.ra(a, b, c, d); switch (b) { case VerticalAnchoredCategorySeries.$$p[0]: if (c != null) { c.b0(this); } if (d != null) { d.ct(this); } this.aaw.c0.g(this.id); if (this.xAxis != null && this.xAxis.c1()) { this.rs(false); } break; case VerticalAnchoredCategorySeries.$$p[1]: if (c != null) { c.b0(this); } if (d != null) { d.ct(this); } if (this.aaw.dc) { this.aaw.db = CategoryTrendLineManagerFactory.a(this.aaw.db, this.yAxis, this.sx, this, this.ds); } this.aaw.c0.g(this.id); this.rs(false); break; case "FastItemsSource": if (this.xAxis != null && !this.xAxis.c1()) { this.aaw.c0.g(this.id); this.rs(this.gg && c != null); } break; case "ValueColumn": if (this.xAxis != null && !this.xAxis.c1()) { this.aaw.c0.g(this.id); this.rs(this.gg && this.d8); } break; case "SeriesViewer": if (c != null && d == null) { this.pc(this.xAxis); this.pc(this.yAxis); } if (c == null && d != null) { this.ri(this.xAxis); this.ri(this.yAxis); } this.aaw.c0.g(this.id); this.rs(false); break; } } getPreferredCategoryMode() { return this.preferredCategoryMode(this.yAxis); } bd() { return new BarTrendLineManager(); } get useHighMarkerFidelity() { return this.zs; } } BarSeries.$t = /*@__PURE__*/ markType(BarSeries, 'BarSeries', VerticalAnchoredCategorySeries.$, [IBarSeries_$type]); BarSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, BarSeries, 'raisePropertyChanged', ['RadiusX:acq:acu', [1, 0], 'RadiusY:acr:acv', [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.b2; let c = this.c.b1; let d = this.c.c2.dp; if (b.isEmpty || c.isEmpty || this.i.dj.yAxis == null || d == null || d.count == 0) { this.d = 0; return; } let e = typeCast(BarSeries.$, this.c.c2); let f = e.wl(this.c); let g = e.getEffectiveViewport1(this.c); let h = new ScalerParams(0, b, c, e.yAxis.ch, g); let i = Math.floor(e.yAxis.ep(f.top, h, 0)); let j = Math.ceil(e.yAxis.ep(f.bottom, h, 0)); if (!e.yAxis.ch) { j = Math.ceil(e.yAxis.ep(f.top, h, 0)); i = Math.floor(e.yAxis.ep(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.dj.valueColumn.count; this.h = this.i.dj.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.dj = null; this.dk = null; this.dl = null; this.dr = new Rectangle(); this.dj = a; this.dk = ((() => { let $ret = new Pool$1(Rectangle.$); $ret.create = runOn(this, this.ds); $ret.activate = runOn(this, this.dm); $ret.disactivate = runOn(this, this.dp); $ret.destroy = runOn(this, this.dn); return $ret; })()); this.db = new BarTrendLineManager(); } ax() { super.ax(); this.dl = new List$1(Rectangle.$, 0); if (!this.r) { this.dj.xc = Defaults.c; this.dj.jp = Defaults.i; } } ds() { let a = new Rectangle(); this.dl.add(a); a._visibility = 1; return a; } dm(a) { a._visibility = 0; } dp(a) { a._visibility = 1; } dn(a) { this.dl.remove(a); } dq(a, b, c) { if (!this.isDirty) { this.av(); } a.o = c; a.n = b; } c1() { return new BarBucketCalculator(this); } bl(a, b) { super.bl(a, b); let c = a; let d = this.bw(b); c._fill = d; c._stroke = d; c.ad = this.f.ie; } af(a) { return this.dl._inner[a]; } ae(a) { let b = this.dl._inner[a]; this.dr.n = b.n; this.dr.o = b.o; this.dr.width = b.width; this.dr.height = b.height; let c = this.bw(a); this.dr._fill = c; this.dr._stroke = c; this.dr.ad = this.f.ie + 3; return this.dr; } bc(a, b) { super.bc(a, b); if (a.d) { for (let c = 0; c < this.dl.count; c++) { let d = this.ad(c, b); this.bj(d, c, b); a.w(d); } } } aq(a) { super.aq(a); let b = 0; let c = new List$1(Rectangle.$, 0); for (let d of fromEnum(this.dk.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++; } ai() { let a = new Color(); a.colorString = "rgba(95,95,95,0.5)"; this.f.v3 = a; this.f.jm = 5; this.f.jn = 5; this.f.jo = -5; } } BarSeriesView.$t = /*@__PURE__*/ markType(BarSeriesView, 'BarSeriesView', AnchoredCategorySeriesView.$); return BarSeriesView; })();