igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
406 lines (405 loc) • 14.9 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-angular-core";
import { Series } from "./Series";
import { List$1 } from "igniteui-angular-core";
import { Number_$type, typeCast, runOn, markType, markDep, getEnumerator, Point_$type, fromEnum } from "igniteui-angular-core";
import { CategoryFrame } from "./CategoryFrame";
import { SafeEnumerable } from "./SafeEnumerable";
import { TrendCalculators } from "igniteui-angular-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-angular-core";
import { Polygon } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
import { Flattener } from "igniteui-angular-core";
/**
* @hidden
*/
export let BollingerBandsOverlay = /*@__PURE__*/ (() => {
class BollingerBandsOverlay extends FinancialOverlay {
constructor() {
super();
this.aa7 = 0;
this.aa8 = 0;
this.aa5 = new List$1(Number_$type, 0);
this.aa6 = new List$1(Number_$type, 0);
this.ab = BollingerBandsOverlay.$;
this.w9 = new CategoryFrame(4);
this.xb = new CategoryFrame(4);
this.w7 = new CategoryFrame(4);
}
bj() {
return new BollingerBandsOverlay();
}
q8(a, b, c, d) {
if (this.yo().contains(b)) {
this.aaz = false;
}
super.q8(a, b, c, d);
switch (b) {
case BollingerBandsOverlay.$$p[1]:
this.aaz = false;
this.rq(false);
break;
case BollingerBandsOverlay.$$p[0]:
this.rq(false);
break;
}
}
aa0() {
this.aa5.clear();
this.aa6.clear();
let a = getEnumerator(TrendCalculators.e(new SafeEnumerable(this.yn), this.aba));
let b = getEnumerator(TrendCalculators.f(new SafeEnumerable(this.yn), this.aba));
this.aa8 = 1.7976931348623157E+308;
this.aa7 = -1.7976931348623157E+308;
let c = true;
let d = true;
let e = this.aa9;
while (c || d) {
if (a.moveNext()) {
this.aa5.add(a.current);
}
else {
c = false;
}
if (b.moveNext()) {
this.aa6.add(b.current);
}
else {
d = false;
}
if (c && d) {
this.aa8 = Math.min(this.aa8, a.current - b.current * e);
this.aa7 = Math.max(this.aa7, a.current + b.current * e);
}
}
return true;
}
ay(a) {
if (this.aa5 == null || this.aa6 == null || a == null || this.dn == null || a != this.xo) {
return null;
}
let b = new AxisRange(this.aa8, this.aa7);
return b;
}
aab(a, b) {
super.aab(a, b);
let c = b.by;
let d = b.bx;
let e = this.getEffectiveViewport1(b);
let f = this.w5;
let g = this.xo;
let h = new ScalerParams(0, c, d, f.ch, e);
let i = new ScalerParams(0, c, d, g.ch, e);
a.f.clear();
a.n.clear();
a.q.clear();
let j = typeCast(ISortingAxis_$type, this.w5);
if (j != null && j.i$b.count != this.dn.count) {
return;
}
let k = 0;
k = this.yw(c, d, e);
if (!this.aaz) {
this.aaz = this.aa0();
if (this.xo != null) {
this.xo.c2(true);
}
}
i.b = this.ix();
let l = this.w5.eo(2, h) - this.w5.eo(1, h);
for (let m = b.b0.c; m <= b.b0.d; ++m) {
let n;
if (j == null) {
n = b.b0.getBucket(m);
}
else {
let o = j.i$b._inner[m];
let p = j.i$d(o);
let q = this.aa5._inner[m];
let r = this.aa6._inner[m];
let s = q;
let t = r;
let u = p;
let v = 1;
while (m < b.b0.d) {
o = j.i$b._inner[m + 1];
u = j.i$d(o);
if (u - p > l) {
break;
}
m++;
s += this.aa5._inner[m];
t += this.aa6._inner[m];
v++;
}
s /= v;
t /= v;
let w = s - t * this.aa9;
let x = s;
let y = s + t * this.aa9;
let z = NaN;
if (!isNaN_(p)) {
z = this.w5.el(p, h);
}
n = [z, w, x, y];
}
let aa = Math.max(1, l);
if (!isNaN_(n[0]) && m * aa >= this.aa1) {
if (this.w5 != null && typeCast(ISortingAxis_$type, this.w5) !== 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.f.add(n);
}
}
}
o4(a, b) {
super.o4(a, b);
let c = b;
if (c != null) {
c.b7();
}
}
i4(a, b, c) {
if (this.aa5 == null) {
return super.i4(a, b, c);
}
let d = this.getEffectiveViewport1(this.cv);
let e = this.yw(this.cv.by, this.cv.bx, d);
let f = new ScalerParams(0, this.cv.by, this.cv.bx, this.w5.ch, d);
f.c = this.db.wk;
return this.i6(this.aa5, a, this.w5, f, e, runOn(this, this.yv), b, c);
}
j9(a, b) {
if (this.aa5 == null) {
return super.j9(a, b);
}
return this.ka(a, b, this.w5, runOn(this, this.yv), this.aa5);
}
j7(a, b) {
if (this.aa5 == null) {
return super.j7(a, b);
}
return this.j8(a, b, this.w5, runOn(this, this.yv), this.aa5);
}
hd(a, b, c) {
let d = super.hd(a, b, c);
if (!this.ye(this.yo())) {
d = false;
}
return d;
}
aad(a, b) {
super.aad(a, b);
let c = typeCast(BollingerBandsOverlayView.$, b);
let d = this.getEffectiveViewport1(b);
if (b.b3(a)) {
c.b7();
let e = a.f.count;
let f = (g) => a.f._inner[g][0];
let g = (h) => a.f._inner[e - 1 - h][0];
let h = (i) => a.f._inner[i][1];
let i = (j) => a.f._inner[j][2];
let j = (k) => a.f._inner[e - 1 - k][3];
c.b8(e, f, g, h, i, j);
b.b5(a);
}
this.xe.a2(this, this.yd(), runOn(this, this.wx), this.y2(b), this.y4(b));
let k = false;
let l = this.xe.b;
let m = a.f;
let n = this.dn.count;
if (l != null) {
k = true;
}
if (k) {
let o = new ScalerParams(0, b.by, b.bx, this.w5.ch, d);
this.aaa(m, -1, n, this.w5, o, b.q, -1);
}
let p = c.cf;
let q = c.cg;
let r = c.ch;
let s = c.ca;
this.xe.ad(q, true, false, true, true);
this.xe.an = null;
this.xe.am = null;
this.xe.ad(p, true, false, false, true);
this.xe.ad(r, true, false, false, true);
this.xe.ad(s, false, true, false, false);
s._opacity = this.xe.j * this.h8;
}
cs() {
return new BollingerBandsOverlayView(this);
}
q0(a) {
super.q0(a);
this.aa4 = typeCast(BollingerBandsOverlayView.$, a);
}
y5() {
return 3;
}
ix() {
return Series.iz(this.aa5, null);
}
}
BollingerBandsOverlay.$t = markType(BollingerBandsOverlay, 'BollingerBandsOverlay', FinancialOverlay.$);
BollingerBandsOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, BollingerBandsOverlay, 'raisePropertyChanged', ['Multiplier:aa9:abd', [1, 2], 'Period:aba:abe', [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.b2.dn.count - 1);
if (b <= c) {
let d = this.f.b6.aa9;
let e = 0;
let f = 0;
let g = 0;
for (let h = b; h <= c; ++h) {
if (!isNaN_(this.f.b6.aa5._inner[h]) && !isNaN_(this.f.b6.aa6._inner[h])) {
e += this.f.b6.aa5._inner[h];
f += this.f.b6.aa6._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;
})();
/**
* @hidden
*/
export let BollingerBandsOverlayView = /*@__PURE__*/ (() => {
class BollingerBandsOverlayView extends FinancialSeriesView {
constructor(a) {
super(a);
this.b6 = null;
this.cb = new Polygon();
this.ci = new Polyline();
this.cj = new Polyline();
this.ck = new Polyline();
this.b9 = new Polygon();
this.cc = new Polyline();
this.cd = new Polyline();
this.ce = new Polyline();
this.b6 = a;
}
au() {
super.au();
if (!this.q) {
}
}
b1() {
return new BollingerBandsBucketCalculator(this);
}
b8(a, b, c, d, e, f) {
for (let g of fromEnum(Flattener.d(a, b, d, this.e.ic))) {
this.cb.an.add({ $type: Point_$type, x: b(g), y: d(g) });
this.ci.an.add({ $type: Point_$type, x: b(g), y: d(g) });
}
for (let h of fromEnum(Flattener.d(a, b, e, this.e.ic))) {
this.cj.an.add({ $type: Point_$type, x: b(h), y: e(h) });
}
for (let i of fromEnum(Flattener.d(a, c, f, this.e.ic))) {
this.cb.an.add({ $type: Point_$type, x: c(i), y: f(i) });
this.ck.an.add({ $type: Point_$type, x: c(i), y: f(i) });
}
this.as();
}
b7() {
this.cb.an.clear();
this.ci.an.clear();
this.cj.an.clear();
this.ck.an.clear();
this.as();
}
get ca() {
return this.cb;
}
get cf() {
return this.ci;
}
get cg() {
return this.cj;
}
get ch() {
return this.ck;
}
be() {
super.be();
this.b9.an = this.cb.an;
this.cc.an = this.ci.an;
this.cd.an = this.cj.an;
this.ce.an = this.ck.an;
let a = this.br();
this.b9._fill = a;
this.b9._opacity = 1;
this.cc._stroke = a;
this.cc.ad = this.e.id + 3;
this.cd._stroke = a;
this.cd.ad = this.e.id + 3;
this.ce._stroke = a;
this.ce.ad = this.e.id + 3;
}
a8(a, b) {
super.a8(a, b);
if (a.d) {
if (b) {
a.u(this.b9);
a.v(this.cc);
a.v(this.cd);
a.v(this.ce);
}
else {
a.u(this.cb);
a.v(this.ci);
a.v(this.cj);
a.v(this.ck);
}
}
}
an(a) {
super.an(a);
this.e.bc.exportPolygonData(a, this.cb, "FillShape", ["Fill"]);
this.e.bc.exportPolylineData(a, this.ci, "BottomLine", ["Lower", "Main"]);
this.e.bc.exportPolylineData(a, this.cj, "CentralLine", ["Central"]);
this.e.bc.exportPolylineData(a, this.ck, "TopLine", ["Upper"]);
}
}
BollingerBandsOverlayView.$t = markType(BollingerBandsOverlayView, 'BollingerBandsOverlayView', FinancialSeriesView.$);
return BollingerBandsOverlayView;
})();