UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

873 lines (872 loc) 31.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-react-core"; import { TrendLineType_$type } from "igniteui-react-core"; import { Brush } from "igniteui-react-core"; import { PenLineCap_$type } from "igniteui-react-core"; import { DoubleCollection } from "igniteui-react-core"; import { List$1 } from "igniteui-react-core"; import { AxisRange } from "./AxisRange"; import { CategoryFrame } from "./CategoryFrame"; import { Number_$type, typeCast, enumGetBox, EnumUtil, runOn, markType, markDep } from "igniteui-react-core"; import { Rect } from "igniteui-react-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-react-core"; import { Path } from "igniteui-react-core"; import { PropertyMetadata } from "igniteui-react-core"; import { isNaN_ } from "igniteui-react-core"; import { PathGeometry } from "igniteui-react-core"; import { GeometryGroup } from "igniteui-react-core"; import { Pool$1 } from "igniteui-react-core"; import { LineGeometry } from "igniteui-react-core"; import { Defaults } from "./Defaults"; import { Extensions } from "igniteui-react-core"; import { IndicatorRenderer } from "./IndicatorRenderer"; /** * @hidden */ export let FinancialIndicator = /*@__PURE__*/ (() => { class FinancialIndicator extends FinancialSeries { get_e8() { return true; } ct() { return new FinancialIndicatorView(this); } q1(a) { super.q1(a); this.aa3 = a; } constructor() { super(); this._indicatorColumn = null; this.aa2 = null; this.xc = new CategoryFrame(3); this.xe = new CategoryFrame(3); this.xa = new CategoryFrame(3); this.indicatorColumn = new List$1(Number_$type, 0); this.aa2 = new AxisRange(-100, 100); } abg(a) { if (this.xr != null && !this.xr.c1()) { this.rs(true); } } aa8(a, b, c) { if (isNaN_(b.x) || isNaN_(b.y)) { return false; } let d = this.xr; let e = 0; if (d != null) { e = d.e6(d.me); } 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(); } } wp(a) { if (this.w8 == null || this.xr == null) { return Rect.empty; } let b = this.v9(a); let c = this.cw.b2; let d = this.cw.b1; let e = this.getEffectiveViewport1(this.cw); let f = new ScalerParams(0, c, d, this.xr.ch, e); f.b = this.iy(); let g = this.an(this.w8, this.xa.h, this.y5(this.cw), this.y7(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.xr.el(this.xr.me, 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)); } } gw(a, b) { let c = this.we(this.wj(a), true, false); if (this.aa5 == 1) { if (this.aa8(a, c, b)) { return true; } } if (this.aa5 == 1 || this.aa5 == 0) { if (this.gv(a, b)) { return true; } } if (this.aa5 == 2) { if (this.gz(a, b)) { return true; } } return false; } pb(a, b, c, d) { super.pb(a, b, c, d); if (this.w8 != null && typeCast(ISortingAxis_$type, this.w8) !== null) { this.w8.i$i(); } if (this.aa3.ce) { this.aa3.cc.g$i(a, b, c, d); } if (d != null && this.yk.containsKey(d)) { let e = this.yk.tryGetValue(d, d); d = e.p1; } if (this.w8 != null && typeCast(ISortingAxis_$type, this.w8) !== null) { a = 4; b = 0; c = this.dp.count; } switch (a) { case 3: if (this.aa7(b, c, d)) { this.abi(b, c, d); this.abg(true); } break; case 2: if (this.aa7(b, this.dp.count - b, d)) { this.abi(b, this.dp.count - b, d); this.abg(true); } break; case 1: if (this.aa7(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.abi(b, this.dp.count - b, d); this.abg(true); } break; case 0: if (this.aa7(b, this.dp.count - b, d)) { this.indicatorColumn.v(b, c); this.abi(b, this.dp.count - b, d); this.abg(true); } break; case 4: if (this.aa7(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.abi(b, this.dp.count - b, d); this.abg(true); } break; } } get_aa4() { return 0; } get aa4() { return this.get_aa4(); } get abt() { return this.c(FinancialIndicator.abj); } set abt(a) { this.h(FinancialIndicator.abj, a); } abd() { return -1; } get indicatorColumn() { return this._indicatorColumn; } set indicatorColumn(a) { this._indicatorColumn = a; } ra(a, b, c, d) { switch (b) { case "XAxis": this.aa3.ck(); break; case "TrendLineType": let e = EnumUtil.getEnumValue(TrendLineType_$type, d); if (e != 0) { this.aa3.cc = CategoryTrendLineManagerFactory.a(this.aa3.cc, this.w8, this.sx, this, this.ds); } break; } super.ra(a, b, c, d); if (this.aa3.ce && this.aa3.cc.g$e(a, b, c, d)) { this.rs(false); let f = typeCast(FinancialIndicatorView.$, this.cv); if (f != null && f.ce) { f.cc.g$e(a, b, c, d); } this.ql(); } 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.abi(0, this.dp.count, null); if (this.xr != null && !this.xr.c1()) { this.xp.b4.e(this.id); this.rs(this.gg && c != null); } } break; case "TrendLineBrush": this.rg(b); break; case FinancialIndicator.$$p[0]: this.o5(true, this.cw); this.sk(); this.rs(false); this.ql(); 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.aa7(0, this.dp.count - 1, b)) { this.abh(); } } break; case "XAxis": if (this.w8 != null && (typeCast(ISortingAxis_$type, this.w8) !== null || typeCast(ISortingAxis_$type, c) !== null)) { this.abh(); } break; case "YAxis": case FinancialIndicator.$$p[1]: this.abh(); this.ql(); break; case "TrendLineType": this.ql(); break; } } i5(a, b, c) { if (this.indicatorColumn == 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.indicatorColumn, a, this.w8, f, e, runOn(this, this.yy), b, c); } ka(a, b) { if (this.indicatorColumn == null) { return super.ka(a, b); } return this.kb(a, b, this.w8, runOn(this, this.yy), this.indicatorColumn); } j8(a, b) { if (this.indicatorColumn == null) { return super.j8(a, b); } return this.j9(a, b, this.w8, runOn(this, this.yy), this.indicatorColumn); } get_hd() { return true; } aa7(a, b, c) { if (c == null) { return true; } if (this.aa9(a, b).contains(c)) { return true; } return false; } abi(a, b, c) { this.aa6(a, b); } ay(a) { if (this.dp == null) { return null; } if (a != null && a == this.xr) { return this.aa2; } return null; } gd(a) { let b = this.dp != null ? this.dp.indexOf(a) : -1; let c = this.cw.b2; c = c.copy(); let d = this.cw.b1; let e = new Rect(0, 0, 0, 1, 1); let f = this.wn(this.cw); if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) { if (this.w8 != null) { let g = new ScalerParams(0, e, e, this.w8.ch, f); let h = this.w8.el(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.xr != null && this.indicatorColumn != null && b < this.indicatorColumn.count) { let i = new ScalerParams(0, e, e, this.xr.ch, f); i.b = this.iy(); let j = this.xr.el(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; } he(a, b, c) { let d = super.he(a, b, c); if (this.indicatorColumn == null || this.indicatorColumn.count == 0) { d = false; } return d; } 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); i.b = this.iy(); let j = this.w8.ag(); let k = j[0]; let l = j[1]; a.h.clear(); a.p.clear(); a.s.clear(); let m = 0; let n = typeCast(ISortingAxis_$type, this.w8); if (n != null && n.i$b.count != this.dp.count) { return; } m = this.yz(c, d, e); let o = this.abd(); if (o == -1) { o = this.trendLinePeriod; } let p = typeCast(FinancialIndicatorView.$, b); if (p.ce) { p.cc.prepareLineCore(a.s, this.trendLineType, this.indicatorColumn, o, (q) => this.w8.el(q, h), (q) => this.xr.el(q, i), ((() => { let $ret = new TrendResolutionParams(); $ret.e = b.b4.b; $ret.f = b.b4.c; $ret.g = b.b4.d; $ret.a = m; $ret.d = this.id; $ret.i = d; $ret.j = c; $ret.h = e; $ret.b = l; $ret.c = k; return $ret; })())); } let q = this.w8.eo(2, h) - this.w8.eo(1, h); for (let r = b.b4.c; r <= b.b4.d; ++r) { let s; if (n == null) { s = b.b4.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.b4.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.w8.el(u, h); } s = [z, v, w]; } if (!isNaN_(s[0])) { if (this.w8 != null && typeCast(ISortingAxis_$type, this.w8) !== null) { s[0] = s[0] + m; } else { s[0] = f.el(s[0], h) + m; } s[1] = g.el(s[1], i); if (b.b4.b > 1 || n != null) { s[2] = g.el(s[2], i); } else { s[2] = s[1]; } a.h.add(s); } } return; } o5(a, b) { super.o5(a, b); let c = b; c.cf(a); if (c.ce) { c.cc.g$h(); } } xi() { switch (this.aa5) { case 1: return 1; case 2: return 1; case 0: return 12; } return 1; } aag(a, b) { super.aag(a, b); let c = typeCast(FinancialIndicatorView.$, b); let d = (e) => a.h._inner[e][0]; let e = (f) => a.h._inner[f][1]; if (c.ce) { c.cc.g$h(); c.cc.g$k(a.s); } let f = b.b1; let g = this.getEffectiveViewport1(b); let h = 0; let i = this.vb; let j = this.aay; if (b.b7(a)) { c.cf(false); if (a.h.count > 0) { switch (this.aa5) { case 0: let k = CategorySeries.yp(a.h, a.h.count - 1, f, b.b2, false); c.cj(a.h.count, d, e, true, k); break; case 1: if (this.xr != null) { h = this.y3(b); } else { h = 0.5 * (f.top + f.bottom); } let l = CategorySeries.yp(a.h, a.h.count - 1, f, b.b2, false); c.ch(a.h.count, d, e, true, h, l); break; case 2: h = this.y3(b); c.ci(a.h.count, d, e, true, h); break; default: throw new NotImplementedException(0); } } b.b9(a); } let m = a.h; let n = this.dp.count; this.xh.a2(this, this.yg(), runOn(this, this.w0), this.y5(b), this.y7(b)); let o = false; let p = this.xh.b; if (p != null) { o = true; } this.xh.ak = i; this.xh.ag = i; if (o) { let q = new ScalerParams(0, b.b2, b.b1, this.w8.ch, g); this.xh.f = false; this.aad(m, -1, n, this.w8, q, b.r, -1); } this.xh.ad(c.c1, true, false, true, false); this.xh.ad(c.c3, true, false, true, false); this.xh.ad(c.c2, false, true, false, false); c.c2._opacity = 0.8 * this.xh.j * this.h9; this.xh.ad(c.c0, true, false, false, false); this.xh.ak = j; this.xh.ag = j; if (o) { let r = new ScalerParams(0, b.b2, b.b1, this.w8.ch, g); this.xh.f = true; this.aad(m, -1, n, this.w8, r, b.r, -1); } this.xh.ad(c.cx, true, false, true, false); this.xh.ad(c.cz, true, false, true, false); this.xh.ad(c.cy, false, true, false, false); c.cy._opacity = 0.8 * this.xh.j * this.h9; this.xh.ad(c.cw, true, false, false, false); c.cl(); } sj() { super.sj(); if (this.index < 0) { return; } if (this.aa3.ce) { this.aa3.cm(); } } abh() { if (this.aa3.ce) { this.aa3.cc.g$m(); } this.aa6(0, this.indicatorColumn.count); if (this.xr != null && !this.xr.c1()) { this.rs(this.gg && this.d8); } } pz(a) { super.pz(a); this.bc.exportTrendlineData(this, a, this.aa3.cc.g$n); } bf(a) { if (this.aa5 == 1 || this.aa5 == 2) { return 3; } else if (this.aa5 == 0) { return 2; } return a; } } FinancialIndicator.$t = /*@__PURE__*/ markType(FinancialIndicator, 'FinancialIndicator', FinancialSeries.$, [ITrendLineSeries_$type]); FinancialIndicator.abj = /*@__PURE__*/ DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialIndicator.$, /*@__PURE__*/ new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue))); FinancialIndicator.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, FinancialIndicator, 'raisePropertyChanged', ['DisplayType:aa5:abk', [IndicatorDisplayType_$type, /*@__PURE__*/ enumGetBox(IndicatorDisplayType_$type, 0)], 'IgnoreFirst:abb:abl', [1, 0], 'TrendLineType::abr', [TrendLineType_$type, /*@__PURE__*/ enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::abq', [1, 1.5], 'TrendLinePeriod::abp', [1, 7], 'TrendLineBrush::abm', [Brush.$, null], 'TrendLineZIndex:abc:abs', [1, 1001], 'TrendLineDashArray:abu:abn', [DoubleCollection.$], 'TrendLineDashCap:abv:abo', [PenLineCap_$type, /*@__PURE__*/ 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.ca.indicatorColumn.count - 1); let d = NaN; let e = NaN; for (let f = b; f <= c; ++f) { let g = this.f.ca.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 = /*@__PURE__*/ markType(FinancialIndicatorBucketCalculator, 'FinancialIndicatorBucketCalculator', FinancialBucketCalculator.$); return FinancialIndicatorBucketCalculator; })(); /** * @hidden */ export let FinancialIndicatorView = /*@__PURE__*/ (() => { class FinancialIndicatorView extends FinancialSeriesView { constructor(a) { super(a); this.ca = null; this.cd = null; this.c1 = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.cx = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.c2 = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.cy = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.c3 = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.cz = ((() => { let $ret = new Path(); $ret.an = new PathGeometry(); return $ret; })()); this.c0 = ((() => { let $ret = new Path(); $ret.an = new GeometryGroup(); return $ret; })()); this.cw = ((() => { let $ret = new Path(); $ret.an = new GeometryGroup(); return $ret; })()); this.cb = null; this.ct = new Path(); this.cv = new Path(); this.cu = new Path(); this.cs = new Path(); this.cp = new Path(); this.cr = new Path(); this.cq = new Path(); this.co = new Path(); this.ca = a; this.cd = ((() => { let $ret = new Pool$1(LineGeometry.$); $ret.create = runOn(this, this.cn); $ret.destroy = runOn(this, this.cg); return $ret; })()); } b5() { return new FinancialIndicatorBucketCalculator(this); } ax() { super.ax(); if (!this.r) { this.ca.aay = Defaults.ah; this.ca.aa5 = this.ca.aa4; } } cn() { return new LineGeometry(); } cg(a) { } get cc() { if (this.cb == null) { this.cb = CategoryTrendLineManagerFactory.a(this.cb, this.f.a0(), this.f.sx, this.f, this.f.ds); } return this.cb; } set cc(a) { this.cb = a; } get ce() { return this.cb != null; } cf(a) { Extensions.e(this.c1.an); Extensions.e(this.c2.an); Extensions.e(this.c3.an); Extensions.e(this.cx.an); Extensions.e(this.cy.an); Extensions.e(this.cz.an); Extensions.d(this.c0.an); Extensions.d(this.cw.an); if (a) { this.cd.count = 0; } this.av(); } cl() { } cj(a, b, c, d, e) { IndicatorRenderer.g(a, b, c, d, this.b2, this.b1, this.c1, this.cx, this.b4.b, this.f.id, e); this.av(); } ch(a, b, c, d, e, f) { IndicatorRenderer.e(a, b, c, d, this.b2, this.b1, this.c1, this.c2, this.cx, this.cy, e, this.b4.b, this.f.id, f); this.av(); } ci(a, b, c, d, e) { IndicatorRenderer.f(a, b, c, d, this.b1, e, this.cd, this.c0, this.cw); this.av(); } cm() { this.ca.abt = null; if (this.ca.trendLineBrush != null) { this.ca.abt = this.ca.trendLineBrush; } else { this.ca.abt = this.ca.vb; } } bi() { super.bi(); let a = this.bv(); this.ct.an = this.c1.an; this.cv.an = this.c3.an; this.cu.an = this.c2.an; this.cs.an = this.c0.an; this.cp.an = this.cx.an; this.cr.an = this.cz.an; this.cq.an = this.cy.an; this.co.an = this.cw.an; this.ct._stroke = a; this.cv._stroke = a; this.ct.ad = this.f.ie + 3; this.cv.ad = this.f.ie + 3; this.cu._fill = a; this.cu._opacity = 1; this.cs._stroke = a; this.cs.ad = this.f.ie + 3; this.cp._stroke = a; this.cr._stroke = a; this.cp.ad = this.f.ie + 3; this.cr.ad = this.f.ie + 3; this.cq._fill = a; this.cq._opacity = 1; this.co._stroke = a; this.co.ad = this.f.ie + 3; } bc(a, b) { super.bc(a, b); if (a.d) { if (b) { if (this.ca.aa5 == 2) { a.t(this.cs); a.t(this.co); } else { a.t(this.cu); a.t(this.ct); a.t(this.cv); a.t(this.cq); a.t(this.cp); a.t(this.cr); } } else { if (this.ca.aa5 == 2) { a.t(this.c0); a.t(this.cw); } else { a.t(this.c2); a.t(this.c1); a.t(this.c3); a.t(this.cy); a.t(this.cx); a.t(this.cz); } } } } bb(a, b) { if (a.d) { if (this.ca.trendLineType != 0 && !b) { let c = this.cc.g$n; c.ad = this.ca.trendLineThickness; c._stroke = this.ca.abt; c.aj = this.ca.abv; c.ai = this.ca.abu; a.v(c); } } super.bb(a, b); } aq(a) { super.aq(a); this.f.bc.exportPathData(a, this.c0, "positiveColumnsShape", ["Positive", "Main"]); this.f.bc.exportPathData(a, this.cw, "negativeColumnsShape", ["Negative"]); this.f.bc.exportPathData(a, this.c1, "positive0", ["Positive", "Main"]); this.f.bc.exportPathData(a, this.c3, "positive1", ["Positive"]); this.f.bc.exportPathData(a, this.c2, "positive01", ["PositiveFill"]); this.f.bc.exportPathData(a, this.cx, "negative0", ["Negative", "Main"]); this.f.bc.exportPathData(a, this.cz, "negative1", ["Negative"]); this.f.bc.exportPathData(a, this.cy, "negative01", ["NegativeFill"]); } ck() { if (this.ce) { this.cb = CategoryTrendLineManagerFactory.a(this.cb, this.f.a0(), this.f.sx, this.f, this.f.ds); } } } FinancialIndicatorView.$t = /*@__PURE__*/ markType(FinancialIndicatorView, 'FinancialIndicatorView', FinancialSeriesView.$); return FinancialIndicatorView; })();