UNPKG

igniteui-react-charts

Version:

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

406 lines (405 loc) 14.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 { FinancialOverlay } from "./FinancialOverlay"; import { DependencyProperty } from "igniteui-react-core"; import { Series } from "./Series"; import { List$1 } from "igniteui-react-core"; import { Number_$type, typeCast, runOn, markType, markDep, getEnumerator, Point_$type, fromEnum } from "igniteui-react-core"; import { CategoryFrame } from "./CategoryFrame"; import { SafeEnumerable } from "./SafeEnumerable"; import { TrendCalculators } from "igniteui-react-core"; import { AxisRange } from "./AxisRange"; import { FinancialSeriesView } from "./FinancialSeriesView"; import { ScalerParams } from "./ScalerParams"; import { ISortingAxis_$type } from "./ISortingAxis"; import { FinancialBucketCalculator } from "./FinancialBucketCalculator"; import { Polyline } from "igniteui-react-core"; import { Polygon } from "igniteui-react-core"; import { PropertyMetadata } from "igniteui-react-core"; import { isNaN_ } from "igniteui-react-core"; import { Flattener } from "igniteui-react-core"; /** * @hidden */ export let BollingerBandsOverlay = /*@__PURE__*/ (() => { class BollingerBandsOverlay extends FinancialOverlay { bk() { return new BollingerBandsOverlay(); } constructor() { super(); this.abu = 0; this.abv = 0; this.abs = new List$1(Number_$type, 0); this.abt = new List$1(Number_$type, 0); this.ab = BollingerBandsOverlay.$; this.xw = new CategoryFrame(4); this.xy = new CategoryFrame(4); this.xu = new CategoryFrame(4); } rr(a, b, c, d) { if (this.zb().contains(b)) { this.abm = false; } super.rr(a, b, c, d); switch (b) { case BollingerBandsOverlay.$$p[1]: this.abm = false; this.r9(false); break; case BollingerBandsOverlay.$$p[0]: this.r9(false); break; } } abn() { this.abs.clear(); this.abt.clear(); let a = getEnumerator(TrendCalculators.e(new SafeEnumerable(this.za), this.abx)); let b = getEnumerator(TrendCalculators.f(new SafeEnumerable(this.za), this.abx)); this.abv = 1.7976931348623157E+308; this.abu = -1.7976931348623157E+308; let c = true; let d = true; let e = this.abw; while (c || d) { if (a.moveNext()) { this.abs.add(a.current); } else { c = false; } if (b.moveNext()) { this.abt.add(b.current); } else { d = false; } if (c && d) { this.abv = Math.min(this.abv, a.current - b.current * e); this.abu = Math.max(this.abu, a.current + b.current * e); } } return true; } ay(a) { if (this.abs == null || this.abt == null || a == null || this.dp == null || a != this.yb) { return null; } let b = new AxisRange(this.abv, this.abu); return b; } aay(a, b) { super.aay(a, b); let c = b.ca; let d = b.b9; let e = this.getEffectiveViewport1(b); let f = this.xs; let g = this.yb; let h = new ScalerParams(0, c, d, f.dn, e); let i = new ScalerParams(0, c, d, g.dn, e); a.k.clear(); a.s.clear(); a.v.clear(); let j = typeCast(ISortingAxis_$type, this.xs); if (j != null && j.i$b.count != this.dp.count) { return; } let k = 0; k = this.zj(c, d, e); if (!this.abm) { this.abm = this.abn(); if (this.yb != null) { this.yb.ef(true); } } i.b = this.i6(); let l = this.xs.ga(2, h) - this.xs.ga(1, h); for (let m = b.cd.c; m <= b.cd.d; ++m) { let n; if (j == null) { n = b.cd.getBucket(m); } else { let o = j.i$b._inner[m]; let p = j.i$d(o); let q = this.abs._inner[m]; let r = this.abt._inner[m]; let s = q; let t = r; let u = p; let v = 1; while (m < b.cd.d) { o = j.i$b._inner[m + 1]; u = j.i$d(o); if (u - p > l) { break; } m++; s += this.abs._inner[m]; t += this.abt._inner[m]; v++; } s /= v; t /= v; let w = s - t * this.abw; let x = s; let y = s + t * this.abw; let z = NaN; if (!isNaN_(p)) { z = this.xs.f7(p, h); } n = [z, w, x, y]; } let aa = Math.max(1, l); if (!isNaN_(n[0]) && m * aa >= this.abo) { if (this.xs != null && typeCast(ISortingAxis_$type, this.xs) !== null) { n[0] = n[0] + k; } else { n[0] = f.f7(n[0], h) + k; } n[1] = g.f7(n[1], i); n[2] = g.f7(n[2], i); n[3] = g.f7(n[3], i); a.k.add(n); } } } pj(a, b) { super.pj(a, b); let c = b; if (c != null) { c.ck(); } } je(a, b, c) { if (this.abs == null) { return super.je(a, b, c); } let d = this.getEffectiveViewport1(this.cw); let e = this.zj(this.cw.ca, this.cw.b9, d); let f = new ScalerParams(0, this.cw.ca, this.cw.b9, this.xs.dn, d); f.c = this.dc.za; return this.jg(this.abs, a, this.xs, f, e, runOn(this, this.zi), b, c); } kk(a, b) { if (this.abs == null) { return super.kk(a, b); } return this.kl(a, b, this.xs, runOn(this, this.zi), this.abs); } ki(a, b) { if (this.abs == null) { return super.ki(a, b); } return this.kj(a, b, this.xs, runOn(this, this.zi), this.abs); } hl(a, b, c) { let d = super.hl(a, b, c); if (!this.y1(this.zb())) { d = false; } return d; } aa0(a, b) { super.aa0(a, b); let c = typeCast(BollingerBandsOverlayView.$, b); let d = this.getEffectiveViewport1(b); if (b.cg(a)) { c.ck(); let e = a.k.count; let f = (g) => a.k._inner[g][0]; let g = (h) => a.k._inner[e - 1 - h][0]; let h = (i) => a.k._inner[i][1]; let i = (j) => a.k._inner[j][2]; let j = (k) => a.k._inner[e - 1 - k][3]; c.cl(e, f, g, h, i, j); b.ci(a); } this.x1.a2(this, this.y0(), runOn(this, this.xk), this.zp(b), this.zr(b)); let k = false; let l = this.x1.b; let m = a.k; let n = this.dp.count; if (l != null) { k = true; } if (k) { let o = new ScalerParams(0, b.ca, b.b9, this.xs.dn, d); this.aax(m, -1, n, this.xs, o, b.t, -1); } let p = c.cs; let q = c.ct; let r = c.cu; let s = c.cn; this.x1.ad(q, true, false, true, true); this.x1.an = null; this.x1.am = null; this.x1.ad(p, true, false, false, true); this.x1.ad(r, true, false, false, true); this.x1.ad(s, false, true, false, false); s._opacity = this.x1.j * this.ih; } ct() { return new BollingerBandsOverlayView(this); } ri(a) { super.ri(a); this.abr = typeCast(BollingerBandsOverlayView.$, a); } zs() { return 3; } i6() { return Series.i8(this.abs, null); } } BollingerBandsOverlay.$t = /*@__PURE__*/ markType(BollingerBandsOverlay, 'BollingerBandsOverlay', FinancialOverlay.$); BollingerBandsOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, BollingerBandsOverlay, 'raisePropertyChanged', ['Multiplier:abw:ab0', [1, 2], 'Period:abx:ab1', [1, 14]]); return BollingerBandsOverlay; })(); /** * @hidden */ export let BollingerBandsBucketCalculator = /*@__PURE__*/ (() => { class BollingerBandsBucketCalculator extends FinancialBucketCalculator { constructor(a) { super(a); this.f = null; this.f = a; } getBucket(a) { let b = a * this.b; let c = Math.min(b + this.b - 1, this.a.cf.dp.count - 1); if (b <= c) { let d = this.f.cj.abw; let e = 0; let f = 0; let g = 0; for (let h = b; h <= c; ++h) { if (!isNaN_(this.f.cj.abs._inner[h]) && !isNaN_(this.f.cj.abt._inner[h])) { e += this.f.cj.abs._inner[h]; f += this.f.cj.abt._inner[h]; ++g; } } if (g > 0) { e = e / g; f = f / g; return [0.5 * (b + c), e - f * d, e, e + f * d]; } } return [NaN, NaN, NaN, NaN]; } } BollingerBandsBucketCalculator.$t = /*@__PURE__*/ markType(BollingerBandsBucketCalculator, 'BollingerBandsBucketCalculator', FinancialBucketCalculator.$); return BollingerBandsBucketCalculator; })(); /** * @hidden */ export let BollingerBandsOverlayView = /*@__PURE__*/ (() => { class BollingerBandsOverlayView extends FinancialSeriesView { constructor(a) { super(a); this.cj = null; this.co = new Polygon(); this.cv = new Polyline(); this.cw = new Polyline(); this.cx = new Polyline(); this.cm = new Polygon(); this.cp = new Polyline(); this.cq = new Polyline(); this.cr = new Polyline(); this.cj = a; } a4() { super.a4(); if (!this.t) { } } ce() { return new BollingerBandsBucketCalculator(this); } cl(a, b, c, d, e, f) { for (let g of fromEnum(Flattener.d(a, b, d, this.f.il))) { this.co.an.add({ $type: Point_$type, x: b(g), y: d(g) }); this.cv.an.add({ $type: Point_$type, x: b(g), y: d(g) }); } for (let h of fromEnum(Flattener.d(a, b, e, this.f.il))) { this.cw.an.add({ $type: Point_$type, x: b(h), y: e(h) }); } for (let i of fromEnum(Flattener.d(a, c, f, this.f.il))) { this.co.an.add({ $type: Point_$type, x: c(i), y: f(i) }); this.cx.an.add({ $type: Point_$type, x: c(i), y: f(i) }); } this.a2(); } ck() { this.co.an.clear(); this.cv.an.clear(); this.cw.an.clear(); this.cx.an.clear(); this.a2(); } get cn() { return this.co; } get cs() { return this.cv; } get ct() { return this.cw; } get cu() { return this.cx; } bq() { super.bq(); this.cm.an = this.co.an; this.cp.an = this.cv.an; this.cq.an = this.cw.an; this.cr.an = this.cx.an; let a = this.b3(); this.cm._fill = a; this.cm._opacity = 1; this.cp._stroke = a; this.cp.ad = this.f.im + 3; this.cq._stroke = a; this.cq.ad = this.f.im + 3; this.cr._stroke = a; this.cr.ad = this.f.im + 3; } bj(a, b) { super.bj(a, b); if (a.d) { if (b) { a.u(this.cm); a.v(this.cp); a.v(this.cq); a.v(this.cr); } else { a.u(this.co); a.v(this.cv); a.v(this.cw); a.v(this.cx); } } } ax(a) { super.ax(a); this.f.bc.exportPolygonData(a, this.co, "FillShape", ["Fill"]); this.f.bc.exportPolylineData(a, this.cv, "BottomLine", ["Lower", "Main"]); this.f.bc.exportPolylineData(a, this.cw, "CentralLine", ["Central"]); this.f.bc.exportPolylineData(a, this.cx, "TopLine", ["Upper"]); } } BollingerBandsOverlayView.$t = /*@__PURE__*/ markType(BollingerBandsOverlayView, 'BollingerBandsOverlayView', FinancialSeriesView.$); return BollingerBandsOverlayView; })();