UNPKG

igniteui-angular-charts

Version:

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

1,440 lines 53.6 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 { TrendLineType_$type } from "igniteui-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { PenLineCap_$type } from "igniteui-angular-core";
import { DoubleCollection } from "igniteui-angular-core";
import { PriceDisplayType_$type } from "./PriceDisplayType";
import { CategoryCollisionMode_$type } from "./CategoryCollisionMode";
import { Series } from "./Series";
import { Defaults } from "./Defaults";
import { enumGetBox, EnumUtil, Number_$type, typeCast, fromEnum, Point_$type, runOn, markType, markDep } from "igniteui-angular-core";
import { CategoryFrame } from "./CategoryFrame";
import { ISortingAxis_$type } from "./ISortingAxis";
import { FinancialSeriesView } from "./FinancialSeriesView";
import { List$1 } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { RectUtil } from "igniteui-angular-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { AxisRange } from "./AxisRange";
import { ScalerParams } from "./ScalerParams";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { Pool$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { PathGeometry } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { LineSegment } from "igniteui-angular-core";
import { GeometryGroup } from "igniteui-angular-core";
import { LineGeometry } from "igniteui-angular-core";
import { RectangleGeometry } from "igniteui-angular-core";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { ChartSelection } from "./ChartSelection";
import { PropertyMetadata } from "igniteui-angular-core";
import { truncate, isNaN_, isInfinity } from "igniteui-angular-core";
import { boxArray$1 } from "igniteui-angular-core";
import { round10N } from "igniteui-angular-core";
import { FinancialPriceBucketCalculator } from "./FinancialPriceBucketCalculator";
import { Extensions } from "igniteui-angular-core";
/**
 * @hidden
 */
export let FinancialPriceSeries = /*@__PURE__*/ (() => {
    class FinancialPriceSeries extends FinancialSeries {
        constructor() {
            super();
            this.abp = true;
            this.abq = 0;
            this.abr = 0;
            this.ab = FinancialPriceSeries.$;
            this.xv = new CategoryFrame(5);
            this.xx = new CategoryFrame(5);
            this.xt = new CategoryFrame(5);
        }
        bk() {
            return new FinancialPriceSeries();
        }
        get_fd() {
            return true;
        }
        js() {
            if (!isNaN_(this.jr)) {
                return super.js();
            }
            return Defaults.financialSeries_Resolution;
        }
        ct() {
            return new FinancialPriceSeriesView(this);
        }
        rh(a) {
            super.rh(a);
            this.abn = a;
        }
        get ac6() {
            return this.c(FinancialPriceSeries.acn);
        }
        set ac6(a) {
            this.h(FinancialPriceSeries.acn, a);
        }
        po(a, b, c, d) {
            super.po(a, b, c, d);
            if (this.xr != null && typeCast(ISortingAxis_$type, this.xr) !== null) {
                this.xr.i$i();
            }
            this.abn.cd.e(this.ik);
            if (this.abn.cn) {
                this.abn.cl.g$i(a, b, c, d);
            }
            if (this.abn.aa.count > 0) {
                for (let e of fromEnum(this.abn.aa)) {
                    e.g$i(a, b, c, d);
                }
            }
            if (this.ya != null) {
                this.ya.ed();
            }
            this.r8(true);
            if (a == 0 || a == 2 || a == 3 || a == 4) {
                this.abp = true;
            }
            else if (a == 1) {
                for (let f = b; f < b + c; f++) {
                    let g = 0;
                    g += this.yl.item(f);
                    g += this.ym.item(f);
                    g += this.yk.item(f);
                    this.abq += g / 3;
                }
                this.abr = this.abq / this.yl.count;
            }
        }
        b3() {
            if (this.b4 == 0) {
                return 1;
            }
            else {
                return super.b3();
            }
        }
        w8(a) {
            if (this.xt == null || this.xt.k.count == 0) {
                return Rect.empty;
            }
            let b = this.wr(a);
            let c = this.cw.ca;
            let d = this.cw.b9;
            let e = this.getEffectiveViewport1(this.cw);
            let f = this.an(this.xr, this.xt.k, this.zo(this.cw), this.zq(this.cw), a, true);
            let g = f[0];
            let h = f[1];
            let i = Math.abs(b.x - g[0]);
            let j = Math.abs(b.x - h[0]);
            let k = this.abs(this.x8, e);
            k = Math.max(k, 3);
            let l = (k - 1) / 2;
            if (i < j) {
                let m = g[0] - l;
                let n = g[0];
                let o = g[0] + l;
                let p = g[1];
                let q = g[2];
                let r = g[3];
                let s = g[4];
                let t = Math.min(Math.min(Math.min(p, q), r), s);
                let u = Math.max(Math.max(Math.max(p, q), r), s);
                return new Rect(0, m, t, Math.abs(o - m), u - t);
            }
            else {
                let v = h[0] - l;
                let w = h[0];
                let x = h[0] + l;
                let y = h[1];
                let z = h[2];
                let aa = h[3];
                let ab = h[4];
                let ac = Math.min(Math.min(Math.min(y, z), aa), ab);
                let ad = Math.max(Math.max(Math.max(y, z), aa), ab);
                return new Rect(0, v, ac, Math.abs(x - v), ad - ac);
            }
        }
        abl(a, b) {
            let c = a[0] - b;
            let d = a[0];
            let e = a[0] + b;
            let f = a[1];
            let g = a[2];
            let h = a[3];
            let i = a[4];
            let j = Math.min(Math.min(Math.min(f, g), h), i);
            let k = Math.max(Math.max(Math.max(f, g), h), i);
            let l = Math.min(g, h);
            let m = Math.max(g, h);
            let n = Math.min(f, i);
            let o = Math.max(f, i);
            if (this.abo == 1) {
                let p = new Array(3);
                let q = new Rect(0, c, f, b, 0);
                let r = new Rect(0, d, i, b, 0);
                let s = new Rect(0, d, l, 0, m - l);
                p[0] = q;
                p[1] = r;
                p[2] = s;
                return p;
            }
            else {
                let t = new Array(2);
                let u = new Rect(0, d, l, 0, m - l);
                let v = new Rect(0, c, n, b * 2, o - n);
                t[0] = u;
                t[1] = v;
                return t;
            }
        }
        ao(a) {
            let b = new List$1(Rect.$, 0);
            let c = this.wr(a);
            let d = this.cw.ca;
            let e = this.cw.b9;
            let f = this.getEffectiveViewport1(this.cw);
            let g = this.an(this.xr, this.xt.k, this.zo(this.cw), this.zq(this.cw), a, true);
            let h = g[0];
            let i = g[1];
            let j = Math.abs(c.x - h[0]);
            let k = Math.abs(c.x - i[0]);
            let l = this.abs(this.x8, f);
            l = Math.max(l, 3);
            let m = (l - 1) / 2;
            if (j < k) {
                return this.abl(h, m);
            }
            else {
                return this.abl(i, m);
            }
        }
        g2(a, b) {
            if (this.g5(a, b)) {
                return true;
            }
            return false;
        }
        g5(a, b) {
            let c = this.w9(a);
            if (c.isEmpty) {
                return false;
            }
            let d = RectUtil.r(c, (this.il / 2) + this.i1(b));
            if (d.containsPoint(a)) {
                let e = this.ap(a);
                if (e != null) {
                    for (let f = 0; f < e.length; f++) {
                        let g = e[f];
                        let h = RectUtil.r(g, (this.il / 2) + this.i1(b));
                        if (h.containsPoint(a)) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
        rq(a, b, c, d) {
            switch (b) {
                case FinancialPriceSeries.$$p[4]:
                case FinancialPriceSeries.$$p[5]:
                case FinancialPriceSeries.$$p[6]:
                case FinancialPriceSeries.$$p[7]:
                case FinancialPriceSeries.$$p[1]:
                case FinancialPriceSeries.$$p[2]:
                case FinancialPriceSeries.$$p[9]:
                case FinancialPriceSeries.$$p[10]:
                    this.qu();
                    break;
                case FinancialSeries.$$p[14]:
                    this.abn.ct();
                    if (this.dc != null) {
                        this.dc.pq();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.abn.cl = CategoryTrendLineManagerFactory.a(this.abn.cl, this.xr, this.td, this, this.ds);
                    }
                    break;
            }
            super.rq(a, b, c, d);
            if (this.abn.cn && this.abn.cl != null && this.abn.cl.g$e(a, b, c, d)) {
                this.r8(false);
                this.q0();
            }
            switch (b) {
                case FinancialPriceSeries.$$p[3]:
                    if (this.td != null) {
                        this.acm();
                        this.s0();
                        this.xt.ac();
                        this.aaz(this.xt, this.abn);
                    }
                    this.q0();
                    break;
                case "ActualHighlightingMode":
                case "ActualSelectionMode":
                case "ActualFocusMode":
                    this.r8(true);
                    break;
                case "TrendLineBrush":
                    this.rw(b);
                    break;
                case "TrendLineType":
                    this.q0();
                    break;
                case FinancialSeries.$$p[10]:
                case FinancialPriceSeries.$$p[8]:
                    this.rj();
                    break;
            }
        }
        acm() {
            this.abn.cx();
            if (this.cv != null) {
                this.cv.cx();
            }
        }
        ay(a) {
            if (a != null && a == this.ya && this.ym != null && !isNaN_(this.ym.minimum) && this.yl != null && !isNaN_(this.yl.maximum)) {
                return new AxisRange(this.ym.minimum, this.yl.maximum);
            }
            return null;
        }
        az(a) {
            if (a.isEmpty && this.dc != null) {
                a = this.dc.yr;
            }
            if (this.ym == null || this.yl == null) {
                return null;
            }
            let b = this.w4(this.cw);
            let c = new ScalerParams(0, a, this.dc.y9, this.xr.dn, this.getEffectiveViewport());
            let d = (this.xr.f9(b.left, c));
            let e = (this.xr.f9(b.right, c));
            if (this.xr.dn) {
                let f = d;
                d = e;
                e = f;
            }
            let g = null;
            if (this.xr.dv) {
                g = this.xr;
                d = g.i$f(d);
                e = g.i$f(e);
            }
            else {
                d = Math.floor(d);
                e = Math.ceil(e);
            }
            d = Math.max(0, Math.min(this.ym.count - 1, d));
            e = Math.max(0, Math.min(this.ym.count - 1, e));
            let h = 1.7976931348623157E+308;
            let i = -1.7976931348623157E+308;
            for (let j = truncate(d); j <= truncate(e); j++) {
                let k = j;
                if (g != null) {
                    k = g.i$b._inner[j];
                }
                let l = this.ym.item(k);
                if (this.ym.mayContainUnknowns) {
                    if (isInfinity(l) || isNaN_(l)) {
                        continue;
                    }
                }
                let m = this.yl.item(k);
                if (this.yl.mayContainUnknowns) {
                    if (isInfinity(m) || isNaN_(m)) {
                        continue;
                    }
                }
                h = Math.min(h, l);
                i = Math.max(i, m);
            }
            let n = new AxisRange(h, i);
            n = this.ax(n, this.ya, a);
            return n;
        }
        i5() {
            return Series.i6(this.yn, typeCast(ISortingAxis_$type, this.xr));
        }
        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.w6(this.cw);
            if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
                if (this.xr != null) {
                    let g = new ScalerParams(0, e, e, this.xr.dn, f);
                    let h = this.xr.f6(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.ya != null && this.ym != null && this.yl != null && b < this.ym.count && b < this.yl.count) {
                    let i = new ScalerParams(0, e, e, this.ya.dn, f);
                    i.b = this.i5();
                    let j = this.ya.f6(this.ym.item(b), i);
                    let k = this.ya.f6(this.yl.item(b), i);
                    if (!isNaN_(j) && !isNaN_(k)) {
                        let l = Math.abs(j - k);
                        if (c.height < l) {
                            c.height = l;
                            c.y = Math.min(j, k);
                        }
                        else {
                            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.yn == null || this.yk == null || this.yl == null || this.ym == null) {
                d = false;
            }
            return d;
        }
        aax(a, b) {
            super.aax(a, b);
            let c = b.ca;
            let d = b.b9;
            let e = this.getEffectiveViewport1(b);
            let f = this.xr;
            let g = this.ya;
            let h = new ScalerParams(0, c, d, f.dn, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, g.dn, e);
                $ret.b = this.i5();
                return $ret;
            })());
            let j = this.xr.ag();
            let k = j[0];
            let l = j[1];
            a.k.clear();
            if (a.r != null) {
                a.r.clear();
            }
            a.s.clear();
            a.v.clear();
            let m = 0;
            let n = typeCast(ISortingAxis_$type, this.xr);
            if (n != null && (n.i$b == null || n.i$b.count != this.dp.count)) {
                return;
            }
            m = this.zi(c, d, e);
            let o = typeCast(FinancialPriceSeriesView.$, b);
            let p = this.ik;
            let q = b.cd.b;
            if (this.trendLineType != 0) {
                let r = new Array(this.dp.count);
                let s = 0;
                for (let t of fromEnum(this.y9)) {
                    r[s] = t;
                    s++;
                }
                if (this.abn.cn) {
                    this.abn.cl.prepareLineCore(a.v, this.trendLineType, boxArray$1(r), this.trendLinePeriod, (u) => this.xr.f6(u, h), (u) => this.ya.f6(u, 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 = p;
                        $ret.i = d;
                        $ret.h = e;
                        $ret.c = k;
                        $ret.b = l;
                        return $ret;
                    })()));
                }
            }
            if (b.aa.count > 0) {
                let u = new Array(this.dp.count);
                let v = 0;
                for (let w of fromEnum(this.y9)) {
                    u[v] = w;
                    v++;
                }
                a.i.clear();
                for (let x = 0; x < b.aa.count; x++) {
                    a.i.add(new List$1(Point_$type, 0));
                    let y = b.aa._inner[x];
                    y.prepareLineCore(a.i._inner[x], y.g$b, boxArray$1(u), y.g$f, (z) => this.xr.f6(z, h), (z) => this.ya.f6(z, 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 = p;
                        $ret.i = d;
                        $ret.h = e;
                        $ret.c = k;
                        $ret.b = l;
                        return $ret;
                    })()));
                }
            }
            let z = this.xr.f9(2, h) - this.xr.f9(1, h);
            for (let aa = b.cd.c; aa <= b.cd.d; ++aa) {
                let ab;
                let ac = aa * q;
                if (n == null) {
                    ab = b.cd.getBucket(aa);
                }
                else {
                    let ad = n.i$b._inner[aa];
                    ac = ad;
                    let ae = n.i$d(ad);
                    let af = this.yn.item(ad);
                    let ag = this.yl.item(ad);
                    let ah = this.ym.item(ad);
                    let ai = this.yk.item(ad);
                    let aj = af;
                    let ak = ag;
                    let al = ah;
                    let am = ai;
                    let an = ae;
                    while (aa < b.cd.d) {
                        ad = n.i$b._inner[aa + 1];
                        an = n.i$d(ad);
                        if (an - ae > z * p) {
                            break;
                        }
                        ac = ad;
                        aa++;
                        ak = Math.max(ak, this.yl.item(ad));
                        al = Math.min(al, this.ym.item(ad));
                        am = this.yk.item(ad);
                    }
                    let ao = NaN;
                    if (!isNaN_(ae)) {
                        ao = this.xr.f6(ae, h);
                    }
                    ab = [ao, aj, ak, al, am];
                }
                if (!isNaN_(ab[0])) {
                    if (n != null) {
                        ab[0] = ab[0] + m;
                    }
                    else {
                        ab[0] = f.f6(ab[0], h) + m;
                    }
                    ab[1] = g.f6(ab[1], i);
                    ab[2] = g.f6(ab[2], i);
                    ab[3] = g.f6(ab[3], i);
                    ab[4] = g.f6(ab[4], i);
                    if (n != null) {
                        if (a.r == null) {
                            a.r = new List$1(Number_$type, 0);
                        }
                        a.r.add(ac);
                    }
                    a.k.add(ab);
                }
            }
            return;
        }
        pi(a, b) {
            super.pi(a, b);
            let c = typeCast(FinancialPriceSeriesView.$, b);
            c.cr();
            if (a) {
                c.cm.count = 0;
            }
            if (c.cn && c.cl != null) {
                c.cl.g$h();
            }
        }
        s8(a, b) {
            super.s8(a, b);
            if (this.dc != null) {
                this.dc.pq();
            }
        }
        xg(a, b) {
            if (this.xr != null && this.xr.categoryMode == 0) {
                let c = this.getEffectiveViewport1(this.cw);
                let d = this.abs(this.x8, c) / 2;
                return new Thickness(1, d, 0, d, 0);
            }
            return super.xg(a, b);
        }
        get_ef() {
            return true;
        }
        aaz(a, b) {
            super.aaz(a, b);
            if (this.xr == null || this.ya == null) {
                return;
            }
            let c = false;
            if (b.cg(a)) {
                c = true;
                b.ci(a);
            }
            this.x0.a2(this, this.yz(), runOn(this, this.xj), this.zo(b), this.zq(b));
            let d = false;
            let e = this.x0.b;
            if (e != null) {
                d = true;
            }
            let f = typeCast(FinancialPriceSeriesView.$, b);
            f.cq();
            f.co = false;
            if (f.cn) {
                f.cl.g$h();
            }
            if (this.trendLineType != 0) {
                f.cl.g$k(a.v);
            }
            if (b.aa.count > 0 && b.aa.count == a.i.count) {
                for (let g = 0; g < b.aa.count; g++) {
                    let h = b.aa._inner[g];
                    h.g$k(a.i._inner[g]);
                }
            }
            if (d) {
                this.ack(a, b, c);
            }
            else {
                f.cm.count = 0;
                this.acj(a, b);
            }
        }
        i3() {
            let a = this.getEffectiveViewport1(this.cw);
            return this.abs(this.x8, a);
        }
        ack(a, b, c) {
            let d = this.abo;
            let e = this.getEffectiveViewport1(b);
            let f = this.abs(b, e);
            let g = (f - 1) / 2;
            let h = typeCast(ISortingAxis_$type, this.xr) !== null;
            let i = typeCast(FinancialPriceSeriesView.$, b);
            i.co = true;
            let j = a.k;
            let k = 0;
            let l = this.dp.count;
            let m = this.xr;
            let n = new ScalerParams(0, b.ca, b.b9, m.dn, e);
            let o = this.vt;
            let p = this.abh;
            if (p == null) {
                p = o;
            }
            let q = this.vx;
            let r = this.ac7;
            if (r == null) {
                r = q;
            }
            for (let s = 0; s < j.count; ++s) {
                let t = j._inner[s][0] - g;
                let u = j._inner[s][0];
                let v = j._inner[s][0] + g;
                let w = j._inner[s][1];
                let x = j._inner[s][2];
                let y = j._inner[s][3];
                let z = j._inner[s][4];
                if (isNaN_(w) || isNaN_(x) || isNaN_(y) || isNaN_(z)) {
                    continue;
                }
                let aa = i.cm.item(k);
                k++;
                let ab = w < z;
                let ac = new PathGeometry();
                if (c) {
                    switch (d) {
                        case 0:
                            if (ab) {
                                let ad = w;
                                w = z;
                                z = ad;
                            }
                            let ae = new PathFigure();
                            ae._startPoint = { $type: Point_$type, x: u, y: y };
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: w };
                                return $ret;
                            })()));
                            let af = new PathFigure();
                            af._startPoint = { $type: Point_$type, x: t, y: z };
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: z };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: w };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: w };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: z };
                                return $ret;
                            })()));
                            let ag = new PathFigure();
                            ag._startPoint = { $type: Point_$type, x: u, y: z };
                            ag._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: x };
                                return $ret;
                            })()));
                            ac.c.add(ae);
                            ac.c.add(af);
                            ac.c.add(ag);
                            break;
                        case 1:
                            let ah = new PathFigure();
                            ah._startPoint = { $type: Point_$type, x: t, y: w };
                            ah._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: w };
                                return $ret;
                            })()));
                            let ai = new PathFigure();
                            ai._startPoint = { $type: Point_$type, x: u, y: y };
                            ai._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: x };
                                return $ret;
                            })()));
                            let aj = new PathFigure();
                            aj._startPoint = { $type: Point_$type, x: u, y: z };
                            aj._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: z };
                                return $ret;
                            })()));
                            ac.c.add(ah);
                            ac.c.add(ai);
                            ac.c.add(aj);
                            break;
                    }
                }
                if (ab) {
                    this.x0.ak = p;
                    this.x0.ag = p;
                    this.x0.ah = r;
                    this.x0.al = r;
                    this.x0.f = true;
                }
                else {
                    this.x0.ak = o;
                    this.x0.ag = o;
                    this.x0.ah = q;
                    this.x0.al = q;
                    this.x0.f = false;
                }
                let ak = this.x0.aw(l, s)[0];
                if (h && a.r != null && s >= 0 && s < a.r.count) {
                    ak = truncate(Math.round(a.r._inner[s]));
                }
                this.aaw(j, s, l, m, n, b.t, ak);
                if (d == 1) {
                    this.x0.ad(aa, true, false, false, false);
                }
                else {
                    this.x0.ad(aa, false, false, false, false);
                }
                if (c) {
                    aa.an = ac;
                }
            }
            i.cm.count = k;
            i.cs();
        }
        abs(a, b) {
            let c = this.xr.pz(a.ca, a.b9, b);
            c = Math.max(c, this.ik * 0.9);
            c = Math.max(c, 3);
            return c;
        }
        acj(a, b) {
            let c = this.abo;
            let d = this.getEffectiveViewport1(b);
            let e = this.abs(b, d);
            let f = (e - 1) / 2;
            let g = typeCast(FinancialPriceSeriesView.$, b);
            let h = g.c0();
            let i = g.cz();
            let j = a.k;
            for (let k = 0; k < j.count; ++k) {
                let l = j._inner[k][0] - f;
                let m = j._inner[k][0];
                let n = j._inner[k][0] + f;
                let o = j._inner[k][1];
                let p = j._inner[k][2];
                let q = j._inner[k][3];
                let r = j._inner[k][4];
                if (isNaN_(o) || isNaN_(p) || isNaN_(q) || isNaN_(r)) {
                    continue;
                }
                let s = o < r;
                let t = s ? i : h;
                switch (c) {
                    case 0:
                        if (s) {
                            let u = o;
                            o = r;
                            r = u;
                        }
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: q };
                            $ret.c = { $type: Point_$type, x: m, y: o };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new RectangleGeometry();
                            $ret.e = new Rect(0, l, r, n - l, o - r);
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: r };
                            $ret.c = { $type: Point_$type, x: m, y: p };
                            return $ret;
                        })()));
                        break;
                    case 1:
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: l, y: o };
                            $ret.c = { $type: Point_$type, x: m, y: o };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: q };
                            $ret.c = { $type: Point_$type, x: m, y: p };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: r };
                            $ret.c = { $type: Point_$type, x: n, y: r };
                            return $ret;
                        })()));
                        break;
                }
            }
        }
        k6(a, b) {
            if (this.abn.cn && a == this.abn.cl.g$n) {
                return null;
            }
            return super.k6(a, b);
        }
        sz() {
            super.sz();
            if (this.index < 0) {
                return;
            }
            this.abn.cy();
        }
        qd(a) {
            super.qd(a);
            if (this.abn.cn) {
                this.bc.exportTrendlineData(this, a, this.abn.cl.g$n);
            }
        }
        wh() {
            return this.ac7;
        }
        sl(a, b) {
            super.sl(a, b);
            this.ac7 = b;
        }
        bf(a) {
            if (this.abo == 0) {
                return 3;
            }
            else if (this.abo == 1) {
                if (this.be == 1) {
                    return 3;
                }
                return 2;
            }
            return a;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.jb(c, false, false);
            let e = this.i9(c, false, false);
            let f = new DataLegendSeriesValueInfo();
            f.a = 4;
            f.l = this.zj(c, false, false);
            f.q = "Close";
            f.r = this.zv != null ? this.zv : "Close";
            f.s = this.abw != null ? this.abw : "C:";
            f.t = this.aby != null ? this.aby : "";
            let g = new DataLegendSeriesValueInfo();
            g.l = this.zk(c, false, false);
            g.a = 3;
            g.q = "Open";
            g.r = this.aah != null ? this.aah : "Open";
            g.s = this.aca != null ? this.aca : "O:";
            g.t = this.acc != null ? this.acc : "";
            g.k = true;
            let h = new DataLegendSeriesValueInfo();
            h.l = (f.l - g.l) / g.l * 100;
            h.l = round10N(h.l, 1);
            h.a = 9;
            h.q = "Change";
            h.r = "Change";
            h.s = "";
            h.v = "";
            h.x = "+";
            h.w = "%";
            h.y = "%";
            h.t = null;
            h.c = false;
            h.k = true;
            h.e = false;
            h.f = true;
            h.h = false;
            h.g = false;
            h.d = false;
            h.n = 1;
            h.m = 1;
            g.z = h.l >= 0 ? this.vt : this.abh;
            f.z = h.l >= 0 ? this.vt : this.abh;
            h.z = h.l >= 0 ? this.vt : this.abh;
            let i = new DataLegendSeriesValueInfo();
            i.l = e > d ? d : e;
            i.a = 1;
            i.q = "Low";
            i.r = this.aad != null ? this.aad : "Low";
            i.s = this.ab5 != null ? this.ab5 : "L:";
            i.t = this.ab7 != null ? this.ab7 : "";
            i.k = true;
            let j = new DataLegendSeriesValueInfo();
            j.l = e > d ? e : d;
            j.a = 2;
            j.q = "High";
            j.r = this.z8 != null ? this.z8 : "High";
            j.s = this.ab1 != null ? this.ab1 : "H:";
            j.t = this.ab3 != null ? this.ab3 : "";
            j.k = true;
            let k = new DataLegendSeriesValueInfo();
            k.l = (j.l + i.l + f.l) / 3;
            k.l = round10N(k.l, 2);
            k.a = 5;
            k.q = "TypicalPrice";
            k.r = "TypicalPrice";
            k.s = "TP:";
            k.t = "";
            k.k = true;
            let l = new DataLegendSeriesValueInfo();
            l.l = this.zl(c, false, false);
            l.a = 8;
            l.q = "Volume";
            l.r = this.aal != null ? this.aal : "Volume";
            l.s = "VOL:";
            l.t = "";
            l.k = true;
            l.n = 0;
            l.m = 0;
            l.e = false;
            l.f = false;
            l.h = false;
            let m = new List$1(DataLegendSeriesValueInfo.$, 0);
            m.add(g);
            m.add(j);
            m.add(i);
            m.add(f);
            m.add(k);
            m.add(h);
            m.add(l);
            let n = new DataLegendSeriesContext();
            n.h = this.mn();
            n.e = m;
            return n;
        }
        acl() {
            if (this.abp) {
                this.abq = 0;
                for (let a = 0; a < this.yl.count; a++) {
                    let b = 0;
                    b += this.yl.item(a);
                    b += this.ym.item(a);
                    b += this.yk.item(a);
                    this.abq += b / 3;
                }
                this.abr = this.abq / this.yl.count;
                this.abp = false;
            }
        }
        aq(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.yl.maximum;
                    break;
                case 1:
                    b = this.ym.minimum;
                    break;
                case 3:
                    if (this.abp) {
                        this.acl();
                    }
                    b = this.abr;
                    break;
            }
            let c = this.ya;
            if (c.dy) {
                return [NaN, b];
            }
            else {
                return [b, NaN];
            }
        }
        wz(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.yl.maximum;
                    break;
                case 1:
                    b = this.ym.minimum;
                    break;
                case 3:
                    if (this.abp) {
                        this.acl();
                    }
                    b = this.abr;
                    break;
            }
            if (isNaN_(b)) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let c = this.ya;
            let d = this.getEffectiveViewport1(this.cw);
            let e = new ScalerParams(0, this.cw.ca, this.cw.b9, c.dn, d);
            if (c.dy) {
                e.b = this.i5();
            }
            e.c = d;
            if (c.dy) {
                return { $type: Point_$type, x: NaN, y: c.f6(b, e) };
            }
            else {
                return { $type: Point_$type, x: c.f6(b, e), y: NaN };
            }
        }
        w0(a) {
            let b = this.ya;
            let c = this.getEffectiveViewport1(this.cw);
            let d = new ScalerParams(0, this.cw.ca, this.cw.b9, b.dn, c);
            if (b.dy) {
                d.b = this.i5();
            }
            d.c = c;
            if (b.dy) {
                return { $type: Point_$type, x: NaN, y: b.f6(a[1], d) };
            }
            else {
                return { $type: Point_$type, x: b.f6(a[0], d), y: NaN };
            }
        }
        ak(a, b) {
            let c = new List$1(ChartSelection.$, 0);
            this.qi(a, c, b);
            return c.toArray();
        }
        qi(a, b, c) {
            let d = this.dc.y6(this.dc.yw(a));
            let e = this.ya;
            let f = this.xr;
            let g = this.dc.yz(this.xd, this.getEffectiveViewport(), d);
            let h, i;
            let j = this.acg(d, f, true, g, h, i);
            h = j.p4;
            i = j.p5;
            if (this.abm == 0) {
                this.aci(b, h, i, c);
            }
            else {
                let k, l;
                let m = this.acf(d, e, true, g, k, l);
                k = m.p4;
                l = m.p5;
                this.ach(1, b, h, i, k, l, c);
            }
        }
        acg(a, b, c, d, e, f) {
            let g = new ScalerParams(0, a, this.dc.y9, this.xr.dn, this.getEffectiveViewport());
            let h = (this.xr.f9(d.left, g));
            let i = (this.xr.f9(d.right, g));
            if (this.xr.dn) {
                let j = h;
                h = i;
                i = j;
            }
            if (this.xr.dv) {
                let k = this.xr;
                h = k.i$f(h);
                i = k.i$f(i);
            }
            else {
                h = Math.floor(h);
                i = Math.ceil(i);
            }
            e = truncate(Math.max(0, Math.min(this.ym.count - 1, h)));
            f = truncate(Math.max(0, Math.min(this.ym.count - 1, i)));
            return {
                p4: e,
                p5: f
            };
        }
        acf(a, b, c, d, e, f) {
            let g = new ScalerParams(0, a, this.dc.y9, b.dn, this.getEffectiveViewport());
            let h = c ? (b.dn ? d.top : d.bottom) : (b.dn ? d.left : d.right);
            let i = c ? (b.dn ? d.bottom : d.top) : (b.dn ? d.right : d.left);
            e = b.f9(h, g);
            f = b.f9(i, g);
            return {
                p4: e,
                p5: f
            };
        }
        ace(a, b, c) {
            if (c == 2 || c == 1) {
                a.add(((() => {
                    let $ret = new ChartSelection();
                    $ret.item = this.dp.item(b);
                    return $ret;
                })()));
            }
            else {
                a.add(((() => {
                    let $ret = new ChartSelection();
                    $ret.item = this.dp.item(b);
                    $ret.series = this;
                    return $ret;
                })()));
            }
        }
        aci(a, b, c, d) {
            if (b == -1 || c == -1) {
                return;
            }
            if (d == 7 || d == 6) {
                a.add(((() => {
                    let $ret = new ChartSelection();
                    $ret.series = this;
                    return $ret;
                })()));
                return;
            }
            for (let e = b; e <= c; e++) {
                this.ace(a, e, d);
            }
        }
        ach(a, b, c, d, e, f, g) {
            if (c == -1 || d == -1) {
                return;
            }
            for (let h = c; h <= d; h++) {
                let i = Math.min(this.yn.item(h), this.ym.item(h));
                let j = Math.max(this.yk.item(h), this.yl.item(h));
                let k = Math.min(i, j);
                let l = Math.max(i, j);
                if (k < f && e < l) {
                    if (g == 7 || g == 6) {
                        b.add(((() => {
                            let $ret = new ChartSelection();
                            $ret.series = this;
                            return $ret;
                        })()));
                        return;
                    }
                    this.ace(b, h, g);
                }
            }
        }
        bd() {
            return CategoryTrendLineManagerFactory.a(null, this.xr, null, null, this.ds);
        }
        qr() {
            super.qr();
            if (this.abn.cn) {
                this.abn.cl.g$m();
            }
        }
    }
    FinancialPriceSeries.$t = markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.acn = DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
    FinancialPriceSeries.$$p = markDep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['CategoryCollisionMode:abm:aco', [CategoryCollisionMode_$type, enumGetBox(CategoryCollisionMode_$type, 0)], 'CloseMemberAsLegendLabel:abw:acp', [2, null], 'CloseMemberAsLegendUnit:aby:acq', [2, null], 'DisplayType:abo:acr', [PriceDisplayType_$type, enumGetBox(PriceDisplayType_$type, 0)], 'HighMemberAsLegendLabel:ab1:acs', [2, null], 'HighMemberAsLegendUnit:ab3:act', [2, null], 'LowMemberAsLegendLabel:ab5:acu', [2, null], 'LowMemberAsLegendUnit:ab7:acv', [2, null], 'NegativeOutline:ac7:acw', [Brush.$, null], 'OpenMemberAsLegendLabel:aca:acx', [2, null], 'OpenMemberAsLegendUnit:acc:acy', [2, null], 'TrendLineType::ac4', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ac3', [1, 1.5], 'TrendLinePeriod::ac2', [1, 7], 'TrendLineBrush::acz', [Brush.$, null], 'TrendLineZIndex:abu:ac5', [1, 1001], 'TrendLineDashArray:ac8:ac0', [DoubleCollection.$], 'TrendLineDashCap:ac9:ac1', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
    return FinancialPriceSeries;
})();
/**
 * @hidden
 */
export let FinancialPriceSeriesView = /*@__PURE__*/ (() => {
    class FinancialPriceSeriesView extends FinancialSeriesView {
        constructor(a) {
            super(a);
            this.cj = null;
            this.cm = null;
            this.cp = null;
            this.c3 = ((() => {
                let $ret = new Path();
                $ret.an = new GeometryGroup();
                return $ret;
            })());
            this.c2 = ((() => {
                let $ret = new Path();
                $ret.an = new GeometryGroup();
                return $ret;
            })());
            this.ck = null;
            this.c1 = new Path();
            this.co = false;
            this.cj = a;
            this.cp = new List$1(Path.$, 0);
            this.cm = ((() => {
                let $ret = new Pool$1(Path.$);
                $ret.create = runOn(this, this.c4);
                $ret.activate = runOn(this, this.cu);
                $ret.disactivate = runOn(this, this.cw);
                $ret.destroy = runOn(this, this.cv);
                return $ret;
            })());
        }
        c4() {
            let a = new Path();
            this.cp.add(a);
            a._visibility = 1;
            return a;
        }
        cu(a) {
            a._visibility = 0;
        }
        cw(a) {
            a._visibility = 1;
        }
        cv(a) {
            this.cp.remove(a);
        }
        ce() {
            return new FinancialPriceBucketCalculator(this);
        }
        a4() {
            super.a4();
            if (!this.t) {
                this.cj.abo = Defaults.g;
                this.cj.abh = Defaults.financialSeries_NegativeBrush;
                this.cj.ac7 = Defaults.financialSeries_NegativeOutline;
                this.cj.jy = Defaults.financialSeries_Thickness;
                this.cj.wf = this.cj.vx;
            }
        }
        get cl() {
            if (this.ck == null) {
                this.ck = CategoryTrendLineManagerFactory.a(this.ck, this.f.a0(), this.f.td, this.f, this.f.ds);
            }
            return this.ck;
        }
        set cl(a) {
            this.ck = a;
        }
        get cn() {
            return this.ck != null;
        }
        cx() {
            if (this.cj.abo == 1) {
                this.c3._stroke = this.f.vt;
            }
            else {
                this.c3._stroke = this.f.vx;
            }
            if (this.cj.abo == 1) {
                this.c2._stroke = this.cf.abh;
            }
            else {
                this.c2._stroke = this.cj.ac7;
            }
        }
        cr() {
            this.a2();
            this.cm.count = 0;
            this.cq();
        }
        cq() {
            let a = typeCast(GeometryGroup.$, this.c3.an);
            let b = typeCast(GeometryGroup.$, this.c2.an);
            Extensions.d(a);
            Extensions.d(b);
        }
        c0() {
            this.a2();
            return typeCast(GeometryGroup.$, this.c3.an);
        }
        cz() {
            this.a2();
            return typeCast(GeometryGroup.$, this.c2.an);
        }
        cy() {
            this.cj.ac6 = null;
            if (this.cj.trendLineBrush != null) {
                this.cj.ac6 = this.cj.trendLineBrush;
            }
            else {
                this.cj.ac6 = this.cj.vt;
            }
        }
        bp() {
            super.bp();
            this.c3.ad = this.f.il;
            this.c3.ai = this.f.wm;
            this.c3.aj = this.f.wn;
            if (this.cj.abo == 1) {
                this.c3._stroke = this.f.vt;
            }
            else {
                this.c3._stroke = this.f.vx;
                this.c3._fill = this.f.vt;
            }
            this.c2.ad = this.f.il;
            this.c2.ai = this.f.wm;
            this.c2.aj = this.f.wn;
            if (this.cj.abo == 1) {
                this.c2._stroke = this.cf.abh;
            }
            else {
                this.c2._stroke = this.cj.ac7;
                this.c2._fill = this.cf.abh;
            }
        }
        bq() {
            super.bq();
            let a = this.b3();
            this.c3.ad = this.f.il + 3;
            if (this.cj.abo == 1) {
                this.c3._stroke = a;
            }
            else {
                this.c3._stroke = a;
                this.c3._fill = a;
            }
            this.c2.ad = this.f.il + 3;
            if (this.cj.abo == 1) {
                this.c2._stroke = a;
            }
            else {
                this.c2._stroke = a;
                this.c2._fill = a;
            }
        }
        ak(a) {
            return this.cp._inner[a];
        }
        aj(a) {
            let b = this.cp._inner[a];
            this.c1._visibility = b._visibility;
            this.c1.an = b.an;
            let c = this.b4(a);
            this.c1._fill = c;
            this.c1._stroke = c;
            this.c1.ad = this.f.il + 3;
            return this.c1;
        }
        bj(a, b) {
            super.bj(a, b);
            if (a.d) {
                if (this.co) {
                    for (let c = 0; c < this.cp.count; c++) {
                        let d = this.ai(c, b);
                        if (d._visibility == 0) {
                            a.t(d);
                        }
                    }
                }
                else {
                    a.t(this.c3);
                    a.t(this.c2);
                }
            }
        }
        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.ac6;
                    c.ai = this.cj.ac8;
                    c.aj = this.cj.ac9;
                    a.v(c);
                }
            }
            super.bi(a, b);
        }
        ax(a) {
            super.ax(a);
            if (this.cj.yz()) {
                for (let b = 0; b < this.cp.count; b++) {
                    let c = this.cp._inner[b];
                    if (c._fill == this.cj.abh) {
                        this.f.bc.exportPathData(a, c, "negativePathShape" + b, ["Negative"]);
                    }
                    else {
                        this.f.bc.exportPathData(a, c, "positivePathShape" + b, ["Positive", "Main"]);
                    }
                }
            }
            else {
                this.f.bc.exportPathData(a, this.c3, "positivePathShape", ["Positive", "Main"]);
                this.f.bc.exportPathData(a, this.c2, "negativePathShape", ["Negative"]);
            }
        }
        cs() {
            this.a2();
        }
        ct() {
            if (this.cn) {
                this.ck = CategoryTrendLineManagerFactory.a(this.ck, this.f.a0(), this.f.td, this.f, this.f.ds);
            }
        }
    }
    FinancialPriceSeriesView.$t = markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
})();