UNPKG

igniteui-react-charts

Version:

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

693 lines (692 loc) 26 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 { __extends } from "tslib"; 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 */ var ValueOverlay = /** @class */ /*@__PURE__*/ (function (_super) { __extends(ValueOverlay, _super); function ValueOverlay() { var _this = _super.call(this) || this; _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(); return _this; } ValueOverlay.prototype.bk = function () { return new ValueOverlay(); }; ValueOverlay.prototype.je = function (a, b, c) { return this.yo(); }; ValueOverlay.prototype.yo = function () { if (+(this.x3) != +(dateMinValue())) { return this.x3.getTime(); } return this.yq; }; ValueOverlay.prototype.yb = function (a, b) { var c = Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2)); var d = Math.acos((a.x - b.x) / c); if ((a.y - b.y) < 0) { d = (2 * Math.PI) - d; } return d; }; ValueOverlay.prototype.wx = function (a, b, c) { if (this.xn == null) { return { $type: Point_$type, x: NaN, y: NaN }; } var d = this.ym(); var e = NaN; var f = NaN; var g = NaN; var h = { $type: Point_$type, x: 0.5, y: 0.5 }; var 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 }; }; ValueOverlay.prototype.kd = function (a) { throw new NotImplementedException(0); }; ValueOverlay.prototype.kx = function (a) { return this; }; ValueOverlay.prototype.gk = function (a) { return false; }; ValueOverlay.prototype.ay = function (a) { var b = typeCast(NumericAxisBase.$, a); var c = this.yo(); if (isNaN_(c) || isInfinity(c)) { return null; } return new AxisRange(c, c); }; ValueOverlay.prototype.sa = function (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(); } var 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); } }; ValueOverlay.prototype.ym = function () { var a, b; var c = this.getViewInfo(b, a); b = c.p0; a = c.p1; var d = this.getEffectiveViewport1(this.cw); var e = new ScalerParams(0, a, b, this.xn.dn, d); return this.xn.f7(this.yo(), e); }; ValueOverlay.prototype.zy = function (a, b) { if (this.xn == null) { return; } var c = typeCast(CategoryAxisBase.$, this.xn); if (c != null && !c.dj) { if (this.yo() > c.qd - 1) { return; } if (c.categoryMode != 0) { var d = this.getEffectiveViewport1(b); var e = 0.5 * c.getCategorySize(b.ca, b.b9, d); var f = false; if (c.dz && !c.dn) { f = true; } if (typeCast(CategoryXAxis.$, c) !== null && c.dn) { f = true; } if (f) { e = -e; } a += e; } } var 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; } } var 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()); } }; ValueOverlay.prototype.hl = function (a, b, c) { var d = true; d = _super.prototype.hl.call(this, a, b, c); if (!c.r() || b.isEmpty || a.isEmpty || this.xn == null || this.xn.b7 == null) { d = false; } return d; }; ValueOverlay.prototype.ta = function (a, b) { this.r9(false); }; ValueOverlay.prototype.s9 = function (a, b) { this.r9(false); }; ValueOverlay.prototype.pp = function (a, b, c, d) { throw new NotImplementedException(0); }; ValueOverlay.prototype.rr = function (a, b, c, d) { _super.prototype.rr.call(this, 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]: var 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; } }; ValueOverlay.prototype.qq = function () { _super.prototype.qq.call(this); if (this.xn != null) { this.xn.l0(false); } }; ValueOverlay.prototype.pj = function (a, b) { _super.prototype.pj.call(this, a, b); var c = b; c.ci(); }; ValueOverlay.prototype.x0 = function () { if (this.xn == null || this.xn.b7 == null || isNaN_(this.yo()) || this._visibility != 0) { return false; } var a = typeCast(CategoryAxisBase.$, this.xn); if (a != null && a.qd == 0) { return false; } return true; }; ValueOverlay.prototype.preferredCategoryMode = function (a) { return 0; }; Object.defineProperty(ValueOverlay.prototype, "categoryAxis", { get: function () { return typeCast(CategoryAxisBase.$, this.xn); }, enumerable: false, configurable: true }); ValueOverlay.prototype.ct = function () { return new ValueOverlayView(this); }; ValueOverlay.prototype.ri = function (a) { _super.prototype.ri.call(this, a); this.xs = typeCast(ValueOverlayView.$, a); }; ValueOverlay.prototype.sb = function (a, b) { _super.prototype.sb.call(this, a, b); if (!this.g7) { this.cw.be(b); return; } this.cw.be(b); if (this.d7(this.cv) || !this.x0()) { return; } var c = this.getEffectiveViewport1(this.cw); var 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; }; ValueOverlay.prototype.getOffsetValue = function () { return 0; }; ValueOverlay.prototype.getCategoryWidth = function () { return 0; }; Object.defineProperty(ValueOverlay.prototype, "aa7", { get: function () { return new Thickness(1, this.x6, this.x8, this.x7, this.x5); }, enumerable: false, configurable: true }); ValueOverlay.prototype.ai = function () { return [this.xn]; }; ValueOverlay.prototype.zx = function () { if (OverlayTextUtil.q(this.xt)) { this.xt = OverlayTextUtil.c(); } else if (OverlayTextUtil.k(this.xt)) { this.xt = this.cw.l(this.xt.fontString); } }; ValueOverlay.prototype.zz = function (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; } var 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(); var d = this.vu; if (d == null) { d = this.v0; } this.xs.ch(); if (this.xn.bm == 0 || this.xn.bm == 1) { this.zx(); var e = this.xu; var f = OverlayTextUtil.o(e, this.xz); var g = this.xq; if (g == 18) { f = false; } if (f && !stringIsNullOrEmpty(this.y8)) { var h = this.xn.dz; var i = this.vu; var j = this.aa6; if (j == null && this.xy) { j = i; } var k = this.aa4; if (k == null && this.xw) { k = i; } var l = this.aa5; if (l == null && this.xx) { l = i; } var 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); var 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) { var o = this.dc.yk({ $type: Point_$type, x: 0, y: NaN }); var p = this.dc.yk({ $type: Point_$type, x: 1, y: NaN }); var q = p.x - o.x; n.ab = new Rect(0, o.x, a, q, 1); } else { var r = this.dc.yk({ $type: Point_$type, x: NaN, y: 0 }); var s = this.dc.yk({ $type: Point_$type, x: NaN, y: 1 }); var 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); } } } var u = this.xn.dz; var 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); }; ValueOverlay.prototype.get_isValueOverlay = function () { return true; }; ValueOverlay.prototype.y5 = function (a) { if (this.xn != null) { return this.xn.ja(a); } return null; }; Object.defineProperty(ValueOverlay.prototype, "y7", { get: function () { var a = this.y5(this.yo()); return a != null ? a : stringFormat("{0:0.##}", this.yo()); }, enumerable: false, configurable: true }); Object.defineProperty(ValueOverlay.prototype, "xu", { get: function () { return this.xt; }, set: function (a) { var b = this.xt; if (OverlayTextUtil.q(a)) { a = OverlayTextUtil.c(); } this.xt = a; if (b != this.xt) { this.raisePropertyChanged("OverlayTextStyle", b, this.xt); } }, enumerable: false, configurable: true }); ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]); ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:x4:z0', [1, 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, dateMinValue()], 'IsAxisAnnotationEnabled:xv:aad', [0, false], 'OverlayTextAngle:yc:aae', [1, NaN], 'OverlayTextBackgroundMatchLayer:xw:aaf', [0, false], 'OverlayTextBackgroundMode:xk:aag', [AnnotationAppearanceMode_$type, 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, 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, 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, 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; }(Series)); export { ValueOverlay }; /** * @hidden */ var ValueOverlayView = /** @class */ /*@__PURE__*/ (function (_super) { __extends(ValueOverlayView, _super); function ValueOverlayView(a) { var _this = _super.call(this, a) || this; _this.cr = null; _this.cg = null; _this.ce = null; _this.cf = null; _this.cd = null; _this.cr = new Path(); return _this; } ValueOverlayView.prototype.bp = function () { _super.prototype.bp.call(this); this.cr._stroke = this.f.vu; this.cr.ad = this.f.im; this.cr.ai = this.f.wn; this.cr.aj = this.f.wo; }; ValueOverlayView.prototype.bq = function () { _super.prototype.bq.call(this); var 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; }; ValueOverlayView.prototype.cp = function (a) { this.cr.an = a; this.a2(); }; ValueOverlayView.prototype.ci = function () { this.cr.an = null; this.a2(); }; ValueOverlayView.prototype.bj = function (a, b) { _super.prototype.bj.call(this, a, b); if (a.d) { a.t(this.cr); for (var c = 0; c < this.cd.count; c++) { var 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 (var e = 0; e < this.ce.count; e++) { var f = this.ce.item(e); if (f.j != null) { a.k(f.j); } a.af(f.dataContext); a.x(f); if (f.j != null) { } } } }; ValueOverlayView.prototype.ax = function (a) { _super.prototype.ax.call(this, a); this.f.bc.exportPathData(a, this.cr, "ValueOverlayPath", []); }; ValueOverlayView.prototype.ch = function () { }; ValueOverlayView.prototype.a4 = function () { var _this = this; _super.prototype.a4.call(this); this.cg = new List$1(TextBlock.$, 0); this.ce = ((function () { var $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 = ((function () { var $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; })()); }; ValueOverlayView.prototype.cq = function () { var a = new TextBlock(); this.cg.add(a); return a; }; ValueOverlayView.prototype.cn = function (a) { if (this.cg.contains(a)) { this.cg.remove(a); } }; ValueOverlayView.prototype.cm = function (a) { a._visibility = 0; a.s = 0; }; ValueOverlayView.prototype.co = function (a) { a._visibility = 1; }; ValueOverlayView.prototype.cs = function () { var a = new Rectangle(); this.cf.add(a); return a; }; ValueOverlayView.prototype.ck = function (a) { a.dataContext = null; if (this.cf.contains(a)) { this.cf.remove(a); } }; ValueOverlayView.prototype.cj = function (a) { a._visibility = 0; }; ValueOverlayView.prototype.cl = function (a) { a._visibility = 1; }; ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$); return ValueOverlayView; }(SeriesView)); export { ValueOverlayView };