UNPKG

igniteui-react-charts

Version:

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

475 lines (474 loc) 17 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 { __extends, __values } from "tslib"; 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 */ var BollingerBandsOverlay = /** @class */ /*@__PURE__*/ (function (_super) { __extends(BollingerBandsOverlay, _super); function BollingerBandsOverlay() { var _this = _super.call(this) || this; _this.abj = 0; _this.abk = 0; _this.abh = new List$1(Number_$type, 0); _this.abi = new List$1(Number_$type, 0); _this.ab = BollingerBandsOverlay.$; _this.xl = new CategoryFrame(4); _this.xn = new CategoryFrame(4); _this.xj = new CategoryFrame(4); return _this; } BollingerBandsOverlay.prototype.bk = function () { return new BollingerBandsOverlay(); }; BollingerBandsOverlay.prototype.rh = function (a, b, c, d) { if (this.y0().contains(b)) { this.abb = false; } _super.prototype.rh.call(this, a, b, c, d); switch (b) { case BollingerBandsOverlay.$$p[1]: this.abb = false; this.rz(false); break; case BollingerBandsOverlay.$$p[0]: this.rz(false); break; } }; BollingerBandsOverlay.prototype.abc = function () { this.abh.clear(); this.abi.clear(); var a = getEnumerator(TrendCalculators.e(new SafeEnumerable(this.yz), this.abm)); var b = getEnumerator(TrendCalculators.f(new SafeEnumerable(this.yz), this.abm)); this.abk = 1.7976931348623157E+308; this.abj = -1.7976931348623157E+308; var c = true; var d = true; var e = this.abl; while (c || d) { if (a.moveNext()) { this.abh.add(a.current); } else { c = false; } if (b.moveNext()) { this.abi.add(b.current); } else { d = false; } if (c && d) { this.abk = Math.min(this.abk, a.current - b.current * e); this.abj = Math.max(this.abj, a.current + b.current * e); } } return true; }; BollingerBandsOverlay.prototype.ay = function (a) { if (this.abh == null || this.abi == null || a == null || this.dp == null || a != this.x0) { return null; } var b = new AxisRange(this.abk, this.abj); return b; }; BollingerBandsOverlay.prototype.aan = function (a, b) { _super.prototype.aan.call(this, a, b); var c = b.ca; var d = b.b9; var e = this.getEffectiveViewport1(b); var f = this.xh; var g = this.x0; var h = new ScalerParams(0, c, d, f.df, e); var i = new ScalerParams(0, c, d, g.df, e); a.h.clear(); a.p.clear(); a.s.clear(); var j = typeCast(ISortingAxis_$type, this.xh); if (j != null && j.i$b.count != this.dp.count) { return; } var k = 0; k = this.y8(c, d, e); if (!this.abb) { this.abb = this.abc(); if (this.x0 != null) { this.x0.d3(true); } } i.b = this.i0(); var l = this.xh.fw(2, h) - this.xh.fw(1, h); for (var m = b.cd.c; m <= b.cd.d; ++m) { var n = void 0; if (j == null) { n = b.cd.getBucket(m); } else { var o = j.i$b._inner[m]; var p = j.i$d(o); var q = this.abh._inner[m]; var r = this.abi._inner[m]; var s = q; var t = r; var u = p; var 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.abh._inner[m]; t += this.abi._inner[m]; v++; } s /= v; t /= v; var w = s - t * this.abl; var x = s; var y = s + t * this.abl; var z = NaN; if (!isNaN_(p)) { z = this.xh.ft(p, h); } n = [z, w, x, y]; } var aa = Math.max(1, l); if (!isNaN_(n[0]) && m * aa >= this.abd) { if (this.xh != null && typeCast(ISortingAxis_$type, this.xh) !== null) { n[0] = n[0] + k; } else { n[0] = f.ft(n[0], h) + k; } n[1] = g.ft(n[1], i); n[2] = g.ft(n[2], i); n[3] = g.ft(n[3], i); a.h.add(n); } } }; BollingerBandsOverlay.prototype.pb = function (a, b) { _super.prototype.pb.call(this, a, b); var c = b; if (c != null) { c.ck(); } }; BollingerBandsOverlay.prototype.i8 = function (a, b, c) { if (this.abh == null) { return _super.prototype.i8.call(this, a, b, c); } var d = this.getEffectiveViewport1(this.cw); var e = this.y8(this.cw.ca, this.cw.b9, d); var f = new ScalerParams(0, this.cw.ca, this.cw.b9, this.xh.df, d); f.c = this.dc.x5; return this.ja(this.abh, a, this.xh, f, e, runOn(this, this.y7), b, c); }; BollingerBandsOverlay.prototype.ke = function (a, b) { if (this.abh == null) { return _super.prototype.ke.call(this, a, b); } return this.kf(a, b, this.xh, runOn(this, this.y7), this.abh); }; BollingerBandsOverlay.prototype.kc = function (a, b) { if (this.abh == null) { return _super.prototype.kc.call(this, a, b); } return this.kd(a, b, this.xh, runOn(this, this.y7), this.abh); }; BollingerBandsOverlay.prototype.hf = function (a, b, c) { var d = _super.prototype.hf.call(this, a, b, c); if (!this.yq(this.y0())) { d = false; } return d; }; BollingerBandsOverlay.prototype.aap = function (a, b) { _super.prototype.aap.call(this, a, b); var c = typeCast(BollingerBandsOverlayView.$, b); var d = this.getEffectiveViewport1(b); if (b.cg(a)) { c.ck(); var e_1 = a.h.count; var f = function (g) { return a.h._inner[g][0]; }; var g = function (h) { return a.h._inner[e_1 - 1 - h][0]; }; var h = function (i) { return a.h._inner[i][1]; }; var i = function (j) { return a.h._inner[j][2]; }; var j = function (k) { return a.h._inner[e_1 - 1 - k][3]; }; c.cl(e_1, f, g, h, i, j); b.ci(a); } this.xq.a2(this, this.yp(), runOn(this, this.w9), this.ze(b), this.zg(b)); var k = false; var l = this.xq.b; var m = a.h; var n = this.dp.count; if (l != null) { k = true; } if (k) { var o = new ScalerParams(0, b.ca, b.b9, this.xh.df, d); this.aam(m, -1, n, this.xh, o, b.t, -1); } var p = c.cs; var q = c.ct; var r = c.cu; var s = c.cn; this.xq.ad(q, true, false, true, true); this.xq.an = null; this.xq.am = null; this.xq.ad(p, true, false, false, true); this.xq.ad(r, true, false, false, true); this.xq.ad(s, false, true, false, false); s._opacity = this.xq.j * this.ia; }; BollingerBandsOverlay.prototype.ct = function () { return new BollingerBandsOverlayView(this); }; BollingerBandsOverlay.prototype.q8 = function (a) { _super.prototype.q8.call(this, a); this.abg = typeCast(BollingerBandsOverlayView.$, a); }; BollingerBandsOverlay.prototype.zh = function () { return 3; }; BollingerBandsOverlay.prototype.i0 = function () { return Series.i2(this.abh, null); }; BollingerBandsOverlay.$t = markType(BollingerBandsOverlay, 'BollingerBandsOverlay', FinancialOverlay.$); BollingerBandsOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, BollingerBandsOverlay, 'raisePropertyChanged', ['Multiplier:abl:abp', [1, 2], 'Period:abm:abq', [1, 14]]); return BollingerBandsOverlay; }(FinancialOverlay)); export { BollingerBandsOverlay }; /** * @hidden */ var BollingerBandsBucketCalculator = /** @class */ /*@__PURE__*/ (function (_super) { __extends(BollingerBandsBucketCalculator, _super); function BollingerBandsBucketCalculator(a) { var _this = _super.call(this, a) || this; _this.f = null; _this.f = a; return _this; } BollingerBandsBucketCalculator.prototype.getBucket = function (a) { var b = a * this.b; var c = Math.min(b + this.b - 1, this.a.cf.dp.count - 1); if (b <= c) { var d = this.f.cj.abl; var e = 0; var f = 0; var g = 0; for (var h = b; h <= c; ++h) { if (!isNaN_(this.f.cj.abh._inner[h]) && !isNaN_(this.f.cj.abi._inner[h])) { e += this.f.cj.abh._inner[h]; f += this.f.cj.abi._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 = markType(BollingerBandsBucketCalculator, 'BollingerBandsBucketCalculator', FinancialBucketCalculator.$); return BollingerBandsBucketCalculator; }(FinancialBucketCalculator)); export { BollingerBandsBucketCalculator }; /** * @hidden */ var BollingerBandsOverlayView = /** @class */ /*@__PURE__*/ (function (_super) { __extends(BollingerBandsOverlayView, _super); function BollingerBandsOverlayView(a) { var _this = _super.call(this, a) || this; _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; return _this; } BollingerBandsOverlayView.prototype.a4 = function () { _super.prototype.a4.call(this); if (!this.t) { } }; BollingerBandsOverlayView.prototype.ce = function () { return new BollingerBandsBucketCalculator(this); }; BollingerBandsOverlayView.prototype.cl = function (a, b, c, d, e, f) { var e_2, _a, e_3, _b, e_4, _c; try { for (var _d = __values(fromEnum(Flattener.d(a, b, d, this.f.ie))), _e = _d.next(); !_e.done; _e = _d.next()) { var g = _e.value; 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) }); } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_e && !_e.done && (_a = _d.return)) _a.call(_d); } finally { if (e_2) throw e_2.error; } } try { for (var _f = __values(fromEnum(Flattener.d(a, b, e, this.f.ie))), _g = _f.next(); !_g.done; _g = _f.next()) { var h = _g.value; this.cw.an.add({ $type: Point_$type, x: b(h), y: e(h) }); } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_g && !_g.done && (_b = _f.return)) _b.call(_f); } finally { if (e_3) throw e_3.error; } } try { for (var _h = __values(fromEnum(Flattener.d(a, c, f, this.f.ie))), _j = _h.next(); !_j.done; _j = _h.next()) { var i = _j.value; 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) }); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_j && !_j.done && (_c = _h.return)) _c.call(_h); } finally { if (e_4) throw e_4.error; } } this.a2(); }; BollingerBandsOverlayView.prototype.ck = function () { this.co.an.clear(); this.cv.an.clear(); this.cw.an.clear(); this.cx.an.clear(); this.a2(); }; Object.defineProperty(BollingerBandsOverlayView.prototype, "cn", { get: function () { return this.co; }, enumerable: false, configurable: true }); Object.defineProperty(BollingerBandsOverlayView.prototype, "cs", { get: function () { return this.cv; }, enumerable: false, configurable: true }); Object.defineProperty(BollingerBandsOverlayView.prototype, "ct", { get: function () { return this.cw; }, enumerable: false, configurable: true }); Object.defineProperty(BollingerBandsOverlayView.prototype, "cu", { get: function () { return this.cx; }, enumerable: false, configurable: true }); BollingerBandsOverlayView.prototype.bq = function () { _super.prototype.bq.call(this); this.cm.an = this.co.an; this.cp.an = this.cv.an; this.cq.an = this.cw.an; this.cr.an = this.cx.an; var a = this.b3(); this.cm._fill = a; this.cm._opacity = 1; this.cp._stroke = a; this.cp.ad = this.f.ig + 3; this.cq._stroke = a; this.cq.ad = this.f.ig + 3; this.cr._stroke = a; this.cr.ad = this.f.ig + 3; }; BollingerBandsOverlayView.prototype.bj = function (a, b) { _super.prototype.bj.call(this, 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); } } }; BollingerBandsOverlayView.prototype.ax = function (a) { _super.prototype.ax.call(this, 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 = markType(BollingerBandsOverlayView, 'BollingerBandsOverlayView', FinancialSeriesView.$); return BollingerBandsOverlayView; }(FinancialSeriesView)); export { BollingerBandsOverlayView };