igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
406 lines (405 loc) • 14.5 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 { 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.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);
}
ra(a, b, c, d) {
if (this.yr().contains(b)) {
this.aa2 = false;
}
super.ra(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;
}
}
aa3() {
this.aa8.clear();
this.aa9.clear();
let a = getEnumerator(TrendCalculators.e(new SafeEnumerable(this.yq), this.abd));
let b = getEnumerator(TrendCalculators.f(new SafeEnumerable(this.yq), this.abd));
this.abb = 1.7976931348623157E+308;
this.aba = -1.7976931348623157E+308;
let c = true;
let d = true;
let 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;
}
ay(a) {
if (this.aa8 == null || this.aa9 == null || a == null || this.dp == null || a != this.xr) {
return null;
}
let b = new AxisRange(this.abb, this.aba);
return b;
}
aae(a, b) {
super.aae(a, b);
let c = b.b2;
let d = b.b1;
let e = this.getEffectiveViewport1(b);
let f = this.w8;
let g = this.xr;
let h = new ScalerParams(0, c, d, f.ch, e);
let i = new ScalerParams(0, c, d, g.ch, e);
a.h.clear();
a.p.clear();
a.s.clear();
let j = typeCast(ISortingAxis_$type, this.w8);
if (j != null && j.i$b.count != this.dp.count) {
return;
}
let 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();
let l = this.w8.eo(2, h) - this.w8.eo(1, h);
for (let m = b.b4.c; m <= b.b4.d; ++m) {
let n;
if (j == null) {
n = b.b4.getBucket(m);
}
else {
let o = j.i$b._inner[m];
let p = j.i$d(o);
let q = this.aa8._inner[m];
let r = this.aa9._inner[m];
let s = q;
let t = r;
let u = p;
let 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;
let w = s - t * this.abc;
let x = s;
let y = s + t * this.abc;
let z = NaN;
if (!isNaN_(p)) {
z = this.w8.el(p, h);
}
n = [z, w, x, y];
}
let 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);
}
}
}
o5(a, b) {
super.o5(a, b);
let c = b;
if (c != null) {
c.cb();
}
}
i5(a, b, c) {
if (this.aa8 == null) {
return super.i5(a, b, c);
}
let d = this.getEffectiveViewport1(this.cw);
let e = this.yz(this.cw.b2, this.cw.b1, d);
let 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);
}
ka(a, b) {
if (this.aa8 == null) {
return super.ka(a, b);
}
return this.kb(a, b, this.w8, runOn(this, this.yy), this.aa8);
}
j8(a, b) {
if (this.aa8 == null) {
return super.j8(a, b);
}
return this.j9(a, b, this.w8, runOn(this, this.yy), this.aa8);
}
he(a, b, c) {
let d = super.he(a, b, c);
if (!this.yh(this.yr())) {
d = false;
}
return d;
}
aag(a, b) {
super.aag(a, b);
let c = typeCast(BollingerBandsOverlayView.$, b);
let d = this.getEffectiveViewport1(b);
if (b.b7(a)) {
c.cb();
let e = a.h.count;
let f = (g) => a.h._inner[g][0];
let g = (h) => a.h._inner[e - 1 - h][0];
let h = (i) => a.h._inner[i][1];
let i = (j) => a.h._inner[j][2];
let j = (k) => a.h._inner[e - 1 - k][3];
c.cc(e, f, g, h, i, j);
b.b9(a);
}
this.xh.a2(this, this.yg(), runOn(this, this.w0), this.y5(b), this.y7(b));
let k = false;
let l = this.xh.b;
let m = a.h;
let n = this.dp.count;
if (l != null) {
k = true;
}
if (k) {
let o = new ScalerParams(0, b.b2, b.b1, this.w8.ch, d);
this.aad(m, -1, n, this.w8, o, b.r, -1);
}
let p = c.cj;
let q = c.ck;
let r = c.cl;
let 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;
}
ct() {
return new BollingerBandsOverlayView(this);
}
q1(a) {
super.q1(a);
this.aa7 = typeCast(BollingerBandsOverlayView.$, a);
}
y8() {
return 3;
}
iy() {
return Series.i0(this.aa8, null);
}
}
BollingerBandsOverlay.$t = /*@__PURE__*/ markType(BollingerBandsOverlay, 'BollingerBandsOverlay', FinancialOverlay.$);
BollingerBandsOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, BollingerBandsOverlay, 'raisePropertyChanged', ['Multiplier:abc:abg', [1, 2], 'Period:abd:abh', [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.b6.dp.count - 1);
if (b <= c) {
let d = this.f.ca.abc;
let e = 0;
let f = 0;
let g = 0;
for (let 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 = /*@__PURE__*/ markType(BollingerBandsBucketCalculator, 'BollingerBandsBucketCalculator', FinancialBucketCalculator.$);
return BollingerBandsBucketCalculator;
})();
/**
* @hidden
*/
export let BollingerBandsOverlayView = /*@__PURE__*/ (() => {
class BollingerBandsOverlayView extends FinancialSeriesView {
constructor(a) {
super(a);
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;
}
ax() {
super.ax();
if (!this.r) {
}
}
b5() {
return new BollingerBandsBucketCalculator(this);
}
cc(a, b, c, d, e, f) {
for (let g of fromEnum(Flattener.d(a, b, d, this.f.id))) {
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) });
}
for (let h of fromEnum(Flattener.d(a, b, e, this.f.id))) {
this.cn.an.add({ $type: Point_$type, x: b(h), y: e(h) });
}
for (let i of fromEnum(Flattener.d(a, c, f, this.f.id))) {
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) });
}
this.av();
}
cb() {
this.cf.an.clear();
this.cm.an.clear();
this.cn.an.clear();
this.co.an.clear();
this.av();
}
get ce() {
return this.cf;
}
get cj() {
return this.cm;
}
get ck() {
return this.cn;
}
get cl() {
return this.co;
}
bi() {
super.bi();
this.cd.an = this.cf.an;
this.cg.an = this.cm.an;
this.ch.an = this.cn.an;
this.ci.an = this.co.an;
let 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;
}
bc(a, b) {
super.bc(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);
}
}
}
aq(a) {
super.aq(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 = /*@__PURE__*/ markType(BollingerBandsOverlayView, 'BollingerBandsOverlayView', FinancialSeriesView.$);
return BollingerBandsOverlayView;
})();