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