UNPKG

igniteui-react-charts

Version:

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

656 lines (655 loc) 25 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 { 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 { 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.x5 = 0; _this.x6 = 0; _this.xs = 0; _this.w7 = null; _this.xl = null; _this.xk = null; _this.stylingOverlayText = null; _this.xc = null; _this.ab = ValueOverlay.$; _this.xc = OverlayTextUtil.c(); return _this; } ValueOverlay.prototype.bk = function () { return new ValueOverlay(); }; ValueOverlay.prototype.i6 = function (a, b, c) { return this.x7; }; ValueOverlay.prototype.xt = 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.wh = function (a, b, c) { if (this.w6 == null) { return { $type: Point_$type, x: NaN, y: NaN }; } var d = this.x4(); 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.w6.a2) { 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.xt(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.j4 = function (a) { throw new NotImplementedException(0); }; ValueOverlay.prototype.ko = function (a) { return this; }; ValueOverlay.prototype.ge = function (a) { return false; }; ValueOverlay.prototype.ay = function (a) { var b = typeCast(NumericAxisBase.$, a); var c = this.x7; if (isNaN_(c) || isInfinity(c)) { return null; } return new AxisRange(c, c); }; ValueOverlay.prototype.rv = function (a) { this.o7(true, this.cw); if (!this.xj()) { if (this.w7 != null) { this.zf(NaN, this.d4()); } return; } if (this.gg(a)) { if (this.d4()) { if (this.dd.g) { this.dd.t(); } var b = this.x5; this.x5 = this.x6; this.x6 = b; } else { this.x5 = this.xs; } this.xs = this.x4(); this.sb(); } else { this.xs = this.x4(); this.ze(this.xs, this.xb); } }; ValueOverlay.prototype.x4 = 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.w6.ch, d); return this.w6.el(this.x7, e); }; ValueOverlay.prototype.ze = function (a, b) { if (this.w6 == null) { return; } var c = typeCast(CategoryAxisBase.$, this.w6); if (c != null && !c.ce) { if (this.x7 > c.lk - 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.cp && !c.ch) { f = true; } if (typeCast(CategoryXAxis.$, c) !== null && c.ch) { f = true; } if (f) { e = -e; } a += e; } } var g = typeCast(NumericAxisBase.$, this.w6); if (g != null) { if (this.x7 < g.l4 || this.x7 > g.l3) { return; } if (g.lp && this.x7 < 0) { return; } } var h; switch (this.w6.a2) { case 2: case 3: h = this.w6.j8(a, b.ca, b.b9, this.getEffectiveViewport1(b), this.wo(b)); break; default: h = this.w6.j8(a, b.ca, b.b9, this.getEffectiveViewport1(b), this.wo(b)); break; } if (h != null) { b.cp(h); } if (!b.t) { this.zf(a, this.d4()); } }; ValueOverlay.prototype.hf = function (a, b, c) { var d = true; d = _super.prototype.hf.call(this, a, b, c); if (!c.r() || b.isEmpty || a.isEmpty || this.w6 == null || this.w6.bi == null) { d = false; } return d; }; ValueOverlay.prototype.sv = function (a, b) { this.ru(false); }; ValueOverlay.prototype.su = function (a, b) { this.ru(false); }; ValueOverlay.prototype.pd = function (a, b, c, d) { throw new NotImplementedException(0); }; ValueOverlay.prototype.rc = function (a, b, c, d) { _super.prototype.rc.call(this, a, b, c, d); switch (b) { case ValueOverlay.$$p[11]: if (c != null) { c.b0(this); } if (d != null) { d.ct(this); } this.ru(false); this.qn(); break; case "TransitionProgress": this.x6 = this.x5 + this.jr * (this.xs - this.x5); if (this.d7(this.cw)) { return; } if (this.jr == 1) { this.ze(this.xs, this.xb); this.qq(); } else { this.ze(this.x6, this.xb); } if (this.dc != null) { this.dc.q7(this); } break; case ValueOverlay.$$p[35]: var e = typeCast(NumericAxisBase.$, this.w6); if (e != null) { e.c1(); } this.ru(true); this.qo(); break; case ValueOverlay.$$p[12]: 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.ru(true); break; case ValueOverlay.$$p[31]: case ValueOverlay.$$p[34]: case ValueOverlay.$$p[30]: case ValueOverlay.$$p[13]: case ValueOverlay.$$p[24]: case ValueOverlay.$$p[25]: case ValueOverlay.$$p[27]: case ValueOverlay.$$p[26]: case ValueOverlay.$$p[14]: case ValueOverlay.$$p[15]: case ValueOverlay.$$p[17]: case ValueOverlay.$$p[16]: case ValueOverlay.$$p[19]: case ValueOverlay.$$p[20]: case ValueOverlay.$$p[22]: case ValueOverlay.$$p[18]: case ValueOverlay.$$p[21]: case ValueOverlay.$$p[23]: case ValueOverlay.$$p[28]: case ValueOverlay.$$p[29]: case ValueOverlay.$$p[33]: case ValueOverlay.$$p[32]: this.ru(true); break; case "SeriesViewer": if (d == null) { if (this.xk != null && this.xk.count > 0 && this.w7 != null) { this.zf(NaN, this.d4()); } } break; } }; ValueOverlay.prototype.qd = function () { _super.prototype.qd.call(this); if (this.w6 != null) { this.w6.ib(false); } }; ValueOverlay.prototype.o7 = function (a, b) { _super.prototype.o7.call(this, a, b); var c = b; c.ci(); }; ValueOverlay.prototype.xj = function () { if (this.w6 == null || this.w6.bi == null || isNaN_(this.x7) || this._visibility != 0) { return false; } var a = typeCast(CategoryAxisBase.$, this.w6); if (a != null && a.lk == 0) { return false; } return true; }; ValueOverlay.prototype.preferredCategoryMode = function (a) { return 0; }; Object.defineProperty(ValueOverlay.prototype, "categoryAxis", { get: function () { return typeCast(CategoryAxisBase.$, this.w6); }, enumerable: false, configurable: true }); ValueOverlay.prototype.ct = function () { return new ValueOverlayView(this); }; ValueOverlay.prototype.q3 = function (a) { _super.prototype.q3.call(this, a); this.xb = typeCast(ValueOverlayView.$, a); }; ValueOverlay.prototype.rw = function (a, b) { _super.prototype.rw.call(this, a, b); if (!this.g1) { this.cw.be(b); return; } this.cw.be(b); if (this.d7(this.cv) || !this.xj()) { return; } var c = this.getEffectiveViewport1(this.cw); var d = this.w6.el(this.x7, new ScalerParams(0, this.cv.ca, a, this.w6.ch, c)); this.ze(d, typeCast(ValueOverlayView.$, this.cv)); this.g1 = false; }; ValueOverlay.prototype.getOffsetValue = function () { return 0; }; ValueOverlay.prototype.getCategoryWidth = function () { return 0; }; Object.defineProperty(ValueOverlay.prototype, "aam", { get: function () { return new Thickness(1, this.xo, this.xq, this.xp, this.xn); }, enumerable: false, configurable: true }); ValueOverlay.prototype.ai = function () { return [this.w6]; }; ValueOverlay.prototype.zd = function () { if (OverlayTextUtil.q(this.xc)) { this.xc = OverlayTextUtil.c(); } else if (OverlayTextUtil.k(this.xc)) { this.xc = this.cw.l(this.xc.fontString); } }; ValueOverlay.prototype.zf = function (a, b) { if (isNaN_(a)) { if (this.w7 != null) { AxisAnnotationFrameManager.b(this.w7); AxisAnnotationFrameManager.d(this, this.w7, true, this.xk, this.xl, b, this.x8, this.x8, this.w8, this.w8); } return; } var c = false; if (this.xk == null) { c = true; this.xl = new List$1(Axis.$, 0); this.xk = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0); } this.w7 = new AxisAnnotationFrame(); var d = this.ve; if (d == null) { d = this.vk; } this.xb.ch(); if (this.w6.a2 == 0 || this.w6.a2 == 1) { this.zd(); var e = this.xd; var f = OverlayTextUtil.o(e, this.xi); var g = this.w9; if (g == 18) { f = false; } if (f && !stringIsNullOrEmpty(this.yo)) { var h = this.w6.cp; var i = new OverlayTextUpdatingEventArgs(); i.textLocation = this.w9; i.textAngle = this.xu; i.textVisible = this.xi; i.textContent = this.yo; i.textColorMode = this.w5; i.textColorShift = this.xz; i.textColor = this.xh ? this.ve : this.aal; i.backgroundMode = this.w3; i.backgroundShift = this.xv; i.background = this.xf ? this.ve : this.aaj; i.borderMode = this.w4; i.borderShift = this.xx; i.borderStroke = this.xg ? this.ve : this.aak; i.borderRadius = this.xw; i.borderThickness = this.xy; i.shapeBrush = this.ve; i.shapeOutline = this.vi; i.f = h; i.horizontalMargin = this.x0; i.verticalPadding = this.x3; i.verticalMargin = this.x2; i.horizontalPadding = this.x1; if (this.stylingOverlayText != null) { this.stylingOverlayText(this, i); } OverlayTextUtil.ad(i); var j = OverlayTextInfo.d(i); if (j.textVisible && !j.h) { this.xb.ce.count = 1; this.xb.cd.count = 1; j.f = e; j.ad = this.cw.cc(j.textContent, j.f); j.u = this.xb.ce.item(0); j.ac = this.xb.cd.item(0); if (j.g) { var k = this.dc.wl({ $type: Point_$type, x: 0, y: NaN }); var l = this.dc.wl({ $type: Point_$type, x: 1, y: NaN }); var m = l.x - k.x; j.ab = new Rect(0, k.x, a, m, 1); } else { var n = this.dc.wl({ $type: Point_$type, x: NaN, y: 0 }); var o = this.dc.wl({ $type: Point_$type, x: NaN, y: 1 }); var p = o.y - n.y; j.ab = new Rect(0, a, n.y, 1, p); } OverlayTextUtil.ac(j); this.cw.av(j.u, j.f); this.cw.aw(j.u, j.f); } } } var q = this.w6.cp; AxisAnnotationFrameManager.c(this.w7, { $type: Point_$type, x: a, y: a }, this, this.dc, this.getEffectiveViewport(), d, this.aag, this.xm, this.aai, this.aah, this.aam, this.xr, this.aag, this.xm, this.aai, this.aah, this.aam, this.xr, !q && this.xe, q && this.xe); AxisAnnotationFrameManager.d(this, this.w7, c, this.xk, this.xl, b, this.x8, this.x8, this.w8, this.w8); }; ValueOverlay.prototype.get_isValueOverlay = function () { return true; }; ValueOverlay.prototype.yl = function (a) { if (this.w6 != null) { return this.w6.gf(a); } return null; }; Object.defineProperty(ValueOverlay.prototype, "yn", { get: function () { var a = this.yl(this.x7); return a != null ? a : stringFormat("{0:0.##}", this.x7); }, enumerable: false, configurable: true }); Object.defineProperty(ValueOverlay.prototype, "xd", { get: function () { return this.xc; }, set: function (a) { var b = this.xc; if (OverlayTextUtil.q(a)) { a = OverlayTextUtil.c(); } this.xc = a; if (b != this.xc) { this.raisePropertyChanged("OverlayTextStyle", b, this.xc); } }, enumerable: false, configurable: true }); ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]); ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:xm:zg', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:aag:zh', [Brush.$, null], 'AxisAnnotationFormatLabel:w8:zi', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:x8:zj', [1, -1], 'AxisAnnotationOutline:aah:zk', [Brush.$, null], 'AxisAnnotationPaddingBottom:xn:zl', [1, NaN], 'AxisAnnotationPaddingLeft:xo:zm', [1, NaN], 'AxisAnnotationPaddingRight:xp:zn', [1, NaN], 'AxisAnnotationPaddingTop:xq:zo', [1, NaN], 'AxisAnnotationStrokeThickness:xr:zp', [1, NaN], 'AxisAnnotationTextColor:aai:zq', [Brush.$, null], 'Axis:w6:zr', [Axis.$, null], 'IsAxisAnnotationEnabled:xe:zs', [0, false], 'OverlayTextAngle:xu:zt', [1, NaN], 'OverlayTextBackgroundMatchLayer:xf:zu', [0, false], 'OverlayTextBackgroundMode:w3:zv', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextBackground:aaj:zw', [Brush.$, null], 'OverlayTextBackgroundShift:xv:zx', [1, NaN], 'OverlayTextBorderColor:aak:zy', [Brush.$, null], 'OverlayTextBorderMatchLayer:xg:zz', [0, false], 'OverlayTextBorderMode:w4:z0', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextBorderRadius:xw:z1', [1, NaN], 'OverlayTextBorderShift:xx:z2', [1, NaN], 'OverlayTextBorderThickness:xy:z3', [1, 1], 'OverlayTextColorMatchLayer:xh:z4', [0, true], 'OverlayTextColorMode:w5:z5', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextColor:aal:z6', [Brush.$, null], 'OverlayTextColorShift:xz:z7', [1, NaN], 'OverlayTextHorizontalMargin:x0:z8', [1, NaN], 'OverlayTextHorizontalPadding:x1:z9', [1, NaN], 'OverlayTextLocation:w9:aaa', [OverlayTextLocation_$type, enumGetBox(OverlayTextLocation_$type, 0)], 'OverlayText:yo:aab', [2, null], 'OverlayTextVerticalMargin:x2:aac', [1, NaN], 'OverlayTextVerticalPadding:x3:aad', [1, NaN], 'OverlayTextVisible:xi:aae', [0, true], 'Value:x7:aaf', [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.ve; this.cr.ad = this.f.ig; this.cr.ai = this.f.v7; this.cr.aj = this.f.v8; }; ValueOverlayView.prototype.bq = function () { _super.prototype.bq.call(this); var a = this.b3(); this.cr._stroke = a; this.cr.ad = this.f.ig + 3; this.cr._stroke = a; this.cr.ad = this.f.ig + 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.ad(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 };