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.abd = 0;
this.abe = 0;
this.abb = new List$1(Number_$type, 0);
this.abc = new List$1(Number_$type, 0);
this.ab = BollingerBandsOverlay.$;
this.xf = new CategoryFrame(4);
this.xh = new CategoryFrame(4);
this.xd = new CategoryFrame(4);
}
rc(a, b, c, d) {
if (this.yu().contains(b)) {
this.aa5 = false;
}
super.rc(a, b, c, d);
switch (b) {
case BollingerBandsOverlay.$$p[1]:
this.aa5 = false;
this.ru(false);
break;
case BollingerBandsOverlay.$$p[0]:
this.ru(false);
break;
}
}
aa6() {
this.abb.clear();
this.abc.clear();
let a = getEnumerator(TrendCalculators.e(new SafeEnumerable(this.yt), this.abg));
let b = getEnumerator(TrendCalculators.f(new SafeEnumerable(this.yt), this.abg));
this.abe = 1.7976931348623157E+308;
this.abd = -1.7976931348623157E+308;
let c = true;
let d = true;
let e = this.abf;
while (c || d) {
if (a.moveNext()) {
this.abb.add(a.current);
}
else {
c = false;
}
if (b.moveNext()) {
this.abc.add(b.current);
}
else {
d = false;
}
if (c && d) {
this.abe = Math.min(this.abe, a.current - b.current * e);
this.abd = Math.max(this.abd, a.current + b.current * e);
}
}
return true;
}
ay(a) {
if (this.abb == null || this.abc == null || a == null || this.dp == null || a != this.xu) {
return null;
}
let b = new AxisRange(this.abe, this.abd);
return b;
}
aah(a, b) {
super.aah(a, b);
let c = b.ca;
let d = b.b9;
let e = this.getEffectiveViewport1(b);
let f = this.xb;
let g = this.xu;
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.xb);
if (j != null && j.i$b.count != this.dp.count) {
return;
}
let k = 0;
k = this.y2(c, d, e);
if (!this.aa5) {
this.aa5 = this.aa6();
if (this.xu != null) {
this.xu.c2(true);
}
}
i.b = this.iz();
let l = this.xb.eo(2, h) - this.xb.eo(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.abb._inner[m];
let r = this.abc._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.abb._inner[m];
t += this.abc._inner[m];
v++;
}
s /= v;
t /= v;
let w = s - t * this.abf;
let x = s;
let y = s + t * this.abf;
let z = NaN;
if (!isNaN_(p)) {
z = this.xb.el(p, h);
}
n = [z, w, x, y];
}
let aa = Math.max(1, l);
if (!isNaN_(n[0]) && m * aa >= this.aa7) {
if (this.xb != null && typeCast(ISortingAxis_$type, this.xb) !== 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);
}
}
}
o7(a, b) {
super.o7(a, b);
let c = b;
if (c != null) {
c.ck();
}
}
i6(a, b, c) {
if (this.abb == null) {
return super.i6(a, b, c);
}
let d = this.getEffectiveViewport1(this.cw);
let e = this.y2(this.cw.ca, this.cw.b9, d);
let f = new ScalerParams(0, this.cw.ca, this.cw.b9, this.xb.ch, d);
f.c = this.dc.xb;
return this.i8(this.abb, a, this.xb, f, e, runOn(this, this.y1), b, c);
}
kb(a, b) {
if (this.abb == null) {
return super.kb(a, b);
}
return this.kc(a, b, this.xb, runOn(this, this.y1), this.abb);
}
j9(a, b) {
if (this.abb == null) {
return super.j9(a, b);
}
return this.ka(a, b, this.xb, runOn(this, this.y1), this.abb);
}
hf(a, b, c) {
let d = super.hf(a, b, c);
if (!this.yk(this.yu())) {
d = false;
}
return d;
}
aaj(a, b) {
super.aaj(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.xk.a2(this, this.yj(), runOn(this, this.w3), this.y8(b), this.za(b));
let k = false;
let l = this.xk.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.xb.ch, d);
this.aag(m, -1, n, this.xb, o, b.t, -1);
}
let p = c.cs;
let q = c.ct;
let r = c.cu;
let s = c.cn;
this.xk.ad(q, true, false, true, true);
this.xk.an = null;
this.xk.am = null;
this.xk.ad(p, true, false, false, true);
this.xk.ad(r, true, false, false, true);
this.xk.ad(s, false, true, false, false);
s._opacity = this.xk.j * this.ia;
}
ct() {
return new BollingerBandsOverlayView(this);
}
q3(a) {
super.q3(a);
this.aba = typeCast(BollingerBandsOverlayView.$, a);
}
zb() {
return 3;
}
iz() {
return Series.i1(this.abb, null);
}
}
BollingerBandsOverlay.$t = /*@__PURE__*/ markType(BollingerBandsOverlay, 'BollingerBandsOverlay', FinancialOverlay.$);
BollingerBandsOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, BollingerBandsOverlay, 'raisePropertyChanged', ['Multiplier:abf:abj', [1, 2], 'Period:abg:abk', [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.abf;
let e = 0;
let f = 0;
let g = 0;
for (let h = b; h <= c; ++h) {
if (!isNaN_(this.f.cj.abb._inner[h]) && !isNaN_(this.f.cj.abc._inner[h])) {
e += this.f.cj.abb._inner[h];
f += this.f.cj.abc._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;
})();