igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
475 lines (474 loc) • 17 kB
JavaScript
/*
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.aba = 0;
_this.abb = 0;
_this.aa8 = new List$1(Number_$type, 0);
_this.aa9 = new List$1(Number_$type, 0);
_this.ab = BollingerBandsOverlay.$;
_this.xc = new CategoryFrame(4);
_this.xe = new CategoryFrame(4);
_this.xa = new CategoryFrame(4);
return _this;
}
BollingerBandsOverlay.prototype.bk = function () {
return new BollingerBandsOverlay();
};
BollingerBandsOverlay.prototype.ra = function (a, b, c, d) {
if (this.yr().contains(b)) {
this.aa2 = false;
}
_super.prototype.ra.call(this, a, b, c, d);
switch (b) {
case BollingerBandsOverlay.$$p[1]:
this.aa2 = false;
this.rs(false);
break;
case BollingerBandsOverlay.$$p[0]:
this.rs(false);
break;
}
};
BollingerBandsOverlay.prototype.aa3 = function () {
this.aa8.clear();
this.aa9.clear();
var a = getEnumerator(TrendCalculators.e(new SafeEnumerable(this.yq), this.abd));
var b = getEnumerator(TrendCalculators.f(new SafeEnumerable(this.yq), this.abd));
this.abb = 1.7976931348623157E+308;
this.aba = -1.7976931348623157E+308;
var c = true;
var d = true;
var e = this.abc;
while (c || d) {
if (a.moveNext()) {
this.aa8.add(a.current);
}
else {
c = false;
}
if (b.moveNext()) {
this.aa9.add(b.current);
}
else {
d = false;
}
if (c && d) {
this.abb = Math.min(this.abb, a.current - b.current * e);
this.aba = Math.max(this.aba, a.current + b.current * e);
}
}
return true;
};
BollingerBandsOverlay.prototype.ay = function (a) {
if (this.aa8 == null || this.aa9 == null || a == null || this.dp == null || a != this.xr) {
return null;
}
var b = new AxisRange(this.abb, this.aba);
return b;
};
BollingerBandsOverlay.prototype.aae = function (a, b) {
_super.prototype.aae.call(this, a, b);
var c = b.b2;
var d = b.b1;
var e = this.getEffectiveViewport1(b);
var f = this.w8;
var g = this.xr;
var h = new ScalerParams(0, c, d, f.ch, e);
var i = new ScalerParams(0, c, d, g.ch, e);
a.h.clear();
a.p.clear();
a.s.clear();
var j = typeCast(ISortingAxis_$type, this.w8);
if (j != null && j.i$b.count != this.dp.count) {
return;
}
var k = 0;
k = this.yz(c, d, e);
if (!this.aa2) {
this.aa2 = this.aa3();
if (this.xr != null) {
this.xr.c2(true);
}
}
i.b = this.iy();
var l = this.w8.eo(2, h) - this.w8.eo(1, h);
for (var m = b.b4.c; m <= b.b4.d; ++m) {
var n = void 0;
if (j == null) {
n = b.b4.getBucket(m);
}
else {
var o = j.i$b._inner[m];
var p = j.i$d(o);
var q = this.aa8._inner[m];
var r = this.aa9._inner[m];
var s = q;
var t = r;
var u = p;
var v = 1;
while (m < b.b4.d) {
o = j.i$b._inner[m + 1];
u = j.i$d(o);
if (u - p > l) {
break;
}
m++;
s += this.aa8._inner[m];
t += this.aa9._inner[m];
v++;
}
s /= v;
t /= v;
var w = s - t * this.abc;
var x = s;
var y = s + t * this.abc;
var z = NaN;
if (!isNaN_(p)) {
z = this.w8.el(p, h);
}
n = [z, w, x, y];
}
var aa = Math.max(1, l);
if (!isNaN_(n[0]) && m * aa >= this.aa4) {
if (this.w8 != null && typeCast(ISortingAxis_$type, this.w8) !== null) {
n[0] = n[0] + k;
}
else {
n[0] = f.el(n[0], h) + k;
}
n[1] = g.el(n[1], i);
n[2] = g.el(n[2], i);
n[3] = g.el(n[3], i);
a.h.add(n);
}
}
};
BollingerBandsOverlay.prototype.o5 = function (a, b) {
_super.prototype.o5.call(this, a, b);
var c = b;
if (c != null) {
c.cb();
}
};
BollingerBandsOverlay.prototype.i5 = function (a, b, c) {
if (this.aa8 == null) {
return _super.prototype.i5.call(this, a, b, c);
}
var d = this.getEffectiveViewport1(this.cw);
var e = this.yz(this.cw.b2, this.cw.b1, d);
var f = new ScalerParams(0, this.cw.b2, this.cw.b1, this.w8.ch, d);
f.c = this.dc.wn;
return this.i7(this.aa8, a, this.w8, f, e, runOn(this, this.yy), b, c);
};
BollingerBandsOverlay.prototype.ka = function (a, b) {
if (this.aa8 == null) {
return _super.prototype.ka.call(this, a, b);
}
return this.kb(a, b, this.w8, runOn(this, this.yy), this.aa8);
};
BollingerBandsOverlay.prototype.j8 = function (a, b) {
if (this.aa8 == null) {
return _super.prototype.j8.call(this, a, b);
}
return this.j9(a, b, this.w8, runOn(this, this.yy), this.aa8);
};
BollingerBandsOverlay.prototype.he = function (a, b, c) {
var d = _super.prototype.he.call(this, a, b, c);
if (!this.yh(this.yr())) {
d = false;
}
return d;
};
BollingerBandsOverlay.prototype.aag = function (a, b) {
_super.prototype.aag.call(this, a, b);
var c = typeCast(BollingerBandsOverlayView.$, b);
var d = this.getEffectiveViewport1(b);
if (b.b7(a)) {
c.cb();
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.cc(e_1, f, g, h, i, j);
b.b9(a);
}
this.xh.a2(this, this.yg(), runOn(this, this.w0), this.y5(b), this.y7(b));
var k = false;
var l = this.xh.b;
var m = a.h;
var n = this.dp.count;
if (l != null) {
k = true;
}
if (k) {
var o = new ScalerParams(0, b.b2, b.b1, this.w8.ch, d);
this.aad(m, -1, n, this.w8, o, b.r, -1);
}
var p = c.cj;
var q = c.ck;
var r = c.cl;
var s = c.ce;
this.xh.ad(q, true, false, true, true);
this.xh.an = null;
this.xh.am = null;
this.xh.ad(p, true, false, false, true);
this.xh.ad(r, true, false, false, true);
this.xh.ad(s, false, true, false, false);
s._opacity = this.xh.j * this.h9;
};
BollingerBandsOverlay.prototype.ct = function () {
return new BollingerBandsOverlayView(this);
};
BollingerBandsOverlay.prototype.q1 = function (a) {
_super.prototype.q1.call(this, a);
this.aa7 = typeCast(BollingerBandsOverlayView.$, a);
};
BollingerBandsOverlay.prototype.y8 = function () {
return 3;
};
BollingerBandsOverlay.prototype.iy = function () {
return Series.i0(this.aa8, null);
};
BollingerBandsOverlay.$t = markType(BollingerBandsOverlay, 'BollingerBandsOverlay', FinancialOverlay.$);
BollingerBandsOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, BollingerBandsOverlay, 'raisePropertyChanged', ['Multiplier:abc:abg', [1, 2], 'Period:abd:abh', [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.b6.dp.count - 1);
if (b <= c) {
var d = this.f.ca.abc;
var e = 0;
var f = 0;
var g = 0;
for (var h = b; h <= c; ++h) {
if (!isNaN_(this.f.ca.aa8._inner[h]) && !isNaN_(this.f.ca.aa9._inner[h])) {
e += this.f.ca.aa8._inner[h];
f += this.f.ca.aa9._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.ca = null;
_this.cf = new Polygon();
_this.cm = new Polyline();
_this.cn = new Polyline();
_this.co = new Polyline();
_this.cd = new Polygon();
_this.cg = new Polyline();
_this.ch = new Polyline();
_this.ci = new Polyline();
_this.ca = a;
return _this;
}
BollingerBandsOverlayView.prototype.ax = function () {
_super.prototype.ax.call(this);
if (!this.r) {
}
};
BollingerBandsOverlayView.prototype.b5 = function () {
return new BollingerBandsBucketCalculator(this);
};
BollingerBandsOverlayView.prototype.cc = 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.id))), _e = _d.next(); !_e.done; _e = _d.next()) {
var g = _e.value;
this.cf.an.add({ $type: Point_$type, x: b(g), y: d(g) });
this.cm.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.id))), _g = _f.next(); !_g.done; _g = _f.next()) {
var h = _g.value;
this.cn.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.id))), _j = _h.next(); !_j.done; _j = _h.next()) {
var i = _j.value;
this.cf.an.add({ $type: Point_$type, x: c(i), y: f(i) });
this.co.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.av();
};
BollingerBandsOverlayView.prototype.cb = function () {
this.cf.an.clear();
this.cm.an.clear();
this.cn.an.clear();
this.co.an.clear();
this.av();
};
Object.defineProperty(BollingerBandsOverlayView.prototype, "ce", {
get: function () {
return this.cf;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BollingerBandsOverlayView.prototype, "cj", {
get: function () {
return this.cm;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BollingerBandsOverlayView.prototype, "ck", {
get: function () {
return this.cn;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BollingerBandsOverlayView.prototype, "cl", {
get: function () {
return this.co;
},
enumerable: false,
configurable: true
});
BollingerBandsOverlayView.prototype.bi = function () {
_super.prototype.bi.call(this);
this.cd.an = this.cf.an;
this.cg.an = this.cm.an;
this.ch.an = this.cn.an;
this.ci.an = this.co.an;
var a = this.bv();
this.cd._fill = a;
this.cd._opacity = 1;
this.cg._stroke = a;
this.cg.ad = this.f.ie + 3;
this.ch._stroke = a;
this.ch.ad = this.f.ie + 3;
this.ci._stroke = a;
this.ci.ad = this.f.ie + 3;
};
BollingerBandsOverlayView.prototype.bc = function (a, b) {
_super.prototype.bc.call(this, a, b);
if (a.d) {
if (b) {
a.u(this.cd);
a.v(this.cg);
a.v(this.ch);
a.v(this.ci);
}
else {
a.u(this.cf);
a.v(this.cm);
a.v(this.cn);
a.v(this.co);
}
}
};
BollingerBandsOverlayView.prototype.aq = function (a) {
_super.prototype.aq.call(this, a);
this.f.bc.exportPolygonData(a, this.cf, "FillShape", ["Fill"]);
this.f.bc.exportPolylineData(a, this.cm, "BottomLine", ["Lower", "Main"]);
this.f.bc.exportPolylineData(a, this.cn, "CentralLine", ["Central"]);
this.f.bc.exportPolylineData(a, this.co, "TopLine", ["Upper"]);
};
BollingerBandsOverlayView.$t = markType(BollingerBandsOverlayView, 'BollingerBandsOverlayView', FinancialSeriesView.$);
return BollingerBandsOverlayView;
}(FinancialSeriesView));
export { BollingerBandsOverlayView };