UNPKG

igniteui-angular-charts

Version:

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

645 lines (644 loc) 22.5 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-angular-core"; import { Defaults } from "./Defaults"; import { Rect } from "igniteui-angular-core"; import { typeCast, fromEnum, runOn, markType, markDep } from "igniteui-angular-core"; import { ScalerParams } from "./ScalerParams"; import { List$1 } from "igniteui-angular-core"; import { ChartSelection } from "./ChartSelection"; import { CategorySeriesView } from "./CategorySeriesView"; import { BarFramePreparer } from "./BarFramePreparer"; import { Pool$1 } from "igniteui-angular-core"; import { Rectangle } from "igniteui-angular-core"; import { AxisRange } from "./AxisRange"; import { CategoryBucketCalculator } from "./CategoryBucketCalculator"; import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView"; import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory"; import { PropertyMetadata } from "igniteui-angular-core"; import { truncate, isNaN_, isInfinity } from "igniteui-angular-core"; import { ISupportsMarkers_$type } from "./ISupportsMarkers"; import { BarTrendLineManager } from "./BarTrendLineManager"; import { Color } from "igniteui-angular-core"; /** * @hidden */ export let BarSeries = /*@__PURE__*/ (() => { class BarSeries extends VerticalAnchoredCategorySeries { constructor() { super(); this.ab = BarSeries.$; this.yy = new BarFramePreparer(1, this, this.acn, this, this, this.acn.cw); } bj() { return new BarSeries(); } get_ex() { return true; } jj() { if (!isNaN_(this.ji)) { return super.jj(); } return Defaults.h; } get_fk() { return true; } cs() { return new BarSeriesView(this); } y3() { return 1; } cy() { if (this.cz == 0) { return 2; } return super.cy(); } q0(a) { super.q0(a); this.acn = a; } get_ed() { return true; } wm(a) { if (this.xAxis == null || this.yAxis == null || this.yt.f.count == 0) { return Rect.empty; } let b = this.cv.by; let c = this.cv.bx; let d = this.getEffectiveViewport1(this.cv); let e = new ScalerParams(0, b, c, this.xAxis.ch, d); let f = this.v6(a); let g = this.j9(a, true); let h = this.j7(a, true); let i = truncate(Math.floor(g / this.zu(this.cv))); let j = truncate(Math.floor(h / this.zu(this.cv))); let k = i - this.zv(this.cv); let l = j - this.zv(this.cv); if (k < 0) { k = 0; } if (k > this.yt.f.count - 1) { k = this.yt.f.count - 1; } if (l < 0) { l = 0; } if (l > this.yt.f.count - 1) { l = this.yt.f.count - 1; } let m = this.yt.f._inner[k]; let n = this.yt.f._inner[l]; let o = Math.abs(f.y - m[0]); let p = Math.abs(f.y - n[0]); let q = this.aa8(this.y2); 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); } } gv(a, b) { if (this.gy(a, b)) { return true; } if (this.xg(a, b)) { return true; } return false; } ak(a, b) { let c = new List$1(ChartSelection.$, 0); this.p3(a, c, b); return c.toArray(); } p3(a, b, c) { this.aab(a, b, c, this.ys, 1); } yz(a) { let b = typeCast(CategorySeriesView.$, a); if (b != null && b.q) { if (b.p) { return new BarFramePreparer(1, this, typeCast(ISupportsMarkers_$type, b), b, this, b.cw); } else { return new BarFramePreparer(1, this, typeCast(ISupportsMarkers_$type, b), this.db.c9.o, this, b.cw); } } else { return this.yy; } } ac() { super.ac(); } preferredCategoryMode(a) { return 2; } o4(a, b) { super.o4(a, b); let c = typeCast(BarSeriesView.$, b); if (a && c != null && c.dg != null) { c.dg.count = 0; } } zx() { if (this.bn != null) { let a = this.bn; return a.zx(); } let b = 0; for (let c of fromEnum(this.db.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; } aa8(a) { let b = 0; let c = a.by; let d = a.bx; 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; } gc(a) { let b = this.cv.by; b = b.copy(); let c = this.cv.bx; let d = new Rect(0, 0, 0, 1, 1); let e = !b.isEmpty && !c.isEmpty && this.dn != null ? this.dn.indexOf(a) : -1; let f = this.wk(this.cv); 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.yy.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.c3 != null) { this.c3.au(this.db, b, true); } return e >= 0; } iv() { return this.yAxis.k8(this.cv.by, this.cv.bx, this.getEffectiveViewport1(this.cv)); } aaj(a, b) { super.aaj(a, b); let c = a.f; if (!b.o()) { return; } let d = b.by; let e = b.bx; 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.dg.count = 0; return; } this.y1.a2(this, this.zl(), runOn(this, this.yl), this.zu(b), this.zv(b)); this.y1.r = this.aco; this.y1.s = this.acp; this.y1.k = this.aco; this.y1.l = this.acp; let n = false; let o = this.y1.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.zu(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.dg.item(t); t++; z.height = l; z.width = y; let aa = this.y1.aw(r, u)[0]; if (n) { this.aaf(c, u, r, h, i, b.q, aa); } if (z.dataContext != null) { let ab = z.dataContext; if (s == 1) { if (aa >= 0 && aa < this.dn.count) { if (q != null && q.i$b != null && q.i$b.count > aa) { aa = q.i$b._inner[aa]; } ab.item = this.dn.item(aa); } } else { ab.item = null; } } this.y1.ad(z, false, false, false, false); z.ap = this.y1.k; z.aq = this.y1.l; m.dl(z, Math.min(w, x), v); } m.dg.count = t; b.c3(a); } pa(a, b, c, d) { switch (a) { case 4: case 1: case 0: this.aau.cw.g(this.ic); break; } if (this.aau.c8) { this.aau.c7.g$e(a, b, c, d); } switch (a) { case 4: if (this.xAxis != null && !this.xAxis.c1()) { this.rq(true); } break; case 1: if (this.xAxis != null && !this.xAxis.c1()) { this.rq(true); } break; case 0: if (this.xAxis != null && !this.xAxis.c1()) { this.rq(true); } break; case 2: if (this.abm != null && this.aau.cw.d > 0) { this.rq(true); } break; case 3: if (d == this.abm) { if (this.xAxis != null && !this.xAxis.c1()) { this.rq(true); } } break; } } q8(a, b, c, d) { super.q8(a, b, c, d); switch (b) { case VerticalAnchoredCategorySeries.$$p[0]: if (c != null) { c.b0(this); } if (d != null) { d.ct(this); } this.aau.cw.g(this.ic); if (this.xAxis != null && this.xAxis.c1()) { this.rq(false); } break; case VerticalAnchoredCategorySeries.$$p[1]: if (c != null) { c.b0(this); } if (d != null) { d.ct(this); } if (this.aau.c8) { this.aau.c7 = CategoryTrendLineManagerFactory.a(this.aau.c7, this.yAxis, this.su, this, this.dr); } this.aau.cw.g(this.ic); this.rq(false); break; case "FastItemsSource": if (this.xAxis != null && !this.xAxis.c1()) { this.aau.cw.g(this.ic); this.rq(this.gf && c != null); } break; case "ValueColumn": if (this.xAxis != null && !this.xAxis.c1()) { this.aau.cw.g(this.ic); this.rq(this.gf && this.d7); } break; case "SeriesViewer": if (c != null && d == null) { this.pb(this.xAxis); this.pb(this.yAxis); } if (c == null && d != null) { this.rg(this.xAxis); this.rg(this.yAxis); } this.aau.cw.g(this.ic); this.rq(false); break; } } getPreferredCategoryMode() { return this.preferredCategoryMode(this.yAxis); } get useHighMarkerFidelity() { return this.zp; } } BarSeries.$t = markType(BarSeries, 'BarSeries', VerticalAnchoredCategorySeries.$, [IBarSeries_$type]); BarSeries.$$p = markDep(DependencyProperty, PropertyMetadata, BarSeries, 'raisePropertyChanged', ['RadiusX:aco:acs', [1, 0], 'RadiusY:acp:act', [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.by; let c = this.c.bx; let d = this.c.cy.dn; if (b.isEmpty || c.isEmpty || this.i.df.yAxis == null || d == null || d.count == 0) { this.d = 0; return; } let e = typeCast(BarSeries.$, this.c.cy); let f = e.wi(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.df.valueColumn.count; this.h = this.i.df.valueColumn.asArray(); } unCacheValues() { this.h = null; } } BarBucketCalculator.$t = markType(BarBucketCalculator, 'BarBucketCalculator', CategoryBucketCalculator.$); return BarBucketCalculator; })(); /** * @hidden */ export let BarSeriesView = /*@__PURE__*/ (() => { class BarSeriesView extends AnchoredCategorySeriesView { constructor(a) { super(a); this.df = null; this.dg = null; this.dh = null; this.dm = new Rectangle(); this.df = a; this.dg = ((() => { let $ret = new Pool$1(Rectangle.$); $ret.create = runOn(this, this.dn); $ret.activate = runOn(this, this.di); $ret.disactivate = runOn(this, this.dk); $ret.destroy = runOn(this, this.dj); return $ret; })()); this.c7 = new BarTrendLineManager(); } au() { super.au(); this.dh = new List$1(Rectangle.$, 0); if (!this.q) { this.df.w9 = Defaults.c; this.df.jo = Defaults.i; } } dn() { let a = new Rectangle(); this.dh.add(a); a._visibility = 1; return a; } di(a) { a._visibility = 0; } dk(a) { a._visibility = 1; } dj(a) { this.dh.remove(a); } dl(a, b, c) { if (!this.isDirty) { this.as(); } a.o = c; a.n = b; } cx() { return new BarBucketCalculator(this); } bh(a, b) { super.bh(a, b); let c = a; let d = this.bs(b); c._fill = d; c._stroke = d; c.ad = this.e.id; } ac(a) { return this.dh._inner[a]; } ab(a) { let b = this.dh._inner[a]; this.dm.n = b.n; this.dm.o = b.o; this.dm.width = b.width; this.dm.height = b.height; let c = this.bs(a); this.dm._fill = c; this.dm._stroke = c; this.dm.ad = this.e.id + 3; return this.dm; } a8(a, b) { super.a8(a, b); if (a.d) { for (let c = 0; c < this.dh.count; c++) { let d = this.aa(c, b); this.bf(d, c, b); a.w(d); } } } an(a) { super.an(a); let b = 0; let c = new List$1(Rectangle.$, 0); for (let d of fromEnum(this.dg.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.e.bc.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]); } b++; } af() { let a = new Color(); a.colorString = "rgba(95,95,95,0.5)"; this.e.v0 = a; this.e.jl = 5; this.e.jm = 5; this.e.jn = -5; } } BarSeriesView.$t = markType(BarSeriesView, 'BarSeriesView', AnchoredCategorySeriesView.$); return BarSeriesView; })();