UNPKG

igniteui-angular-charts

Version:

Ignite UI Angular charting components for building rich data visualizations for modern web apps.

881 lines (880 loc) 32.9 kB
/* 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 { FinancialSeries } from "./FinancialSeries"; import { ITrendLineSeries_$type } from "./ITrendLineSeries"; import { IndicatorDisplayType_$type } from "./IndicatorDisplayType"; import { DependencyProperty } from "igniteui-angular-core"; import { TrendLineType_$type } from "igniteui-angular-core"; import { Brush } from "igniteui-angular-core"; import { PenLineCap_$type } from "igniteui-angular-core"; import { DoubleCollection } from "igniteui-angular-core"; import { List$1 } from "igniteui-angular-core"; import { AxisRange } from "./AxisRange"; import { CategoryFrame } from "./CategoryFrame"; import { Number_$type, typeCast, enumGetBox, EnumUtil, runOn, markType, markDep } from "igniteui-angular-core"; import { Rect } from "igniteui-angular-core"; import { ScalerParams } from "./ScalerParams"; import { ISortingAxis_$type } from "./ISortingAxis"; import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory"; import { FinancialSeriesView } from "./FinancialSeriesView"; import { FinancialBucketCalculator } from "./FinancialBucketCalculator"; import { TrendResolutionParams } from "./TrendResolutionParams"; import { CategorySeries } from "./CategorySeries"; import { NotImplementedException } from "igniteui-angular-core"; import { Path } from "igniteui-angular-core"; import { PropertyMetadata } from "igniteui-angular-core"; import { isNaN_ } from "igniteui-angular-core"; import { PathGeometry } from "igniteui-angular-core"; import { GeometryGroup } from "igniteui-angular-core"; import { Pool$1 } from "igniteui-angular-core"; import { LineGeometry } from "igniteui-angular-core"; import { Defaults } from "./Defaults"; import { Extensions } from "igniteui-angular-core"; import { IndicatorRenderer } from "./IndicatorRenderer"; /** * @hidden */ export let FinancialIndicator = /*@__PURE__*/ (() => { class FinancialIndicator extends FinancialSeries { constructor() { super(); this._indicatorColumn = null; this.abk = null; this.xu = new CategoryFrame(3); this.xw = new CategoryFrame(3); this.xs = new CategoryFrame(3); this.indicatorColumn = new List$1(Number_$type, 0); this.abk = new AxisRange(-100, 100); } get_fb() { return true; } ct() { return new FinancialIndicatorView(this); } rg(a) { super.rg(a); this.abl = a; } aby(a) { if (this.x9 != null && !this.x9.ec()) { this.r7(true); } } abq(a, b, c) { if (isNaN_(b.x) || isNaN_(b.y)) { return false; } let d = this.x9; let e = 0; if (d != null) { e = d.gs(d.q7); } if ((a.y >= e && a.y <= b.y) || (a.y <= e && a.y >= b.y)) { return true; } return false; } b3() { if (this.b4 == 0) { return 1; } else { return super.b3(); } } w7(a) { if (this.xq == null || this.x9 == null) { return Rect.empty; } let b = this.wq(a); let c = this.cw.ca; let d = this.cw.b9; let e = this.getEffectiveViewport1(this.cw); let f = new ScalerParams(0, c, d, this.x9.dn, e); f.b = this.i5(); let g = this.an(this.xq, this.xs.k, this.zn(this.cw), this.zp(this.cw), a, true); if (g == null) { return Rect.empty; } let h = g[0]; let i = g[1]; let j = Math.abs(b.x - h[0]); let k = Math.abs(b.x - i[0]); let l = this.x9.f5(this.x9.q7, f); let m = 1; if (j < k) { let n = h[0] - 0.5 * m; let o = h[1]; let p = l; return new Rect(0, n, Math.min(o, p), m, Math.max(o, p) - Math.min(o, p)); } else { let q = i[0] - 0.5 * m; let r = i[1]; let s = l; return new Rect(0, q, Math.min(r, s), m, Math.max(r, s) - Math.min(r, s)); } } g2(a, b) { let c = this.wv(this.w1(a), true, false); if (this.abn == 1) { if (this.abq(a, c, b)) { return true; } } if (this.abn == 1 || this.abn == 0) { if (this.g1(a, b)) { return true; } } if (this.abn == 2) { if (this.g5(a, b)) { return true; } } return false; } pn(a, b, c, d) { super.pn(a, b, c, d); if (this.xq != null && typeCast(ISortingAxis_$type, this.xq) !== null) { this.xq.i$i(); } if (this.abl.cn) { this.abl.cl.g$i(a, b, c, d); } if (d != null && this.y2.containsKey(d)) { let e = this.y2.tryGetValue(d, d); d = e.p1; } if (this.xq != null && typeCast(ISortingAxis_$type, this.xq) !== null) { a = 4; b = 0; c = this.dp.count; } switch (a) { case 3: if (this.abp(b, c, d)) { this.ab0(b, c, d); this.aby(true); } break; case 2: if (this.abp(b, this.dp.count - b, d)) { this.ab0(b, this.dp.count - b, d); this.aby(true); } break; case 1: if (this.abp(b, this.dp.count - b, d)) { let f = new Array(c); for (let g = 0; g < c; g++) { f[g] = 0; } this.indicatorColumn.s(b, f); this.ab0(b, this.dp.count - b, d); this.aby(true); } break; case 0: if (this.abp(b, this.dp.count - b, d)) { this.indicatorColumn.v(b, c); this.ab0(b, this.dp.count - b, d); this.aby(true); } break; case 4: if (this.abp(b, this.dp.count - b, d)) { this.indicatorColumn = new List$1(Number_$type, 2, this.dp.count); let h = new Array(c); for (let i = 0; i < c; i++) { h[i] = 0; } this.indicatorColumn.s(0, h); this.ab0(b, this.dp.count - b, d); this.aby(true); } break; } } get_abm() { return 0; } get abm() { return this.get_abm(); } get acb() { return this.c(FinancialIndicator.ab1); } set acb(a) { this.h(FinancialIndicator.ab1, a); } abv() { return -1; } get indicatorColumn() { return this._indicatorColumn; } set indicatorColumn(a) { this._indicatorColumn = a; } rp(a, b, c, d) { switch (b) { case "XAxis": this.abl.ct(); break; case "TrendLineType": let e = EnumUtil.getEnumValue(TrendLineType_$type, d); if (e != 0) { this.abl.cl = CategoryTrendLineManagerFactory.a(this.abl.cl, this.xq, this.tc, this, this.ds); } break; } super.rp(a, b, c, d); if (this.abl.cn && this.abl.cl.g$e(a, b, c, d)) { this.r7(false); let f = typeCast(FinancialIndicatorView.$, this.cv); if (f != null && f.cn) { f.cl.g$e(a, b, c, d); } this.qz(); } switch (b) { case "FastItemsSource": if (this.dp != null) { this.indicatorColumn = new List$1(Number_$type, 2, this.dp.count); let g = new Array(this.dp.count); for (let h = 0; h < this.dp.count; h++) { g[h] = 0; } this.indicatorColumn.s(0, g); this.ab0(0, this.dp.count, null); if (this.x9 != null && !this.x9.ec()) { this.x7.cd.e(this.ik); this.r7(this.gm && c != null); } } break; case "TrendLineBrush": this.rv(b); break; case FinancialIndicator.$$p[0]: this.ph(true, this.cw); this.sz(); this.r7(false); this.qz(); break; case "OpenColumn": case "HighColumn": case "LowColumn": case "CloseColumn": case "VolumeColumn": if (this.dp != null) { if (this.indicatorColumn.count != this.dp.count) { this.indicatorColumn = new List$1(Number_$type, 2, this.dp.count); let i = new Array(this.dp.count); for (let j = 0; j < this.dp.count; j++) { i[j] = 0; } this.indicatorColumn.s(0, i); } if (this.abp(0, this.dp.count - 1, b)) { this.abz(); } } break; case "XAxis": if (this.xq != null && (typeCast(ISortingAxis_$type, this.xq) !== null || typeCast(ISortingAxis_$type, c) !== null)) { this.abz(); } break; case "YAxis": case FinancialIndicator.$$p[1]: this.abz(); this.qz(); break; case "TrendLineType": this.qz(); break; } } jd(a, b, c) { if (this.indicatorColumn == null) { return super.jd(a, b, c); } let d = this.getEffectiveViewport1(this.cw); let e = this.zh(this.cw.ca, this.cw.b9, d); let f = new ScalerParams(0, this.cw.ca, this.cw.b9, this.xq.dn, d); f.c = this.dc.y9; return this.jf(this.indicatorColumn, a, this.xq, f, e, runOn(this, this.zg), b, c); } kj(a, b) { if (this.indicatorColumn == null) { return super.kj(a, b); } return this.kk(a, b, this.xq, runOn(this, this.zg), this.indicatorColumn); } kh(a, b) { if (this.indicatorColumn == null) { return super.kh(a, b); } return this.ki(a, b, this.xq, runOn(this, this.zg), this.indicatorColumn); } get_hj() { return true; } abp(a, b, c) { if (c == null) { return true; } if (this.abr(a, b).contains(c)) { return true; } return false; } ab0(a, b, c) { this.abo(a, b); } ay(a) { if (this.dp == null) { return null; } if (a != null && a == this.x9) { return this.abk; } return null; } gj(a) { let b = this.dp != null ? this.dp.indexOf(a) : -1; let c = this.cw.ca; c = c.copy(); let d = this.cw.b9; let e = new Rect(0, 0, 0, 1, 1); let f = this.w5(this.cw); if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) { if (this.xq != null) { let g = new ScalerParams(0, e, e, this.xq.dn, f); let h = this.xq.f5(b, g); if (h < c.left + 0.1 * c.width) { h = h + 0.4 * c.width; } if (h > c.right - 0.1 * c.width) { h = h - 0.4 * c.width; } c.x = h - 0.5 * c.width; } if (this.x9 != null && this.indicatorColumn != null && b < this.indicatorColumn.count) { let i = new ScalerParams(0, e, e, this.x9.dn, f); i.b = this.i5(); let j = this.x9.f5(this.indicatorColumn._inner[b], i); if (j < c.top + 0.1 * c.height) { j = j + 0.4 * c.height; } if (j > c.bottom - 0.1 * c.height) { j = j - 0.4 * c.height; } c.y = j - 0.5 * c.height; } this.c4.au(this.dc, c, true); } return b >= 0; } hk(a, b, c) { let d = super.hk(a, b, c); if (this.indicatorColumn == null || this.indicatorColumn.count == 0) { d = false; } return d; } aaw(a, b) { super.aaw(a, b); let c = b.ca; let d = b.b9; let e = this.getEffectiveViewport1(b); let f = this.xq; let g = this.x9; let h = new ScalerParams(0, c, d, f.dn, e); let i = new ScalerParams(0, c, d, g.dn, e); i.b = this.i5(); let j = this.xq.ag(); let k = j[0]; let l = j[1]; a.k.clear(); a.s.clear(); a.v.clear(); let m = 0; let n = typeCast(ISortingAxis_$type, this.xq); if (n != null && n.i$b.count != this.dp.count) { return; } m = this.zh(c, d, e); let o = this.abv(); if (o == -1) { o = this.trendLinePeriod; } let p = typeCast(FinancialIndicatorView.$, b); if (p.cn) { p.cl.prepareLineCore(a.v, this.trendLineType, this.indicatorColumn, o, (q) => this.xq.f5(q, h), (q) => this.x9.f5(q, i), ((() => { let $ret = new TrendResolutionParams(); $ret.e = b.cd.b; $ret.f = b.cd.c; $ret.g = b.cd.d; $ret.a = m; $ret.d = this.ik; $ret.i = d; $ret.j = c; $ret.h = e; $ret.b = l; $ret.c = k; return $ret; })())); } let q = this.xq.f8(2, h) - this.xq.f8(1, h); for (let r = b.cd.c; r <= b.cd.d; ++r) { let s; if (n == null) { s = b.cd.getBucket(r); } else { let t = n.i$b._inner[r]; let u = n.i$d(t); let v = this.indicatorColumn._inner[r]; let w = v; let x = u; while (r < b.cd.d) { t = n.i$b._inner[r + 1]; x = n.i$d(t); if (x - u > q) { break; } r++; let y = this.indicatorColumn._inner[r]; v = Math.min(v, y); w = Math.max(w, y); } let z = NaN; if (!isNaN_(u)) { z = this.xq.f5(u, h); } s = [z, v, w]; } if (!isNaN_(s[0])) { if (this.xq != null && typeCast(ISortingAxis_$type, this.xq) !== null) { s[0] = s[0] + m; } else { s[0] = f.f5(s[0], h) + m; } s[1] = g.f5(s[1], i); if (b.cd.b > 1 || n != null) { s[2] = g.f5(s[2], i); } else { s[2] = s[1]; } a.k.add(s); } } return; } ph(a, b) { super.ph(a, b); let c = b; c.co(a); if (c.cn) { c.cl.g$h(); } } x0() { switch (this.abn) { case 1: return 1; case 2: return 1; case 0: return 12; } return 1; } aay(a, b) { super.aay(a, b); let c = typeCast(FinancialIndicatorView.$, b); let d = (e) => a.k._inner[e][0]; let e = (f) => a.k._inner[f][1]; if (c.cn) { c.cl.g$h(); c.cl.g$k(a.v); } let f = b.b9; let g = this.getEffectiveViewport1(b); let h = 0; let i = this.vs; let j = this.abg; if (b.cg(a)) { c.co(false); if (a.k.count > 0) { switch (this.abn) { case 0: let k = CategorySeries.y7(a.k, a.k.count - 1, f, b.ca, false); c.cs(a.k.count, d, e, true, k); break; case 1: if (this.x9 != null) { h = this.zl(b); } else { h = 0.5 * (f.top + f.bottom); } let l = CategorySeries.y7(a.k, a.k.count - 1, f, b.ca, false); c.cq(a.k.count, d, e, true, h, l); break; case 2: h = this.zl(b); c.cr(a.k.count, d, e, true, h); break; default: throw new NotImplementedException(0); } } b.ci(a); } let m = a.k; let n = this.dp.count; this.xz.a2(this, this.yy(), runOn(this, this.xi), this.zn(b), this.zp(b)); let o = false; let p = this.xz.b; if (p != null) { o = true; } this.xz.ak = i; this.xz.ag = i; if (o) { let q = new ScalerParams(0, b.ca, b.b9, this.xq.dn, g); this.xz.f = false; this.aav(m, -1, n, this.xq, q, b.t, -1); } this.xz.ad(c.da, true, false, true, false); this.xz.ad(c.dc, true, false, true, false); this.xz.ad(c.db, false, true, false, false); c.db._opacity = 0.8 * this.xz.j * this.ig; this.xz.ad(c.c9, true, false, false, false); this.xz.ak = j; this.xz.ag = j; if (o) { let r = new ScalerParams(0, b.ca, b.b9, this.xq.dn, g); this.xz.f = true; this.aav(m, -1, n, this.xq, r, b.t, -1); } this.xz.ad(c.c6, true, false, true, false); this.xz.ad(c.c8, true, false, true, false); this.xz.ad(c.c7, false, true, false, false); c.c7._opacity = 0.8 * this.xz.j * this.ig; this.xz.ad(c.c5, true, false, false, false); c.cu(); } sy() { super.sy(); if (this.index < 0) { return; } if (this.abl.cn) { this.abl.cv(); } } abz() { if (this.abl.cn) { this.abl.cl.g$m(); } this.abo(0, this.indicatorColumn.count); if (this.x9 != null && !this.x9.ec()) { this.r7(this.gm && this.d9); } } qc(a) { super.qc(a); this.bc.exportTrendlineData(this, a, this.abl.cl.g$n); } bf(a) { if (this.abn == 1 || this.abn == 2) { return 3; } else if (this.abn == 0) { return 2; } return a; } qq() { super.qq(); if (this.abl.cn) { this.abl.cl.g$m(); } } } FinancialIndicator.$t = markType(FinancialIndicator, 'FinancialIndicator', FinancialSeries.$, [ITrendLineSeries_$type]); FinancialIndicator.ab1 = DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialIndicator.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue))); FinancialIndicator.$$p = markDep(DependencyProperty, PropertyMetadata, FinancialIndicator, 'raisePropertyChanged', ['DisplayType:abn:ab2', [IndicatorDisplayType_$type, enumGetBox(IndicatorDisplayType_$type, 0)], 'IgnoreFirst:abt:ab3', [1, 0], 'TrendLineType::ab9', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ab8', [1, 1.5], 'TrendLinePeriod::ab7', [1, 7], 'TrendLineBrush::ab4', [Brush.$, null], 'TrendLineZIndex:abu:aca', [1, 1001], 'TrendLineDashArray:acc:ab5', [DoubleCollection.$], 'TrendLineDashCap:acd:ab6', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]); return FinancialIndicator; })(); /** * @hidden */ export let FinancialIndicatorBucketCalculator = /*@__PURE__*/ (() => { class FinancialIndicatorBucketCalculator 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.f.cj.indicatorColumn.count - 1); let d = NaN; let e = NaN; if (b <= c) { for (let f = b; f <= c; ++f) { let g = this.f.cj.indicatorColumn._inner[f]; if (!isNaN_(d)) { if (!isNaN_(g)) { d = Math.min(d, g); e = Math.max(e, g); } } else { d = g; e = g; } } } if (!isNaN_(d)) { return [0.5 * (b + c), d, e]; } return [NaN, NaN, NaN]; } } FinancialIndicatorBucketCalculator.$t = markType(FinancialIndicatorBucketCalculator, 'FinancialIndicatorBucketCalculator', FinancialBucketCalculator.$); return FinancialIndicatorBucketCalculator; })(); /** * @hidden */ export let FinancialIndicatorView = /*@__PURE__*/ (() => { class FinancialIndicatorView extends FinancialSeriesView { constructor(a) { super(a); this.cj = null; this.cm = null; this.da = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.c6 = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.db = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.c7 = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.dc = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.c8 = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.c9 = ((() => { let $ret = new Path(); $ret.an = new GeometryGroup(); return $ret; })()); this.c5 = ((() => { let $ret = new Path(); $ret.an = new GeometryGroup(); return $ret; })()); this.ck = null; this.c2 = new Path(); this.c4 = new Path(); this.c3 = new Path(); this.c1 = new Path(); this.cy = new Path(); this.c0 = new Path(); this.cz = new Path(); this.cx = new Path(); this.cj = a; this.cm = ((() => { let $ret = new Pool$1(LineGeometry.$); $ret.create = runOn(this, this.cw); $ret.destroy = runOn(this, this.cp); return $ret; })()); } ce() { return new FinancialIndicatorBucketCalculator(this); } a4() { super.a4(); if (!this.t) { this.cj.abg = Defaults.financialSeries_NegativeBrush; this.cj.abn = this.cj.abm; } } cw() { return new LineGeometry(); } cp(a) { } get cl() { if (this.ck == null) { this.ck = CategoryTrendLineManagerFactory.a(this.ck, this.f.a0(), this.f.tc, this.f, this.f.ds); } return this.ck; } set cl(a) { this.ck = a; } get cn() { return this.ck != null; } co(a) { Extensions.e(this.da.an); Extensions.e(this.db.an); Extensions.e(this.dc.an); Extensions.e(this.c6.an); Extensions.e(this.c7.an); Extensions.e(this.c8.an); Extensions.d(this.c9.an); Extensions.d(this.c5.an); if (a) { this.cm.count = 0; } this.a2(); } cu() { } cs(a, b, c, d, e) { IndicatorRenderer.g(a, b, c, d, this.ca, this.b9, this.da, this.c6, this.cd.b, this.f.ik, e); this.a2(); } cq(a, b, c, d, e, f) { IndicatorRenderer.e(a, b, c, d, this.ca, this.b9, this.da, this.db, this.c6, this.c7, e, this.cd.b, this.f.ik, f); this.a2(); } cr(a, b, c, d, e) { IndicatorRenderer.f(a, b, c, d, this.b9, e, this.cm, this.c9, this.c5); this.a2(); } cv() { this.cj.acb = null; if (this.cj.trendLineBrush != null) { this.cj.acb = this.cj.trendLineBrush; } else { this.cj.acb = this.cj.vs; } } bq() { super.bq(); let a = this.b3(); this.c2.an = this.da.an; this.c4.an = this.dc.an; this.c3.an = this.db.an; this.c1.an = this.c9.an; this.cy.an = this.c6.an; this.c0.an = this.c8.an; this.cz.an = this.c7.an; this.cx.an = this.c5.an; this.c2._stroke = a; this.c4._stroke = a; this.c2.ad = this.f.il + 3; this.c4.ad = this.f.il + 3; this.c3._fill = a; this.c3._opacity = 1; this.c1._stroke = a; this.c1.ad = this.f.il + 3; this.cy._stroke = a; this.c0._stroke = a; this.cy.ad = this.f.il + 3; this.c0.ad = this.f.il + 3; this.cz._fill = a; this.cz._opacity = 1; this.cx._stroke = a; this.cx.ad = this.f.il + 3; } bj(a, b) { super.bj(a, b); if (a.d) { if (b) { if (this.cj.abn == 2) { a.t(this.c1); a.t(this.cx); } else { a.t(this.c3); a.t(this.c2); a.t(this.c4); a.t(this.cz); a.t(this.cy); a.t(this.c0); } } else { if (this.cj.abn == 2) { a.t(this.c9); a.t(this.c5); } else { a.t(this.db); a.t(this.da); a.t(this.dc); a.t(this.c7); a.t(this.c6); a.t(this.c8); } } } } bi(a, b) { if (a.d) { if (this.cj.trendLineType != 0 && !b) { let c = this.cl.g$n; c.ad = this.cj.trendLineThickness; c._stroke = this.cj.acb; c.aj = this.cj.acd; c.ai = this.cj.acc; a.v(c); } } super.bi(a, b); } ax(a) { super.ax(a); this.f.bc.exportPathData(a, this.c9, "positiveColumnsShape", ["Positive", "Main"]); this.f.bc.exportPathData(a, this.c5, "negativeColumnsShape", ["Negative"]); this.f.bc.exportPathData(a, this.da, "positive0", ["Positive", "Main"]); this.f.bc.exportPathData(a, this.dc, "positive1", ["Positive"]); this.f.bc.exportPathData(a, this.db, "positive01", ["PositiveFill"]); this.f.bc.exportPathData(a, this.c6, "negative0", ["Negative", "Main"]); this.f.bc.exportPathData(a, this.c8, "negative1", ["Negative"]); this.f.bc.exportPathData(a, this.c7, "negative01", ["NegativeFill"]); } ct() { if (this.cn) { this.ck = CategoryTrendLineManagerFactory.a(this.ck, this.f.a0(), this.f.tc, this.f, this.f.ds); } } } FinancialIndicatorView.$t = markType(FinancialIndicatorView, 'FinancialIndicatorView', FinancialSeriesView.$); return FinancialIndicatorView; })();