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.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);
}
rh(a, b, c, d) {
if (this.y0().contains(b)) {
this.abb = false;
}
super.rh(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;
}
}
abc() {
this.abh.clear();
this.abi.clear();
let a = getEnumerator(TrendCalculators.e(new SafeEnumerable(this.yz), this.abm));
let b = getEnumerator(TrendCalculators.f(new SafeEnumerable(this.yz), this.abm));
this.abk = 1.7976931348623157E+308;
this.abj = -1.7976931348623157E+308;
let c = true;
let d = true;
let 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;
}
ay(a) {
if (this.abh == null || this.abi == null || a == null || this.dp == null || a != this.x0) {
return null;
}
let b = new AxisRange(this.abk, this.abj);
return b;
}
aan(a, b) {
super.aan(a, b);
let c = b.ca;
let d = b.b9;
let e = this.getEffectiveViewport1(b);
let f = this.xh;
let g = this.x0;
let h = new ScalerParams(0, c, d, f.df, e);
let i = new ScalerParams(0, c, d, g.df, e);
a.h.clear();
a.p.clear();
a.s.clear();
let j = typeCast(ISortingAxis_$type, this.xh);
if (j != null && j.i$b.count != this.dp.count) {
return;
}
let 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();
let l = this.xh.fw(2, h) - this.xh.fw(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.abh._inner[m];
let r = this.abi._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.abh._inner[m];
t += this.abi._inner[m];
v++;
}
s /= v;
t /= v;
let w = s - t * this.abl;
let x = s;
let y = s + t * this.abl;
let z = NaN;
if (!isNaN_(p)) {
z = this.xh.ft(p, h);
}
n = [z, w, x, y];
}
let 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);
}
}
}
pb(a, b) {
super.pb(a, b);
let c = b;
if (c != null) {
c.ck();
}
}
i8(a, b, c) {
if (this.abh == null) {
return super.i8(a, b, c);
}
let d = this.getEffectiveViewport1(this.cw);
let e = this.y8(this.cw.ca, this.cw.b9, d);
let 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);
}
ke(a, b) {
if (this.abh == null) {
return super.ke(a, b);
}
return this.kf(a, b, this.xh, runOn(this, this.y7), this.abh);
}
kc(a, b) {
if (this.abh == null) {
return super.kc(a, b);
}
return this.kd(a, b, this.xh, runOn(this, this.y7), this.abh);
}
hf(a, b, c) {
let d = super.hf(a, b, c);
if (!this.yq(this.y0())) {
d = false;
}
return d;
}
aap(a, b) {
super.aap(a, b);
let c = typeCast(BollingerBandsOverlayView.$, b);
let d = this.getEffectiveViewport1(b);
if (b.cg(a)) {
c.ck();
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.cl(e, f, g, h, i, j);
b.ci(a);
}
this.xq.a2(this, this.yp(), runOn(this, this.w9), this.ze(b), this.zg(b));
let k = false;
let l = this.xq.b;
let m = a.h;
let n = this.dp.count;
if (l != null) {
k = true;
}
if (k) {
let o = new ScalerParams(0, b.ca, b.b9, this.xh.df, d);
this.aam(m, -1, n, this.xh, o, b.t, -1);
}
let p = c.cs;
let q = c.ct;
let r = c.cu;
let 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;
}
ct() {
return new BollingerBandsOverlayView(this);
}
q8(a) {
super.q8(a);
this.abg = typeCast(BollingerBandsOverlayView.$, a);
}
zh() {
return 3;
}
i0() {
return Series.i2(this.abh, null);
}
}
BollingerBandsOverlay.$t = /*@__PURE__*/ markType(BollingerBandsOverlay, 'BollingerBandsOverlay', FinancialOverlay.$);
BollingerBandsOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, BollingerBandsOverlay, 'raisePropertyChanged', ['Multiplier:abl:abp', [1, 2], 'Period:abm:abq', [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.abl;
let e = 0;
let f = 0;
let g = 0;
for (let 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 = /*@__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.ie))) {
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.ie))) {
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.ie))) {
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.ig + 3;
this.cq._stroke = a;
this.cq.ad = this.f.ig + 3;
this.cr._stroke = a;
this.cr.ad = this.f.ig + 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;
})();