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.abv = 0; this.abw = 0; this.abt = new List$1(Number_$type, 0); this.abu = new List$1(Number_$type, 0); this.ab = BollingerBandsOverlay.$; this.xx = new CategoryFrame(4); this.xz = new CategoryFrame(4); this.xv = new CategoryFrame(4); } rs(a, b, c, d) { if (this.zc().contains(b)) { this.abn = false; } super.rs(a, b, c, d); switch (b) { case BollingerBandsOverlay.$$p[1]: this.abn = false; this.sa(false); break; case BollingerBandsOverlay.$$p[0]: this.sa(false); break; } } abo() { this.abt.clear(); this.abu.clear(); let a = getEnumerator(TrendCalculators.e(new SafeEnumerable(this.zb), this.aby)); let b = getEnumerator(TrendCalculators.f(new SafeEnumerable(this.zb), this.aby)); this.abw = 1.7976931348623157E+308; this.abv = -1.7976931348623157E+308; let c = true; let d = true; let e = this.abx; while (c || d) { if (a.moveNext()) { this.abt.add(a.current); } else { c = false; } if (b.moveNext()) { this.abu.add(b.current); } else { d = false; } if (c && d) { this.abw = Math.min(this.abw, a.current - b.current * e); this.abv = Math.max(this.abv, a.current + b.current * e); } } return true; } ay(a) { if (this.abt == null || this.abu == null || a == null || this.dp == null || a != this.yc) { return null; } let b = new AxisRange(this.abw, this.abv); return b; } aaz(a, b) { super.aaz(a, b); let c = b.ca; let d = b.b9; let e = this.getEffectiveViewport1(b); let f = this.xt; let g = this.yc; 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.xt); if (j != null && j.i$b.count != this.dp.count) { return; } let k = 0; k = this.zk(c, d, e); if (!this.abn) { this.abn = this.abo(); if (this.yc != null) { this.yc.ef(true); } } i.b = this.i7(); let l = this.xt.ga(2, h) - this.xt.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.abt._inner[m]; let r = this.abu._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.abt._inner[m]; t += this.abu._inner[m]; v++; } s /= v; t /= v; let w = s - t * this.abx; let x = s; let y = s + t * this.abx; let z = NaN; if (!isNaN_(p)) { z = this.xt.f7(p, h); } n = [z, w, x, y]; } let aa = Math.max(1, l); if (!isNaN_(n[0]) && m * aa >= this.abp) { if (this.xt != null && typeCast(ISortingAxis_$type, this.xt) !== 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); } } } pk(a, b) { super.pk(a, b); let c = b; if (c != null) { c.ck(); } } jf(a, b, c) { if (this.abt == null) { return super.jf(a, b, c); } let d = this.getEffectiveViewport1(this.cw); let e = this.zk(this.cw.ca, this.cw.b9, d); let f = new ScalerParams(0, this.cw.ca, this.cw.b9, this.xt.dn, d); f.c = this.dc.zd; return this.jh(this.abt, a, this.xt, f, e, runOn(this, this.zj), b, c); } kl(a, b) { if (this.abt == null) { return super.kl(a, b); } return this.km(a, b, this.xt, runOn(this, this.zj), this.abt); } kj(a, b) { if (this.abt == null) { return super.kj(a, b); } return this.kk(a, b, this.xt, runOn(this, this.zj), this.abt); } hm(a, b, c) { let d = super.hm(a, b, c); if (!this.y2(this.zc())) { d = false; } return d; } aa1(a, b) { super.aa1(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.x2.a2(this, this.y1(), runOn(this, this.xl), this.zq(b), this.zs(b)); let k = false; let l = this.x2.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.xt.dn, d); this.aay(m, -1, n, this.xt, o, b.t, -1); } let p = c.cs; let q = c.ct; let r = c.cu; let s = c.cn; this.x2.ad(q, true, false, true, true); this.x2.an = null; this.x2.am = null; this.x2.ad(p, true, false, false, true); this.x2.ad(r, true, false, false, true); this.x2.ad(s, false, true, false, false); s._opacity = this.x2.j * this.ii; } ct() { return new BollingerBandsOverlayView(this); } rj(a) { super.rj(a); this.abs = typeCast(BollingerBandsOverlayView.$, a); } zt() { return 3; } i7() { return Series.i9(this.abt, null); } } BollingerBandsOverlay.$t = /*@__PURE__*/ markType(BollingerBandsOverlay, 'BollingerBandsOverlay', FinancialOverlay.$); BollingerBandsOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, BollingerBandsOverlay, 'raisePropertyChanged', ['Multiplier:abx:ab1', [1, 2], 'Period:aby:ab2', [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.abx; let e = 0; let f = 0; let g = 0; for (let h = b; h <= c; ++h) { if (!isNaN_(this.f.cj.abt._inner[h]) && !isNaN_(this.f.cj.abu._inner[h])) { e += this.f.cj.abt._inner[h]; f += this.f.cj.abu._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.im))) { 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.im))) { 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.im))) { 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.io + 3; this.cq._stroke = a; this.cq.ad = this.f.io + 3; this.cr._stroke = a; this.cr.ad = this.f.io + 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; })();