UNPKG

igniteui-react-charts

Version:

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

673 lines (672 loc) 25.7 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 { Series } from "./Series"; import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference"; import { Axis } from "./Axis"; import { DependencyProperty } from "igniteui-react-core"; import { CategoryAxisBase } from "./CategoryAxisBase"; import { Point_$type, typeCast, Delegate_$type, enumGetBox, markType, markDep, runOn } from "igniteui-react-core"; import { Brush } from "igniteui-react-core"; import { Thickness } from "igniteui-react-core"; import { OverlayTextLocation_$type } from "./OverlayTextLocation"; import { AnnotationAppearanceMode_$type } from "./AnnotationAppearanceMode"; import { OverlayTextUtil } from "./OverlayTextUtil"; import { List$1 } from "igniteui-react-core"; import { Dictionary$2 } from "igniteui-react-core"; import { Pool$1 } from "igniteui-react-core"; import { AxisAnnotation } from "./AxisAnnotation"; import { SeriesView } from "./SeriesView"; import { Rect } from "igniteui-react-core"; import { NotImplementedException } from "igniteui-react-core"; import { AxisRange } from "./AxisRange"; import { NumericAxisBase } from "./NumericAxisBase"; import { AxisAnnotationFrame } from "./AxisAnnotationFrame"; import { ScalerParams } from "./ScalerParams"; import { CategoryXAxis } from "./CategoryXAxis"; import { OverlayTextUpdatingEventArgs } from "./OverlayTextUpdatingEventArgs"; import { AxisAnnotationFramePrepareSettings } from "./AxisAnnotationFramePrepareSettings"; import { OverlayTextInfo } from "./OverlayTextInfo"; import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager"; import { TextBlock } from "igniteui-react-core"; import { Rectangle } from "igniteui-react-core"; import { PropertyMetadata } from "igniteui-react-core"; import { DeviceUtils } from "igniteui-react-core"; import { dateMinValue } from "igniteui-react-core"; import { isNaN_, isInfinity } from "igniteui-react-core"; import { stringIsNullOrEmpty } from "igniteui-react-core"; import { stringFormat } from "igniteui-react-core"; import { Path } from "igniteui-react-core"; /** * @hidden */ export let ValueOverlay = /*@__PURE__*/ (() => { class ValueOverlay extends Series { bk() { return new ValueOverlay(); } constructor() { super(); this.ym = 0; this.yo = 0; this.x9 = 0; this.xn = null; this.x1 = null; this.x0 = null; this.stylingOverlayText = null; this.xs = null; this.ab = ValueOverlay.$; this.xs = OverlayTextUtil.c(); } jd(a, b, c) { return this.yn(); } yn() { if (+(this.x2) != +(dateMinValue())) { return this.x2.getTime(); } return this.yp; } ya(a, b) { let c = Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2)); let d = Math.acos((a.x - b.x) / c); if ((a.y - b.y) < 0) { d = (2 * Math.PI) - d; } return d; } ww(a, b, c) { if (this.xm == null) { return { $type: Point_$type, x: NaN, y: NaN }; } let d = this.yl(); let e = NaN; let f = NaN; let g = NaN; let h = { $type: Point_$type, x: 0.5, y: 0.5 }; let i = NaN; switch (this.xm.bm) { case 2: i = Math.sqrt(Math.pow(a.x - h.x, 2) + Math.pow(a.y - h.y, 2)); g = d; e = h.x + Math.cos(g) * i; f = h.y + Math.sin(g) * i; f = this.cw.b9.top + this.cw.b9.height * (f - this.cw.ca.top) / this.cw.ca.height; e = this.cw.b9.left + this.cw.b9.width * (e - this.cw.ca.left) / this.cw.ca.width; break; case 0: e = d; f = a.y; f = this.cw.b9.top + this.cw.b9.height * (f - this.cw.ca.top) / this.cw.ca.height; break; case 1: f = d; e = a.x; e = this.cw.b9.left + this.cw.b9.width * (e - this.cw.ca.left) / this.cw.ca.width; break; case 3: g = this.ya(a, h); i = d; e = h.x + Math.cos(g) * i; f = h.y + Math.sin(g) * i; f = this.cw.b9.top + this.cw.b9.height * (f - this.cw.ca.top) / this.cw.ca.height; e = this.cw.b9.left + this.cw.b9.width * (e - this.cw.ca.left) / this.cw.ca.width; break; } return { $type: Point_$type, x: e, y: f }; } kc(a) { throw new NotImplementedException(0); } kw(a) { return this; } gj(a) { return false; } ay(a) { let b = typeCast(NumericAxisBase.$, a); let c = this.yn(); if (isNaN_(c) || isInfinity(c)) { return null; } return new AxisRange(c, c); } r9(a) { this.pi(true, this.cw); if (!this.xz()) { if (this.xn != null) { this.zy(NaN, this.d4()); } return; } if (this.gl(a)) { if (this.d4()) { if (this.dd.g) { this.dd.t(); } let b = this.ym; this.ym = this.yo; this.yo = b; } else { this.ym = this.x9; } this.x9 = this.yl(); this.sp(); } else { this.x9 = this.yl(); this.zx(this.x9, this.xr); } } yl() { let a, b; let c = this.getViewInfo(b, a); b = c.p0; a = c.p1; let d = this.getEffectiveViewport1(this.cw); let e = new ScalerParams(0, a, b, this.xm.dn, d); return this.xm.f6(this.yn(), e); } zx(a, b) { if (this.xm == null) { return; } let c = typeCast(CategoryAxisBase.$, this.xm); if (c != null && !c.dj) { if (this.yn() > c.qb - 1) { return; } if (c.categoryMode != 0) { let d = this.getEffectiveViewport1(b); let e = 0.5 * c.getCategorySize(b.ca, b.b9, d); let f = false; if (c.dy && !c.dn) { f = true; } if (typeCast(CategoryXAxis.$, c) !== null && c.dn) { f = true; } if (f) { e = -e; } a += e; } } let g = typeCast(NumericAxisBase.$, this.xm); if (g != null) { if (this.yn() < g.qw || this.yn() > g.qv) { return; } if (g.qh && this.yn() < 0) { return; } } let h; switch (this.xm.bm) { case 2: case 3: h = this.xm.ov(a, b.ca, b.b9, this.getEffectiveViewport1(b), this.w4(b)); break; default: h = this.xm.ov(a, b.ca, b.b9, this.getEffectiveViewport1(b), this.w4(b)); break; } if (h != null) { b.cp(h); } if (!b.t) { this.zy(a, this.d4()); } } hk(a, b, c) { let d = true; d = super.hk(a, b, c); if (!c.r() || b.isEmpty || a.isEmpty || this.xm == null || this.xm.b7 == null) { d = false; } return d; } s9(a, b) { this.r8(false); } s8(a, b) { this.r8(false); } po(a, b, c, d) { throw new NotImplementedException(0); } rq(a, b, c, d) { super.rq(a, b, c, d); switch (b) { case ValueOverlay.$$p[11]: if (c != null) { c.cx(this); } if (d != null) { d.d3(this); } this.r8(false); this.q0(); break; case "TransitionProgress": this.yo = this.ym + this.jz * (this.x9 - this.ym); if (this.d7(this.cw)) { return; } if (this.jz == 1) { this.zx(this.x9, this.xr); this.q3(); } else { this.zx(this.yo, this.xr); } if (this.dc != null) { this.dc.st(this); } break; case ValueOverlay.$$p[12]: case ValueOverlay.$$p[36]: let e = typeCast(NumericAxisBase.$, this.xm); if (e != null) { e.ed(); } this.r8(true); this.q1(); break; case ValueOverlay.$$p[13]: case ValueOverlay.$$p[10]: case ValueOverlay.$$p[1]: case ValueOverlay.$$p[0]: case ValueOverlay.$$p[3]: case ValueOverlay.$$p[4]: case ValueOverlay.$$p[9]: case ValueOverlay.$$p[5]: case ValueOverlay.$$p[6]: case ValueOverlay.$$p[7]: case ValueOverlay.$$p[8]: this.r8(true); break; case ValueOverlay.$$p[32]: case ValueOverlay.$$p[35]: case ValueOverlay.$$p[31]: case ValueOverlay.$$p[14]: case ValueOverlay.$$p[25]: case ValueOverlay.$$p[26]: case ValueOverlay.$$p[28]: case ValueOverlay.$$p[27]: case ValueOverlay.$$p[15]: case ValueOverlay.$$p[16]: case ValueOverlay.$$p[18]: case ValueOverlay.$$p[17]: case ValueOverlay.$$p[20]: case ValueOverlay.$$p[21]: case ValueOverlay.$$p[23]: case ValueOverlay.$$p[19]: case ValueOverlay.$$p[22]: case ValueOverlay.$$p[24]: case ValueOverlay.$$p[29]: case ValueOverlay.$$p[30]: case ValueOverlay.$$p[34]: case ValueOverlay.$$p[33]: this.r8(true); break; case "SeriesViewer": if (d == null) { if (this.x0 != null && this.x0.count > 0 && this.xn != null) { this.zy(NaN, this.d4()); } } break; } } qp() { super.qp(); if (this.xm != null) { this.xm.ly(false); } } pi(a, b) { super.pi(a, b); let c = b; c.ci(); } xz() { if (this.xm == null || this.xm.b7 == null || isNaN_(this.yn()) || this._visibility != 0) { return false; } let a = typeCast(CategoryAxisBase.$, this.xm); if (a != null && a.qb == 0) { return false; } return true; } preferredCategoryMode(a) { return 0; } get categoryAxis() { return typeCast(CategoryAxisBase.$, this.xm); } ct() { return new ValueOverlayView(this); } rh(a) { super.rh(a); this.xr = typeCast(ValueOverlayView.$, a); } sa(a, b) { super.sa(a, b); if (!this.g6) { this.cw.be(b); return; } this.cw.be(b); if (this.d7(this.cv) || !this.xz()) { return; } let c = this.getEffectiveViewport1(this.cw); let d = this.xm.f6(this.yn(), new ScalerParams(0, this.cv.ca, a, this.xm.dn, c)); this.zx(d, typeCast(ValueOverlayView.$, this.cv)); this.g6 = false; } getOffsetValue() { return 0; } getCategoryWidth() { return 0; } get aa6() { return new Thickness(1, this.x5, this.x7, this.x6, this.x4); } ai() { return [this.xm]; } zw() { if (OverlayTextUtil.q(this.xs)) { this.xs = OverlayTextUtil.c(); } else if (OverlayTextUtil.k(this.xs)) { this.xs = this.cw.l(this.xs.fontString); } } zy(a, b) { if (isNaN_(a)) { if (this.xn != null) { AxisAnnotationFrameManager.b(this.xn); AxisAnnotationFrameManager.d(this, this.xn, true, this.x0, this.x1, b, this.yq, this.yq, this.xo, this.xo); } return; } let c = false; if (this.x0 == null) { c = true; this.x1 = new List$1(Axis.$, 0); this.x0 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0); } this.xn = new AxisAnnotationFrame(); let d = this.vt; if (d == null) { d = this.vz; } this.xr.ch(); if (this.xm.bm == 0 || this.xm.bm == 1) { this.zw(); let e = this.xt; let f = OverlayTextUtil.o(e, this.xy); let g = this.xp; if (g == 18) { f = false; } if (f && !stringIsNullOrEmpty(this.y7)) { let h = this.xm.dy; let i = this.vt; let j = this.aa5; if (j == null && this.xx) { j = i; } let k = this.aa3; if (k == null && this.xv) { k = i; } let l = this.aa4; if (l == null && this.xw) { l = i; } let m = new OverlayTextUpdatingEventArgs(); m.textLocation = this.xp; m.textAngle = this.yb; m.textVisible = this.xy; m.textContent = this.y7; m.textColorMode = this.xl; m.textColorShift = this.yg; m.textColor = j; m.backgroundMode = this.xj; m.backgroundShift = this.yc; m.background = k; m.borderMode = this.xk; m.borderShift = this.ye; m.borderStroke = l; m.borderRadius = this.yd; m.borderThickness = this.yf; m.shapeBrush = this.vt; m.shapeOutline = this.vx; m.f = h; m.horizontalMargin = this.yh; m.verticalPadding = this.yk; m.verticalMargin = this.yj; m.horizontalPadding = this.yi; if (this.stylingOverlayText != null) { this.stylingOverlayText(this, m); } OverlayTextUtil.ad(m); let n = OverlayTextInfo.d(m); if (n.textVisible && !n.h) { this.xr.ce.count = 1; this.xr.cd.count = 1; n.f = e; n.ad = this.cw.cc(n.textContent, n.f); n.u = this.xr.ce.item(0); n.ac = this.xr.cd.item(0); if (n.g) { let o = this.dc.yj({ $type: Point_$type, x: 0, y: NaN }); let p = this.dc.yj({ $type: Point_$type, x: 1, y: NaN }); let q = p.x - o.x; n.ab = new Rect(0, o.x, a, q, 1); } else { let r = this.dc.yj({ $type: Point_$type, x: NaN, y: 0 }); let s = this.dc.yj({ $type: Point_$type, x: NaN, y: 1 }); let t = s.y - r.y; n.ab = new Rect(0, a, r.y, 1, t); } OverlayTextUtil.ac(n); this.cw.av(n.u, n.f); this.cw.aw(n.u, n.f); } } } let u = this.xm.dy; let v = new AxisAnnotationFramePrepareSettings(); v.u = this.aa0; v.y = this.aa2; v.x = this.aa1; v.g = this.x3; v.ae = this.aa6; v.l = this.x8; v.c = !u && this.xu; v.z = this.aa0; v.ad = this.aa2; v.ac = this.aa1; v.m = this.x3; v.af = this.aa6; v.r = this.x8; v.d = u && this.xu; AxisAnnotationFrameManager.c(this.xn, { $type: Point_$type, x: a, y: a }, this, this.dc, this.getEffectiveViewport(), d, v); AxisAnnotationFrameManager.d(this, this.xn, c, this.x0, this.x1, b, this.yq, this.yq, this.xo, this.xo); } get_isValueOverlay() { return true; } y4(a) { if (this.xm != null) { return this.xm.i8(a); } return null; } get y6() { let a = this.y4(this.yn()); return a != null ? a : stringFormat("{0:0.##}", this.yn()); } get xt() { return this.xs; } set xt(a) { let b = this.xs; if (OverlayTextUtil.q(a)) { a = OverlayTextUtil.c(); } this.xs = a; if (b != this.xs) { this.raisePropertyChanged("OverlayTextStyle", b, this.xs); } } } ValueOverlay.$t = /*@__PURE__*/ markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]); ValueOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:x3:zz', [1, /*@__PURE__*/ DeviceUtils.g(3)], 'AxisAnnotationBackground:aa0:z0', [Brush.$, null], 'AxisAnnotationFormatLabel:xo:z1', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:yq:z2', [1, -1], 'AxisAnnotationOutline:aa1:z3', [Brush.$, null], 'AxisAnnotationPaddingBottom:x4:z4', [1, NaN], 'AxisAnnotationPaddingLeft:x5:z5', [1, NaN], 'AxisAnnotationPaddingRight:x6:z6', [1, NaN], 'AxisAnnotationPaddingTop:x7:z7', [1, NaN], 'AxisAnnotationStrokeThickness:x8:z8', [1, NaN], 'AxisAnnotationTextColor:aa2:z9', [Brush.$, null], 'Axis:xm:aaa', [Axis.$, null], 'DateValue:x2:aab', [3, /*@__PURE__*/ dateMinValue()], 'IsAxisAnnotationEnabled:xu:aac', [0, false], 'OverlayTextAngle:yb:aad', [1, NaN], 'OverlayTextBackgroundMatchLayer:xv:aae', [0, false], 'OverlayTextBackgroundMode:xj:aaf', [AnnotationAppearanceMode_$type, /*@__PURE__*/ enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextBackground:aa3:aag', [Brush.$, null], 'OverlayTextBackgroundShift:yc:aah', [1, NaN], 'OverlayTextBorderColor:aa4:aai', [Brush.$, null], 'OverlayTextBorderMatchLayer:xw:aaj', [0, false], 'OverlayTextBorderMode:xk:aak', [AnnotationAppearanceMode_$type, /*@__PURE__*/ enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextBorderRadius:yd:aal', [1, NaN], 'OverlayTextBorderShift:ye:aam', [1, NaN], 'OverlayTextBorderThickness:yf:aan', [1, 1], 'OverlayTextColorMatchLayer:xx:aao', [0, true], 'OverlayTextColorMode:xl:aap', [AnnotationAppearanceMode_$type, /*@__PURE__*/ enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextColor:aa5:aaq', [Brush.$, null], 'OverlayTextColorShift:yg:aar', [1, NaN], 'OverlayTextHorizontalMargin:yh:aas', [1, NaN], 'OverlayTextHorizontalPadding:yi:aat', [1, NaN], 'OverlayTextLocation:xp:aau', [OverlayTextLocation_$type, /*@__PURE__*/ enumGetBox(OverlayTextLocation_$type, 0)], 'OverlayText:y7:aav', [2, null], 'OverlayTextVerticalMargin:yj:aaw', [1, NaN], 'OverlayTextVerticalPadding:yk:aax', [1, NaN], 'OverlayTextVisible:xy:aay', [0, true], 'Value:yp:aaz', [1, 0]]); return ValueOverlay; })(); /** * @hidden */ export let ValueOverlayView = /*@__PURE__*/ (() => { class ValueOverlayView extends SeriesView { constructor(a) { super(a); this.cr = null; this.cg = null; this.ce = null; this.cf = null; this.cd = null; this.cr = new Path(); } bp() { super.bp(); this.cr._stroke = this.f.vt; this.cr.ad = this.f.il; this.cr.ai = this.f.wm; this.cr.aj = this.f.wn; } bq() { super.bq(); let a = this.b3(); this.cr._stroke = a; this.cr.ad = this.f.il + 3; this.cr._stroke = a; this.cr.ad = this.f.il + 3; } cp(a) { this.cr.an = a; this.a2(); } ci() { this.cr.an = null; this.a2(); } bj(a, b) { super.bj(a, b); if (a.d) { a.t(this.cr); for (let c = 0; c < this.cd.count; c++) { let d = this.cd.item(c); if (d.j != null) { a.aa(); a.k(d.j); } if (d._visibility == 0) { a.w(d); } if (d.j != null) { a.z(); } } for (let e = 0; e < this.ce.count; e++) { let f = this.ce.item(e); if (f.j != null) { a.k(f.j); } a.af(f.dataContext); a.x(f); if (f.j != null) { } } } } ax(a) { super.ax(a); this.f.bc.exportPathData(a, this.cr, "ValueOverlayPath", []); } ch() { } a4() { super.a4(); this.cg = new List$1(TextBlock.$, 0); this.ce = ((() => { let $ret = new Pool$1(TextBlock.$); $ret.create = runOn(this, this.cq); $ret.activate = runOn(this, this.cm); $ret.disactivate = runOn(this, this.co); $ret.destroy = runOn(this, this.cn); return $ret; })()); this.cf = new List$1(Rectangle.$, 0); this.cd = ((() => { let $ret = new Pool$1(Rectangle.$); $ret.create = runOn(this, this.cs); $ret.activate = runOn(this, this.cj); $ret.disactivate = runOn(this, this.cl); $ret.destroy = runOn(this, this.ck); return $ret; })()); } cq() { let a = new TextBlock(); this.cg.add(a); return a; } cn(a) { if (this.cg.contains(a)) { this.cg.remove(a); } } cm(a) { a._visibility = 0; a.s = 0; } co(a) { a._visibility = 1; } cs() { let a = new Rectangle(); this.cf.add(a); return a; } ck(a) { a.dataContext = null; if (this.cf.contains(a)) { this.cf.remove(a); } } cj(a) { a._visibility = 0; } cl(a) { a._visibility = 1; } } ValueOverlayView.$t = /*@__PURE__*/ markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$); return ValueOverlayView; })();