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.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(); return _this; } ValueOverlay.prototype.bk = function () { return new ValueOverlay(); }; ValueOverlay.prototype.jd = function (a, b, c) { return this.yn(); }; ValueOverlay.prototype.yn = function () { if (+(this.x2) != +(dateMinValue())) { return this.x2.getTime(); } return this.yp; }; ValueOverlay.prototype.ya = 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.ww = function (a, b, c) { if (this.xm == null) { return { $type: Point_$type, x: NaN, y: NaN }; } var d = this.yl(); 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.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 }; }; ValueOverlay.prototype.kc = function (a) { throw new NotImplementedException(0); }; ValueOverlay.prototype.kw = function (a) { return this; }; ValueOverlay.prototype.gj = function (a) { return false; }; ValueOverlay.prototype.ay = function (a) { var b = typeCast(NumericAxisBase.$, a); var c = this.yn(); if (isNaN_(c) || isInfinity(c)) { return null; } return new AxisRange(c, c); }; ValueOverlay.prototype.r9 = function (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(); } var 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); } }; ValueOverlay.prototype.yl = 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.xm.dn, d); return this.xm.f6(this.yn(), e); }; ValueOverlay.prototype.zx = function (a, b) { if (this.xm == null) { return; } var c = typeCast(CategoryAxisBase.$, this.xm); if (c != null && !c.dj) { if (this.yn() > c.qb - 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.dy && !c.dn) { f = true; } if (typeCast(CategoryXAxis.$, c) !== null && c.dn) { f = true; } if (f) { e = -e; } a += e; } } var 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; } } var 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()); } }; ValueOverlay.prototype.hk = function (a, b, c) { var d = true; d = _super.prototype.hk.call(this, a, b, c); if (!c.r() || b.isEmpty || a.isEmpty || this.xm == null || this.xm.b7 == null) { d = false; } return d; }; ValueOverlay.prototype.s9 = function (a, b) { this.r8(false); }; ValueOverlay.prototype.s8 = function (a, b) { this.r8(false); }; ValueOverlay.prototype.po = function (a, b, c, d) { throw new NotImplementedException(0); }; ValueOverlay.prototype.rq = function (a, b, c, d) { _super.prototype.rq.call(this, 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]: var 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; } }; ValueOverlay.prototype.qp = function () { _super.prototype.qp.call(this); if (this.xm != null) { this.xm.ly(false); } }; ValueOverlay.prototype.pi = function (a, b) { _super.prototype.pi.call(this, a, b); var c = b; c.ci(); }; ValueOverlay.prototype.xz = function () { if (this.xm == null || this.xm.b7 == null || isNaN_(this.yn()) || this._visibility != 0) { return false; } var a = typeCast(CategoryAxisBase.$, this.xm); if (a != null && a.qb == 0) { return false; } return true; }; ValueOverlay.prototype.preferredCategoryMode = function (a) { return 0; }; Object.defineProperty(ValueOverlay.prototype, "categoryAxis", { get: function () { return typeCast(CategoryAxisBase.$, this.xm); }, enumerable: false, configurable: true }); ValueOverlay.prototype.ct = function () { return new ValueOverlayView(this); }; ValueOverlay.prototype.rh = function (a) { _super.prototype.rh.call(this, a); this.xr = typeCast(ValueOverlayView.$, a); }; ValueOverlay.prototype.sa = function (a, b) { _super.prototype.sa.call(this, a, b); if (!this.g6) { this.cw.be(b); return; } this.cw.be(b); if (this.d7(this.cv) || !this.xz()) { return; } var c = this.getEffectiveViewport1(this.cw); var 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; }; ValueOverlay.prototype.getOffsetValue = function () { return 0; }; ValueOverlay.prototype.getCategoryWidth = function () { return 0; }; Object.defineProperty(ValueOverlay.prototype, "aa6", { get: function () { return new Thickness(1, this.x5, this.x7, this.x6, this.x4); }, enumerable: false, configurable: true }); ValueOverlay.prototype.ai = function () { return [this.xm]; }; ValueOverlay.prototype.zw = function () { if (OverlayTextUtil.q(this.xs)) { this.xs = OverlayTextUtil.c(); } else if (OverlayTextUtil.k(this.xs)) { this.xs = this.cw.l(this.xs.fontString); } }; ValueOverlay.prototype.zy = function (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; } var 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(); var d = this.vt; if (d == null) { d = this.vz; } this.xr.ch(); if (this.xm.bm == 0 || this.xm.bm == 1) { this.zw(); var e = this.xt; var f = OverlayTextUtil.o(e, this.xy); var g = this.xp; if (g == 18) { f = false; } if (f && !stringIsNullOrEmpty(this.y7)) { var h = this.xm.dy; var i = this.vt; var j = this.aa5; if (j == null && this.xx) { j = i; } var k = this.aa3; if (k == null && this.xv) { k = i; } var l = this.aa4; if (l == null && this.xw) { l = i; } var 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); var 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) { var o = this.dc.yj({ $type: Point_$type, x: 0, y: NaN }); var p = this.dc.yj({ $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.yj({ $type: Point_$type, x: NaN, y: 0 }); var s = this.dc.yj({ $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.xm.dy; var 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); }; ValueOverlay.prototype.get_isValueOverlay = function () { return true; }; ValueOverlay.prototype.y4 = function (a) { if (this.xm != null) { return this.xm.i8(a); } return null; }; Object.defineProperty(ValueOverlay.prototype, "y6", { get: function () { var a = this.y4(this.yn()); return a != null ? a : stringFormat("{0:0.##}", this.yn()); }, enumerable: false, configurable: true }); Object.defineProperty(ValueOverlay.prototype, "xt", { get: function () { return this.xs; }, set: function (a) { var b = this.xs; if (OverlayTextUtil.q(a)) { a = OverlayTextUtil.c(); } this.xs = a; if (b != this.xs) { this.raisePropertyChanged("OverlayTextStyle", b, this.xs); } }, enumerable: false, configurable: true }); ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]); ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:x3:zz', [1, 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, dateMinValue()], 'IsAxisAnnotationEnabled:xu:aac', [0, false], 'OverlayTextAngle:yb:aad', [1, NaN], 'OverlayTextBackgroundMatchLayer:xv:aae', [0, false], 'OverlayTextBackgroundMode:xj:aaf', [AnnotationAppearanceMode_$type, 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, 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, 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, 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; }(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.vt; this.cr.ad = this.f.il; this.cr.ai = this.f.wm; this.cr.aj = this.f.wn; }; ValueOverlayView.prototype.bq = function () { _super.prototype.bq.call(this); var 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; }; 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 };