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.yo = 0; this.yq = 0; this.yb = 0; this.xp = null; this.x3 = null; this.x2 = null; this.stylingOverlayText = null; this.xu = null; this.ab = ValueOverlay.$; this.xu = OverlayTextUtil.c(); } jf(a, b, c) { return this.yp(); } yp() { if (+(this.x4) != +(dateMinValue())) { return this.x4.getTime(); } return this.yr; } yc(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; } wy(a, b, c) { if (this.xo == null) { return { $type: Point_$type, x: NaN, y: NaN }; } let d = this.yn(); 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.xo.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.yc(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 }; } ke(a) { throw new NotImplementedException(0); } ky(a) { return this; } gl(a) { return false; } ay(a) { let b = typeCast(NumericAxisBase.$, a); let c = this.yp(); if (isNaN_(c) || isInfinity(c)) { return null; } return new AxisRange(c, c); } sb(a) { this.pk(true, this.cw); if (!this.x1()) { if (this.xp != null) { this.z0(NaN, this.d4()); } return; } if (this.gn(a)) { if (this.d4()) { if (this.dd.g) { this.dd.t(); } let b = this.yo; this.yo = this.yq; this.yq = b; } else { this.yo = this.yb; } this.yb = this.yn(); this.sr(); } else { this.yb = this.yn(); this.zz(this.yb, this.xt); } } yn() { 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.xo.dn, d); return this.xo.f7(this.yp(), e); } zz(a, b) { if (this.xo == null) { return; } let c = typeCast(CategoryAxisBase.$, this.xo); if (c != null && !c.dj) { if (this.yp() > c.qe - 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.dz && !c.dn) { f = true; } if (typeCast(CategoryXAxis.$, c) !== null && c.dn) { f = true; } if (f) { e = -e; } a += e; } } let g = typeCast(NumericAxisBase.$, this.xo); if (g != null) { if (this.yp() < g.qy || this.yp() > g.qx) { return; } if (g.qj && this.yp() < 0) { return; } } let h; switch (this.xo.bm) { case 2: case 3: h = this.xo.ox(a, b.ca, b.b9, this.getEffectiveViewport1(b), this.w6(b)); break; default: h = this.xo.ox(a, b.ca, b.b9, this.getEffectiveViewport1(b), this.w6(b)); break; } if (h != null) { b.cp(h); } if (!b.t) { this.z0(a, this.d4()); } } hm(a, b, c) { let d = true; d = super.hm(a, b, c); if (!c.r() || b.isEmpty || a.isEmpty || this.xo == null || this.xo.b7 == null) { d = false; } return d; } tb(a, b) { this.sa(false); } ta(a, b) { this.sa(false); } pq(a, b, c, d) { throw new NotImplementedException(0); } rs(a, b, c, d) { super.rs(a, b, c, d); switch (b) { case ValueOverlay.$$p[11]: if (c != null) { c.cx(this); } if (d != null) { d.d4(this); } this.sa(false); this.q2(); break; case "TransitionProgress": this.yq = this.yo + this.j1 * (this.yb - this.yo); if (this.d7(this.cw)) { return; } if (this.j1 == 1) { this.zz(this.yb, this.xt); this.q5(); } else { this.zz(this.yq, this.xt); } if (this.dc != null) { this.dc.sv(this); } break; case ValueOverlay.$$p[12]: case ValueOverlay.$$p[36]: let e = typeCast(NumericAxisBase.$, this.xo); if (e != null) { e.ee(); } this.sa(true); this.q3(); 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.sa(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.sa(true); break; case "SeriesViewer": if (d == null) { if (this.x2 != null && this.x2.count > 0 && this.xp != null) { this.z0(NaN, this.d4()); } } break; } } qr() { super.qr(); if (this.xo != null) { this.xo.l0(false); } } pk(a, b) { super.pk(a, b); let c = b; c.ci(); } x1() { if (this.xo == null || this.xo.b7 == null || isNaN_(this.yp()) || this._visibility != 0) { return false; } let a = typeCast(CategoryAxisBase.$, this.xo); if (a != null && a.qe == 0) { return false; } return true; } preferredCategoryMode(a) { return 0; } get categoryAxis() { return typeCast(CategoryAxisBase.$, this.xo); } ct() { return new ValueOverlayView(this); } rj(a) { super.rj(a); this.xt = typeCast(ValueOverlayView.$, a); } sc(a, b) { super.sc(a, b); if (!this.g8) { this.cw.be(b); return; } this.cw.be(b); if (this.d7(this.cv) || !this.x1()) { return; } let c = this.getEffectiveViewport1(this.cw); let d = this.xo.f7(this.yp(), new ScalerParams(0, this.cv.ca, a, this.xo.dn, c)); this.zz(d, typeCast(ValueOverlayView.$, this.cv)); this.g8 = false; } getOffsetValue() { return 0; } getCategoryWidth() { return 0; } get aa8() { return new Thickness(1, this.x7, this.x9, this.x8, this.x6); } ai() { return [this.xo]; } zy() { if (OverlayTextUtil.q(this.xu)) { this.xu = OverlayTextUtil.c(); } else if (OverlayTextUtil.k(this.xu)) { this.xu = this.cw.l(this.xu.fontString); } } z0(a, b) { if (isNaN_(a)) { if (this.xp != null) { AxisAnnotationFrameManager.b(this.xp); AxisAnnotationFrameManager.d(this, this.xp, true, this.x2, this.x3, b, this.ys, this.ys, this.xq, this.xq); } return; } let c = false; if (this.x2 == null) { c = true; this.x3 = new List$1(Axis.$, 0); this.x2 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0); } this.xp = new AxisAnnotationFrame(); let d = this.vv; if (d == null) { d = this.v1; } this.xt.ch(); if (this.xo.bm == 0 || this.xo.bm == 1) { this.zy(); let e = this.xv; let f = OverlayTextUtil.o(e, this.x0); let g = this.xr; if (g == 18) { f = false; } if (f && !stringIsNullOrEmpty(this.y9)) { let h = this.xo.dz; let i = this.vv; let j = this.aa7; if (j == null && this.xz) { j = i; } let k = this.aa5; if (k == null && this.xx) { k = i; } let l = this.aa6; if (l == null && this.xy) { l = i; } let m = new OverlayTextUpdatingEventArgs(); m.textLocation = this.xr; m.textAngle = this.yd; m.textVisible = this.x0; m.textContent = this.y9; m.textColorMode = this.xn; m.textColorShift = this.yi; m.textColor = j; m.backgroundMode = this.xl; m.backgroundShift = this.ye; m.background = k; m.borderMode = this.xm; m.borderShift = this.yg; m.borderStroke = l; m.borderRadius = this.yf; m.borderThickness = this.yh; m.shapeBrush = this.vv; m.shapeOutline = this.vz; m.f = h; m.horizontalMargin = this.yj; m.verticalPadding = this.ym; m.verticalMargin = this.yl; m.horizontalPadding = this.yk; if (this.stylingOverlayText != null) { this.stylingOverlayText(this, m); } OverlayTextUtil.ad(m); let n = OverlayTextInfo.d(m); if (n.textVisible && !n.h) { this.xt.ce.count = 1; this.xt.cd.count = 1; n.f = e; n.ad = this.cw.cc(n.textContent, n.f); n.u = this.xt.ce.item(0); n.ac = this.xt.cd.item(0); if (n.g) { let o = this.dc.yn({ $type: Point_$type, x: 0, y: NaN }); let p = this.dc.yn({ $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.yn({ $type: Point_$type, x: NaN, y: 0 }); let s = this.dc.yn({ $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.xo.dz; let v = new AxisAnnotationFramePrepareSettings(); v.u = this.aa2; v.y = this.aa4; v.x = this.aa3; v.g = this.x5; v.ae = this.aa8; v.l = this.ya; v.c = !u && this.xw; v.z = this.aa2; v.ad = this.aa4; v.ac = this.aa3; v.m = this.x5; v.af = this.aa8; v.r = this.ya; v.d = u && this.xw; AxisAnnotationFrameManager.c(this.xp, { $type: Point_$type, x: a, y: a }, this, this.dc, this.getEffectiveViewport(), d, v); AxisAnnotationFrameManager.d(this, this.xp, c, this.x2, this.x3, b, this.ys, this.ys, this.xq, this.xq); } get_isValueOverlay() { return true; } y6(a) { if (this.xo != null) { return this.xo.ja(a); } return null; } get y8() { let a = this.y6(this.yp()); return a != null ? a : stringFormat("{0:0.##}", this.yp()); } get xv() { return this.xu; } set xv(a) { let b = this.xu; if (OverlayTextUtil.q(a)) { a = OverlayTextUtil.c(); } this.xu = a; if (b != this.xu) { this.raisePropertyChanged("OverlayTextStyle", b, this.xu); } } } ValueOverlay.$t = /*@__PURE__*/ markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]); ValueOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:x5:z1', [1, /*@__PURE__*/ DeviceUtils.g(3)], 'AxisAnnotationBackground:aa2:z2', [Brush.$, null], 'AxisAnnotationFormatLabel:xq:z3', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:ys:z4', [1, -1], 'AxisAnnotationOutline:aa3:z5', [Brush.$, null], 'AxisAnnotationPaddingBottom:x6:z6', [1, NaN], 'AxisAnnotationPaddingLeft:x7:z7', [1, NaN], 'AxisAnnotationPaddingRight:x8:z8', [1, NaN], 'AxisAnnotationPaddingTop:x9:z9', [1, NaN], 'AxisAnnotationStrokeThickness:ya:aaa', [1, NaN], 'AxisAnnotationTextColor:aa4:aab', [Brush.$, null], 'Axis:xo:aac', [Axis.$, null], 'DateValue:x4:aad', [3, /*@__PURE__*/ dateMinValue()], 'IsAxisAnnotationEnabled:xw:aae', [0, false], 'OverlayTextAngle:yd:aaf', [1, NaN], 'OverlayTextBackgroundMatchLayer:xx:aag', [0, false], 'OverlayTextBackgroundMode:xl:aah', [AnnotationAppearanceMode_$type, /*@__PURE__*/ enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextBackground:aa5:aai', [Brush.$, null], 'OverlayTextBackgroundShift:ye:aaj', [1, NaN], 'OverlayTextBorderColor:aa6:aak', [Brush.$, null], 'OverlayTextBorderMatchLayer:xy:aal', [0, false], 'OverlayTextBorderMode:xm:aam', [AnnotationAppearanceMode_$type, /*@__PURE__*/ enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextBorderRadius:yf:aan', [1, NaN], 'OverlayTextBorderShift:yg:aao', [1, NaN], 'OverlayTextBorderThickness:yh:aap', [1, 1], 'OverlayTextColorMatchLayer:xz:aaq', [0, true], 'OverlayTextColorMode:xn:aar', [AnnotationAppearanceMode_$type, /*@__PURE__*/ enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextColor:aa7:aas', [Brush.$, null], 'OverlayTextColorShift:yi:aat', [1, NaN], 'OverlayTextHorizontalMargin:yj:aau', [1, NaN], 'OverlayTextHorizontalPadding:yk:aav', [1, NaN], 'OverlayTextLocation:xr:aaw', [OverlayTextLocation_$type, /*@__PURE__*/ enumGetBox(OverlayTextLocation_$type, 0)], 'OverlayText:y9:aax', [2, null], 'OverlayTextVerticalMargin:yl:aay', [1, NaN], 'OverlayTextVerticalPadding:ym:aaz', [1, NaN], 'OverlayTextVisible:x0:aa0', [0, true], 'Value:yr:aa1', [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.vv; this.cr.ad = this.f.io; this.cr.ai = this.f.wo; this.cr.aj = this.f.wp; } bq() { super.bq(); let a = this.b3(); this.cr._stroke = a; this.cr.ad = this.f.io + 3; this.cr._stroke = a; this.cr.ad = this.f.io + 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.ac(); a.k(d.j); } if (d._visibility == 0) { a.w(d); } if (d.j != null) { a.ab(); } } for (let e = 0; e < this.ce.count; e++) { let f = this.ce.item(e); if (f.j != null) { a.k(f.j); } a.ah(f.dataContext); a.y(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; })();