UNPKG

igniteui-react-charts

Version:

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

617 lines (616 loc) 20.5 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, __values } from "tslib"; import { AnnotationLayer } from "./AnnotationLayer"; import { DependencyProperty } from "igniteui-react-core"; import { Series } from "./Series"; import { Brush } from "igniteui-react-core"; import { ItemTooltipLayerFrame } from "./ItemTooltipLayerFrame"; import { Base, String_$type, fromEnum, Point_$type, markType, markDep, runOn } from "igniteui-react-core"; import { Pool$1 } from "igniteui-react-core"; import { List$1 } from "igniteui-react-core"; import { ItemTooltipCollisionInfo } from "./ItemTooltipCollisionInfo"; import { Rect } from "igniteui-react-core"; import { DataContext } from "igniteui-react-core"; import { Size } from "igniteui-react-core"; import { DeviceUtils } from "igniteui-react-core"; import { PropertyMetadata } from "igniteui-react-core"; import { isNaN_ } from "igniteui-react-core"; import { AnnotationLayerView } from "./AnnotationLayerView"; import { PointerTooltip } from "./PointerTooltip"; import { PointerTooltipStyle } from "./PointerTooltipStyle"; import { PointerTooltipUtils } from "./PointerTooltipUtils"; /** * @hidden */ var ItemToolTipLayer = /** @class */ /*@__PURE__*/ (function (_super) { __extends(ItemToolTipLayer, _super); function ItemToolTipLayer() { var _this = _super.call(this) || this; var a = new ItemTooltipLayerFrame(); var b = new ItemTooltipLayerFrame(); var c = new ItemTooltipLayerFrame(); var d = _this.km / 1000; _this.xx = a; _this.xw = b; _this.xy = c; _this.ab = ItemToolTipLayer.$; return _this; } ItemToolTipLayer.prototype.bk = function () { return new ItemToolTipLayer(); }; ItemToolTipLayer.prototype.get_eu = function () { return true; }; ItemToolTipLayer.prototype.get_f7 = function () { return true; }; ItemToolTipLayer.prototype.ct = function () { return new ItemToolTipLayerView(this); }; ItemToolTipLayer.prototype.rh = function (a) { _super.prototype.rh.call(this, a); this.aas = a; }; ItemToolTipLayer.prototype.get_e5 = function () { return true; }; ItemToolTipLayer.prototype.g0 = function (a) { if (this.aat == null) { return true; } if (this.aat == a) { return true; } return false; }; ItemToolTipLayer.prototype.rq = function (a, b, c, d) { _super.prototype.rq.call(this, a, b, c, d); switch (b) { case ItemToolTipLayer.$$p[1]: case ItemToolTipLayer.$$p[2]: this.r8(true); break; case ItemToolTipLayer.$$p[6]: this.r8(true); break; case ItemToolTipLayer.$$p[0]: this.r8(true); break; case "SeriesViewer": this.aas.cz(); break; case ItemToolTipLayer.$$p[3]: case ItemToolTipLayer.$$p[4]: case ItemToolTipLayer.$$p[5]: this.r8(true); break; } }; ItemToolTipLayer.prototype.zd = function (a, b) { if (this.aat == null || this.aat == a) { if (!this.a1.c) { this.r8(b); } } }; ItemToolTipLayer.prototype.x4 = function (a) { if (!_super.prototype.x4.call(this, a)) { return false; } if (this.aa0 != null) { if (a.isFragment) { var b = a.nn(); if (!Base.equalsStatic(this.aa0, b)) { return false; } } else { if (!Base.equalsStatic(this.aa0, a.name)) { return false; } } } var c = this.oz(a, this.aap); if (!c.c) { return false; } return true; }; ItemToolTipLayer.prototype.zf = function (a, b) { var e_1, _a; var _this = this; _super.prototype.zf.call(this, a, b); var c = a; var d = this.aas.co; var e = this.aaw; var f = this.aav; c.r.clear(); c.l.clear(); c.q.clear(); c.j.clear(); c.i.clear(); c.o.clear(); c.m.clear(); c.p.clear(); c.n.clear(); c.k.clear(); if (isNaN_(this.aap.x) && isNaN_(this.aap.y)) { d.count = 0; return; } var g = 0; if (this.x4(this.aat)) { this.aa8(this.aat, c, e, f, 0); g++; } else { try { for (var _b = __values(fromEnum(this.dc.b9)), _c = _b.next(); !_c.done; _c = _b.next()) { var h = _c.value; if (this.x4(h)) { this.aa8(h, c, e, f, g); g++; } if (h.isStacked) { h.qh(function (i) { if (_this.x4(i)) { _this.aa8(i, c, e, f, g); g++; } if (i.ei) { i.qf(function (j) { if (_this.x4(j)) { _this.aa8(j, c, e, f, g); g++; } return true; }); } return true; }); } if (h.ei) { h.qf(function (i) { if (_this.x4(i)) { _this.aa8(i, c, e, f, g); g++; } return true; }); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } this.aa7(c); } d.count = g; }; ItemToolTipLayer.prototype.aa7 = function (a) { var b = new List$1(ItemTooltipCollisionInfo.$, 0); for (var c = 0; c < a.i.count; c++) { var d = new ItemTooltipCollisionInfo(); d.d = c; d.e = { $type: Point_$type, x: a.i._inner[c], y: a.j._inner[c] }; d.c = a.p._inner[c]; d.a = a.n._inner[c]; d.b = a.r._inner[c]; if (isNaN_(d.e.x) || isNaN_(d.e.y)) { continue; } b.add(d); } b.aa(function (e, f) { if (e.e.y < f.e.y) { return -1; } if (e.e.y > f.e.y) { return 1; } if (e.b < f.b) { return -1; } if (e.b > f.b) { return 1; } return 0; }); var e = this.aau(b); if (!e) { return; } for (var f = 0; f < b.count - 1; f++) { var g = b._inner[f]; var h = b._inner[f + 1]; var i = new Rect(0, g.e.x, g.e.y, g.c, g.a); var j = new Rect(0, h.e.x, h.e.y, h.c, h.a); if (i.intersectsWith(j) || i.top > j.bottom) { h.e = { $type: Point_$type, x: h.e.x, y: i.bottom + 1 }; } } if (b._inner[b.count - 1].e.y + b._inner[b.count - 1].a > this.cw.b9.height) { b._inner[b.count - 1].e = { $type: Point_$type, x: b._inner[b.count - 1].e.x, y: b._inner[b.count - 1].e.y - ((b._inner[b.count - 1].e.y + b._inner[b.count - 1].a) - this.cw.b9.height) }; } for (var k = b.count - 1; k >= 1; k--) { var l = b._inner[k]; var m = b._inner[k - 1]; var n = new Rect(0, l.e.x, l.e.y, l.c, l.a); var o = new Rect(0, m.e.x, m.e.y, m.c, m.a); if (n.intersectsWith(o) || n.top < o.bottom) { m.e = { $type: Point_$type, x: m.e.x, y: n.top - (o.height + 1) }; } } for (var p = 0; p < b.count; p++) { var q = b._inner[p].d; var r = b._inner[p]; a.i._inner[q] = r.e.x; a.j._inner[q] = r.e.y; } }; ItemToolTipLayer.prototype.aau = function (a) { if (a.count <= 1) { return false; } var b = this.cw.b9; for (var c = 0; c < a.count - 1; c++) { var d = a._inner[c]; var e = a._inner[c + 1]; var f = new Rect(0, d.e.x, d.e.y, d.c, d.a); var g = new Rect(0, e.e.x, e.e.y, e.c, e.a); if (f.intersectsWith(g)) { return true; } } return false; }; ItemToolTipLayer.prototype.aa8 = function (a, b, c, d, e) { var f = this.oz(a, this.aap); if (!f.c) { return; } var g = a.ww(f.d, c, d); var h = this.aas.co; var i = this.aay(a); var j = this.aap; if (!c) { j = this.w2(g); } var k = a.kw(j); var l = h.item(e); var m = this.cw.b9; var n = null; if (a.e7 && k != null) { n = a.a3(k); } else { n = new DataContext(); n.item = k; n.series = a; } if (!this.aas.cp(a, l, i, n)) { return; } var o = this.aas.c0(l, i, n); b.l.add1(l); b.m.add1(n); b.o.add1(i); var p = g.x; var q = g.x; q = Math.max(q, m.left); q = Math.min(q, m.right); b.q.add(q); var r = g.y; r = Math.max(r, m.top); r = Math.min(r, m.bottom); b.r.add(r); var s = DeviceUtils.g(10); var t = g.x + s; if (t + o.width > m.right) { t = (p - o.width) - s; } if (t < m.left) { t = m.left; } b.i.add(t); var u = (g.y - o.height) - s; if (u + o.height > m.bottom) { u = (m.bottom - o.height) - s; } if (u < m.top) { u = m.top; } b.j.add(u); b.p.add(o.width); b.n.add(o.height); var v = this.vt; if (v == null) { v = this.vz; } if (v == null) { v = a.vt; } b.k.add(v); }; ItemToolTipLayer.prototype.aay = function (a) { return a.toolTip; }; ItemToolTipLayer.prototype.ql = function () { this.aap = { $type: Point_$type, x: NaN, y: NaN }; this.r8(false); this.aas.cx(false); }; ItemToolTipLayer.prototype.qm = function () { this.aap = { $type: Point_$type, x: NaN, y: NaN }; this.r8(false); this.aas.cx(true); }; ItemToolTipLayer.prototype.zi = function (a, b) { _super.prototype.zi.call(this, a, b); var c = a; var d = c.r.count; var e = b.b9.left; var f = b.b9.right; var g = b.b9.top; var h = b.b9.bottom; for (var i = 0; i < d; i++) { if (isNaN_(c.q._inner[i]) || isNaN_(c.r._inner[i]) || isNaN_(c.i._inner[i]) || isNaN_(c.j._inner[i]) || c.o._inner[i] == null || c.m._inner[i] == null) { this.aas.cw(c.l._inner[i]); continue; } var j = c.i._inner[i]; var k = c.j._inner[i]; var l = c.p._inner[i]; var m = c.n._inner[i]; var n = false; if (j < e && Math.abs(j - e) > 1) { n = true; } if (k < g && Math.abs(k - g) > 1) { n = true; } if ((j + l) > f && Math.abs((j + l) - f) > 1) { n = true; } if ((k + m) > h && Math.abs((k + m) - h) > 1) { n = true; } if (n) { this.aas.cw(c.l._inner[i]); continue; } var o = c.l._inner[i]; var p = Math.min(c.i._inner[i], c.q._inner[i]); var q = Math.min(c.j._inner[i], c.r._inner[i]); var r = c.q._inner[i] - c.i._inner[i]; var s = c.r._inner[i] - c.j._inner[i]; if (o != null) { this.aas.cy(o, p, q, r, s); } } }; ItemToolTipLayer.prototype.gg = function () { return true; }; ItemToolTipLayer.$t = markType(ItemToolTipLayer, 'ItemToolTipLayer', AnnotationLayer.$); ItemToolTipLayer.$$p = markDep(DependencyProperty, PropertyMetadata, ItemToolTipLayer, 'raisePropertyChanged', ['SkipUnknownValues:aav:aa9', [0, true], 'TargetSeriesName:aa0:aba', [2, null], 'TargetSeries:aat:abb', [Series.$, null], 'ToolTipBackground:abg:abc', [Brush.$, null], 'ToolTipBorderBrush:abh:abd', [Brush.$, null], 'ToolTipBorderThickness:aax:abe', [1, NaN], 'UseInterpolation:aaw:abf', [0, false]]); return ItemToolTipLayer; }(AnnotationLayer)); export { ItemToolTipLayer }; /** * @hidden */ var ItemToolTipLayerView = /** @class */ /*@__PURE__*/ (function (_super) { __extends(ItemToolTipLayerView, _super); function ItemToolTipLayerView(a) { var _this = _super.call(this, a) || this; _this.cn = null; _this.co = null; _this.cq = null; _this._htmlTest = null; _this.cn = a; _this.cq = new List$1(PointerTooltip.$, 0); return _this; } ItemToolTipLayerView.prototype.a4 = function () { var _this = this; _super.prototype.a4.call(this); this.co = ((function () { var $ret = new Pool$1(Base.$); $ret.create = runOn(_this, _this.cr); $ret.activate = runOn(_this, _this.ct); $ret.disactivate = runOn(_this, _this.cv); $ret.destroy = runOn(_this, _this.cu); return $ret; })()); this.htmlTest = /^[^<]*(<[\w\W]+>)[^>]*$/; }; ItemToolTipLayerView.prototype.as = function () { _super.prototype.as.call(this); for (var a = 0; a < this.co.a.count; a++) { this.co.a._inner[a].bv(); } for (var b = 0; b < this.co.b.count; b++) { this.co.b._inner[b].bv(); } this.co.clear(); }; ItemToolTipLayerView.prototype.cr = function () { var a = new PointerTooltip(); a.b0(this.f.j8); a._visibility = 1; a.ap = this.f.dc.dw.k; this.cq.add(a); return a; }; ItemToolTipLayerView.prototype.ct = function (a) { var b = a; }; ItemToolTipLayerView.prototype.cv = function (a) { var b = a; b._visibility = 1; }; ItemToolTipLayerView.prototype.cu = function (a) { var b = a; b.b3(); b.content = null; this.cq.remove1(a); }; Object.defineProperty(ItemToolTipLayerView.prototype, "htmlTest", { get: function () { return this._htmlTest; }, set: function (a) { this._htmlTest = a; }, enumerable: false, configurable: true }); ItemToolTipLayerView.prototype.cp = function (a, b, c, d) { var e = b; if (a.lb == "default") { a.lb = a.cw.getDefaultTooltipTemplate(); } var template_ = a.lb; var context_ = d; if (a.toolTip == null) { return false; } var tooltip_ = a.toolTip; if ((tooltip_.updateToolTip)) { tooltip_._inPointer = true; tooltip_.updateToolTip(context_, true); tooltip_.setStyleProperty('position', 'relative'); tooltip_.setStyleProperty('left', ''); tooltip_.setStyleProperty('top', ''); } e.content = a.toolTip; return true; }; ItemToolTipLayerView.prototype.c0 = function (a, b, c) { var d = a; var e = d.content; var f = new Size(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); d.c2 = 1; var g = d.c1(new Size(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)); d.c2 = 0; return g; }; ItemToolTipLayerView.prototype.cy = function (a, b, c, d, e) { var f = new PointerTooltipStyle(); if (this.f.dc != null) { var g = this.f.dc.dw.j.i(); PointerTooltipUtils.a(g, f, this.cn.abg, this.cn.abh, this.cn.aax, 0); } var h = a; h.aq = f; var i = h.content; var j = h.an.n(); h.cw = { $type: Point_$type, x: d * j, y: e * j }; h._visibility = 0; h.n = b; h.o = c; }; ItemToolTipLayerView.prototype.cw = function (a) { if (a != null) { var b = a; b._visibility = 1; } }; ItemToolTipLayerView.prototype.bj = function (a, b) { _super.prototype.bj.call(this, a, b); if (b) { return; } var c = 0; var d = 0; var e = this.f.dc; if (e != null) { var f = e.dw.j.b8(); c += f.x; d += f.y; } for (var g = 0; g < this.cq.count; g++) { var h = this.cq._inner[g].an.n(); this.cq._inner[g].b2(this.cq._inner[g].n * h + c, this.cq._inner[g].o * h + d); } }; ItemToolTipLayerView.prototype.ax = function (a) { var e_2, _a; _super.prototype.ax.call(this, a); try { for (var _b = __values(fromEnum(this.co.a)), _c = _b.next(); !_c.done; _c = _b.next()) { var tooltip_ = _c.value; if (tooltip_._visibility != 0) { continue; } var b = tooltip_; var c = b.a9(); var d = b.n; var e = b.o; var f = new List$1(String_$type, 0); var g = b.content; if (g != null) { var h = g.findByClass("ui-chart-default-tooltip-content"); if (h != null && h.length > 0 && h[0] != null && h[0].getChildCount() > 0) { var i = h[0]; var j = i.getChildAt(0); var k = j.getText(); f.add(k); } else { var l = g.getText(); f.add(l); } } this.f.bc.addPointerTooltipData(a, c, d, e, f); } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } }; ItemToolTipLayerView.prototype.cx = function (a) { this.a2(); for (var b = 0; b < this.cq.count; b++) { this.cw(this.cq._inner[b]); if (a) { this.cq._inner[b].bw(); } } }; ItemToolTipLayerView.prototype.cz = function () { if (this.f.dc == null) { this.cx(true); } }; ItemToolTipLayerView.$t = markType(ItemToolTipLayerView, 'ItemToolTipLayerView', AnnotationLayerView.$); return ItemToolTipLayerView; }(AnnotationLayerView)); export { ItemToolTipLayerView };