UNPKG

igniteui-react-charts

Version:

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

916 lines (915 loc) 31.4 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 { AnnotationLayerView } from "./AnnotationLayerView"; import { Base, Point_$type, markType, runOn, delegateRemove, delegateCombine, typeCast, fromEnum, markDep } from "igniteui-react-core"; import { ImageLoader } from "igniteui-react-core"; import { PointerTooltip } from "./PointerTooltip"; import { TextBlock } from "igniteui-react-core"; import { Rectangle } from "igniteui-react-core"; import { AnnotationBadge } from "./AnnotationBadge"; import { Series } from "./Series"; import { DataContext } from "igniteui-react-core"; import { CalloutView } from "./CalloutView"; import { Size } from "igniteui-react-core"; import { Thickness } from "igniteui-react-core"; import { Rect } from "igniteui-react-core"; import { AxisAnnotationManager } from "./AxisAnnotationManager"; import { PointerTooltipStyle } from "./PointerTooltipStyle"; import { PointerTooltipUtils } from "./PointerTooltipUtils"; import { BrushUtil } from "igniteui-react-core"; import { stringIsNullOrEmpty, stringContains, stringReplace } from "igniteui-react-core"; import { tryParseNumber, isNaN_ } from "igniteui-react-core"; import { AnnotationLayer } from "./AnnotationLayer"; import { DependencyProperty } from "igniteui-react-core"; import { UserAnnotationTooltipLayerFrame } from "./UserAnnotationTooltipLayerFrame"; import { UserAnnotationToolTipContentUpdatingEventArgs } from "./UserAnnotationToolTipContentUpdatingEventArgs"; import { UserAnnotationLayer } from "./UserAnnotationLayer"; import { Tuple$2 } from "igniteui-react-core"; import { CalloutAnnotationWrapper } from "./CalloutAnnotationWrapper"; import { CalloutLayer } from "./CalloutLayer"; import { PropertyMetadata } from "igniteui-react-core"; /** * @hidden */ export let UserAnnotationToolTipLayerView = /*@__PURE__*/ (() => { class UserAnnotationToolTipLayerView extends AnnotationLayerView { constructor(a) { super(a); this.cp = null; this.cq = null; this.co = null; this.c3 = new TextBlock(); this.c5 = new Rectangle(); this.cn = null; this.c7 = null; this.cr = false; this._htmlTest = null; this.cp = a; } a4() { super.a4(); this.cq = new ImageLoader(); this.cn = new AnnotationBadge(this.cq); this.htmlTest = /^[^<]*(<[\w\W]+>)[^>]*$/; } as() { super.as(); let a = this.co; a.content = null; this.co = null; } get htmlTest() { return this._htmlTest; } set htmlTest(a) { this._htmlTest = a; } cu(a, b, c, d, e, f) { let g = c; if (b.ld == "default") { b.ld = b.cw.getDefaultTooltipTemplate(); } let template_ = b.ld; let context_ = d; if (b.toolTip == null) { return false; } let tooltip_ = b.toolTip; if ((tooltip_.updateToolTip)) { tooltip_._inPointer = true; tooltip_.updateToolTip(context_, true); tooltip_.setStyleProperty('position', 'relative'); tooltip_.setStyleProperty('left', ''); tooltip_.setStyleProperty('top', ''); } g.content = b.toolTip; let h = b.toolTip; e.t = 0; e.j = false; h.setStyleProperty("pointer-events", "auto"); g.an.p.setStyleProperty("pointer-events", "auto"); this.c7 = new Thickness(1, 0, 0, 0, 0); let i = h.findByClass("ui-tooltip-container"); if (i.length != 0) { this.cr = true; } if (i.length == 0) { i = h.findByClass("ig-tooltip-container"); } if (i.length == 0) { i = h.findByClass("ig-tooltip-container-background"); } for (let k = 0; k < i.length; k++) { let j = i[k]; j.setStyleProperty("pointer-events", "auto"); j.setStyleProperty("border-radius", e.s + "px"); let l = window.getComputedStyle(j.getNativeElement()); this.c7.top = stringIsNullOrEmpty(l.paddingTop) ? 5 : UserAnnotationToolTipLayerView.cs(l.paddingTop); this.c7.right = stringIsNullOrEmpty(l.paddingRight) ? 5 : UserAnnotationToolTipLayerView.cs(l.paddingRight); this.c7.bottom = stringIsNullOrEmpty(l.paddingBottom) ? 5 : UserAnnotationToolTipLayerView.cs(l.paddingBottom); this.c7.left = stringIsNullOrEmpty(l.paddingLeft) ? 5 : UserAnnotationToolTipLayerView.cs(l.paddingLeft); } let m = h.findByClass("ui-chart-user-annotation-tooltip-main-content"); let n = h.findByClass("ui-chart-user-annotation-tooltip-template-content"); if (m.length > 0) { let o = m[0]; if (e != null) { o.setStyleProperty("height", e.aw().height + "px"); o.setStyleProperty("width", e.aw().width + "px"); e.u = this.c7.left; e.v = this.c7.top; let p = g.an.b; let q = this.co.an.m(); if (q > 0) { p.ac(); p.ad(q, q); } p.ac(); p.ah(f); e.ae(p); p.ab(); if (q > 0) { p.ab(); } } } if (n.length != 1) { return null; } let r = n[0].getNativeElement(); h.setStyleProperty("background", "transparent"); return r; } ct(a, b, c, d, e, f, g, h, i, j) { let k = b; if (a.ld == "default") { a.ld = a.cw.getDefaultTooltipTemplate(); } let template_ = a.ld; let context_ = c; if (a.toolTip == null) { return false; } let tooltip_ = a.toolTip; if ((tooltip_.updateToolTip)) { tooltip_._inPointer = true; tooltip_.updateToolTip(context_, true); tooltip_.setStyleProperty('position', 'relative'); tooltip_.setStyleProperty('left', ''); tooltip_.setStyleProperty('top', ''); } k.content = a.toolTip; let l = a.toolTip; l.setStyleProperty("pointer-events", "auto"); let m = l.findByClass("ui-tooltip-container"); if (m.length != 0) { this.cr = true; } if (m.length == 0) { m = l.findByClass("ig-tooltip-container"); } if (m.length == 0) { m = l.findByClass("ig-tooltip-container-background"); } this.c7 = new Thickness(1, 0, 0, 0, 0); let n = this.cp.ab2(); let o = n.ap; for (let q = 0; q < m.length; q++) { let p = m[q]; p.setStyleProperty("pointer-events", "auto"); p.setStyleProperty("border-radius", o + "px"); let r = window.getComputedStyle(p.getNativeElement()); this.c7.top = stringIsNullOrEmpty(r.paddingTop) ? 5 : UserAnnotationToolTipLayerView.cs(r.paddingTop); this.c7.right = stringIsNullOrEmpty(r.paddingRight) ? 5 : UserAnnotationToolTipLayerView.cs(r.paddingRight); this.c7.bottom = stringIsNullOrEmpty(r.paddingBottom) ? 5 : UserAnnotationToolTipLayerView.cs(r.paddingBottom); this.c7.left = stringIsNullOrEmpty(r.paddingLeft) ? 5 : UserAnnotationToolTipLayerView.cs(r.paddingLeft); } let s = l.findByClass("ui-chart-user-annotation-tooltip-main-content"); let t = l.findByClass("ui-chart-user-annotation-tooltip-template-content"); if (s.length > 0) { let u = s[0]; let v = k.an.b; this.c5._visibility = 0; this.c5.n = 0; this.c5.o = 0; this.c3.dataContext = d.ca(); this.c3._visibility = e._visibility; AxisAnnotationManager.f(j, this.c3); let w = d.a1.ag.q(); let x = d.a1.ag.s(); let y = d.a1.ag.r(); let z = d.a1.ag.p(); this.cn._visibility = f._visibility; let aa = this.c3.al != null && this.c3.al.length > 0; AxisAnnotationManager.e(j, this.cn, aa); this.cn.n = 0; this.cn.o = 0; let ab = this.cn.a7(); let ac = d.a1.ag.ax(this.c3); let ad = Math.max(h.width, ac.width); d.a1.ag.z(this.c3, new Rect(0, ab.width, 0, ad, h.height), 0, 0, 0, 0); this.c3.ao = e.ao; AxisAnnotationManager.g(this.c5, this.c3, this.cn, 102); if (g.i == null) { g.i = new Thickness(1, 0, 0, 0, 0); } d.a1.ag.av(this.c5, this.c3, this.cn, g, new Rect(0, 0, 0, h.width, h.height), w, x, y, z); let ae = this.co.an.m(); if (ae > 0) { v.ac(); v.ad(ae, ae); } v.ac(); v.ak(this.c7.left, this.c7.top); v.w(this.c5); v.ah(this.c3.dataContext); v.y(this.c3); this.cn.ag.d(v); v.ab(); if (ae > 0) { v.ab(); } let af = Math.max(this.c3.l, this.cn.l); u.setStyleProperty("height", af + "px"); if (j.isBadgeEnabled) { u.setStyleProperty("width", this.cn.m + this.cn.bb.right + this.c3.m + "px"); } else { u.setStyleProperty("width", this.c3.m + "px"); } } if (t.length != 1) { return null; } let ag = t[0].getNativeElement(); l.setStyleProperty("background", "transparent"); return ag; } c6(a, b, c, d) { let e = a; let f = e.content; let g = new Size(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); e.a5 = 0; e.a4 = 1.7976931348623157E+308; if (c != null) { let h = c.badgeSize; let i = c.badgeMargin; let j = this.c3.m; e.a5 = h + 2 * i + j + this.c7.left + this.c7.right; } else if (d != null) { let k = d.aw(); e.a5 = k.width + this.c7.left + this.c7.right; } if (this.cr) { let l = e.an.ad(g); e.a4 = l.height - 12; } let m = e.c1(new Size(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)); return m; } c1(a, b, c, d, e, f) { let g = new PointerTooltipStyle(); if (this.f.dc != null) { let h = this.f.dc.dw.j.i(); if (d != null) { PointerTooltipUtils.a(h, g, d.am, d.ao, d.t, d.s); } else { let i = e.outline == null ? BrushUtil.l(0, 0, 0, 0) : e.outline; let j = this.cp.ab2(); PointerTooltipUtils.a(h, g, e.background, i, e.strokeThickness, j.ap); } } let k = a; k.aq = g; let l = k.content; k.cw = { $type: Point_$type, x: 0, y: 0 }; k._visibility = 0; if (e == null) { k.n = b - this.c7.left; k.o = c - this.c7.top; } else { if (e.isBadgeEnabled) { k.n = b; } else { k.n = b; } k.o = c; } } cv() { if (this.co == null) { let a = new PointerTooltip(); a.b0(this.f.ka); a.c2 = 1; this.co = a; } return this.co; } cz(a) { if (a != null) { let b = a; b._visibility = 1; } } bj(a, b) { super.bj(a, b); if (b) { return; } let c = 0; let d = 0; let e = this.f.dc; if (e != null) { let f = e.dw.j.b8(); c += f.x; d += f.y; } if (this.co == null) { return; } let g = this.co.an.n(); this.co.b2(this.co.n * g + c, this.co.o * g + d); let h = this.co.content; if (h == null) { return; } let i = h.findByClass("ui-chart-user-annotation-tooltip-main-content"); let j = h.findByClass("ui-chart-user-annotation-tooltip-template-content"); if (j.length == 1) { this.cp.abm(j[0].getNativeElement()); let k = this.cp.aa2(); let l = this.co.an.b; if (k != null) { k.u = this.c7.left; k.v = this.c7.top; let m = this.co.an.m(); if (m > 0) { l.ac(); l.ad(m, m); } l.ac(); l.ah(this.cp.aba()); k.ae(l); l.ab(); if (m > 0) { l.ab(); } } else { let n = this.cp.aaz(); let o = this.cp.aax(); this.cn.n = 0; this.cn.o = 0; this.c5.n = 0; this.c5.o = 0; let p = this.co.an.m(); if (p > 0) { l.ac(); l.ad(p, p); } l.ac(); l.ak(this.c7.left, this.c7.top); l.w(this.c5); l.ah(this.c3.dataContext); l.y(this.c3); this.cn.ag.d(l); l.ab(); if (p > 0) { l.ab(); } } } } c0(a) { this.a2(); this.cz(this.co); if (a) { this.co.bw(); } } c2() { if (this.f.dc == null) { this.c0(true); } } cx() { if (this.co == null) { let a = new PointerTooltip(); a.b0(this.f.ka); a.c2 = 1; this.co = a; } } cy() { if (this.co == null) { return; } this.co._visibility = 1; } c4(a) { return a; } static cs(a) { if (stringContains(a, "px")) { a = stringReplace(a, "px", ""); } let b = 0; let c = tryParseNumber(a, b); b = c.p1; return b; } } UserAnnotationToolTipLayerView.$t = /*@__PURE__*/ markType(UserAnnotationToolTipLayerView, 'UserAnnotationToolTipLayerView', AnnotationLayerView.$); return UserAnnotationToolTipLayerView; })(); /** * @hidden */ export let UserAnnotationToolTipLayer = /*@__PURE__*/ (() => { class UserAnnotationToolTipLayer extends AnnotationLayer { bk() { return new UserAnnotationToolTipLayer(); } get_eu() { return true; } constructor() { super(); this.aby = null; this.abz = null; this.aau = null; this.abw = null; this.ab0 = null; this.aaw = null; this.aa0 = 0; this.abc = false; this.abs = null; this.aav = null; this.aa3 = null; this.ab1 = null; this.aay = null; this.abb = false; this.abx = null; this.aa5 = null; this.aa1 = null; this.aa9 = null; this.ab3 = null; this.abh = null; this.aa6 = null; this.abd = false; this.contentUpdating = null; let a = new UserAnnotationTooltipLayerFrame(); let b = new UserAnnotationTooltipLayerFrame(); let c = new UserAnnotationTooltipLayerFrame(); let d = this.ko / 1000; this.xz = a; this.xy = b; this.x0 = c; this.ab = UserAnnotationToolTipLayer.$; } ct() { return new UserAnnotationToolTipLayerView(this); } rj(a) { super.rj(a); this.aa8 = a; } g2(a) { if (this.aa4 == null) { return true; } if (this.aa4 == a) { return true; } return false; } rs(a, b, c, d) { super.rs(a, b, c, d); switch (b) { case UserAnnotationToolTipLayer.$$p[1]: case UserAnnotationToolTipLayer.$$p[2]: this.sa(true); break; case UserAnnotationToolTipLayer.$$p[0]: this.sa(true); break; case "SeriesViewer": this.abo(c, d); this.aa8.c2(); break; } } abo(a, b) { if (a != null) { a.axisPanelMouseOver = delegateRemove(a.axisPanelMouseOver, runOn(this, this.abq)); a.axisLabelMouseOver = delegateRemove(a.axisLabelMouseOver, runOn(this, this.abr)); a.axisLabelMouseLeave = delegateRemove(a.axisLabelMouseLeave, runOn(this, this.abp)); this.contentUpdating = delegateRemove(this.contentUpdating, runOn(a, a.rx)); } if (b != null) { b.axisPanelMouseOver = delegateCombine(b.axisPanelMouseOver, runOn(this, this.abq)); b.axisLabelMouseOver = delegateCombine(b.axisLabelMouseOver, runOn(this, this.abr)); b.axisLabelMouseLeave = delegateCombine(b.axisLabelMouseLeave, runOn(this, this.abp)); this.contentUpdating = delegateCombine(this.contentUpdating, runOn(b, b.rx)); } } abq(a, b) { this.aby = b.h; } abp(a, b) { } abr(a, b) { this.abc = false; if (b.a.at.count == 0) { return; } let c = b.a.a1.bi._inner[b.a.hm]; let d = b.a.ch; let e = -1; this.abs = null; for (let f = 0; f < d.a.count; f++) { let g = d.a._inner[f]; if (g == c) { e = f; this.abs = g; this.aav = b.a.cg.item(f); this.aa3 = b.a.es._inner[f]; this.ab1 = b.a.cf.item(f); } } if (e == -1) { return; } this.aay = b.a.at._inner[e]; if (this.aay.ag == null) { return; } for (let h of fromEnum(this.dc.b9)) { let i = typeCast(UserAnnotationLayer.$, h); if (i == null) { continue; } if (Base.equalsStatic(i.yt, this.aay.ag)) { this.aa6 = i; break; } } if (this.aa6 == null) { return; } this.aby = b.h; this.abz = b.a.a1.bf._inner[b.a.hm]; this.aau = b.a.ce.item(b.a.hl); this.aaw = b.a; this.ab0 = b.a.bp.bl(); this.abw = b.a.bp.bi(); this.aa0 = b.a.a1.ai; this.abc = true; this.sa(true); } zf(a, b) { if (this.aa4 == null || this.aa4 == a) { if (!this.a1.c) { this.sa(b); } } } x6(a) { if (a == null) { return false; } if (!a.eq) { return false; } if (a.isValueOverlay) { return false; } if (a == this) { return false; } return a.hm(a.cw.b9, a.cw.ca, a.cw); } zh(a, b) { super.zh(a, b); let c = a; let d = this.abe; c.l = 0; c.m = null; c.k = 0; c.o = null; c.n = null; c.j = 0; c.i = 0; c.p = null; let e = this.abc && isNaN_(this.aar.x); let f = 0; this.aa1 = null; if (this.abd) { } else if (e) { if (this.abc) { this.aa1 = null; if (this.abf(c)) { f = 1; } } else { this.aa8.cz(this.aa8.cv()); return; } } else { this.abc = false; this.aay = null; if (this.x6(this.aa4)) { if (this.abg(this.aa4, c, d, 0)) { f++; } } else { for (let g of fromEnum(this.dc.b9)) { if (this.x6(g)) { if (this.abg(g, c, d, f)) { f++; } } } } } if (f == 1) { this.aa8.cx(); } else if (f == 0) { this.abb = false; this.abc = false; this.aa8.cy(); } } abf(a) { this.aa5 = null; if (this.aay == null) { return false; } if (!this.aay.o) { return false; } let b; let c; b = { $type: Point_$type, x: this.aau.d, y: this.aau.e }; c = this.aby; if (isNaN_(b.x) || isNaN_(b.y)) { return false; } else { this.abb = true; this.abx = c; } this.aa9 = this.aaw.ca(); let d = this.aay.k; let e = d.j(); let f = e; let g = this.aa8.cv(); let h = null; h = new DataContext(); h.item = f; h.series = this.aa6; let i = this.aa8.ct(this.aa6, g, h, this.aaw, this.abs, this.aav, this.aa3, this.abz, null, this.aay); this.ab3 = new Thickness(1, this.aaw.a1.ag.q(), this.aaw.a1.ag.s(), this.aaw.a1.ag.r(), this.aaw.a1.ag.p()); this.abn(i, f); let j = this.aa8.c6(g, h, this.aay, this.aa1); let k = this.cw.b9; let l = b; let m = l.x; let n = l.y; let o = l.x; let p = l.y; let q = l.x; let r = l.y; let s = this.vv; if (s == null) { s = this.v1; } let t = this.dc.yn(this.aar); let u = new Rect(0, b.x, b.y, j.width, j.height); if (!isNaN_(t.x) && !(u.containsPoint(t))) { return false; } this.aa5 = f; a.m = g; a.n = h; a.o = i; a.k = o; a.l = p; a.j = j.width; a.i = j.height; a.p = s; return true; } abg(a, b, c, d) { this.aa5 = null; let e; let f; let g = this.o1(a, this.aar); if (!g.c && !this.abb) { return false; } f = isNaN_(g.d.x) || this.abb ? this.abx : g.d; e = a.wy(f, false, c); if (isNaN_(e.x) || isNaN_(e.y)) { if (!this.abb) { return false; } f = this.abx; e = a.wy(this.abx, false, c); if (isNaN_(e.x) || isNaN_(e.y)) { return false; } } else { this.abb = true; this.abx = f; } let h = typeCast(Tuple$2.$.specialize(CalloutAnnotationWrapper.$, CalloutView.$), a.ky(f)); let i = null; let j = null; if (h != null) { i = h.c; j = h.d; } if (i == null) { return false; } this.abh = i.b.bn; if (this.abh == null) { this.abh = i.b.text; } let k = a.md; if (k == null) { return false; } let l = null; for (let m of fromEnum(this.dc.b9)) { let n = typeCast(UserAnnotationLayer.$, m); if (n == null) { continue; } if (Base.equalsStatic(n.yt, k)) { l = n; break; } } if (l == null) { return false; } this.aa6 = l; let o = i.b.n.b; let p = o.j(); let q = p; let r = i.c.p; let s = i.c.o; let t = i.c.k - r; let u = i.c.l - s; let v = this.w4({ $type: Point_$type, x: t, y: u }); let w = this.aa8.cv(); let x = null; x = new DataContext(); x.item = this.aa6; x.series = this.aa6; this.aa1 = j.b(null); this.aa1.x = this.abh; this.aa1.u = 0; this.aa1.v = 0; let y = typeCast(CalloutLayer.$, a); this.aa9 = y.aa5.cq(); let z = this.aa8.cu(a, l, w, x, this.aa1, this.aa9); if (z == null) { z = a.toolTip; } else { this.abn(z, q); } let aa = this.aa8.c6(w, x, this.aay, this.aa1); let ab = this.cw.b9; let ac = e; let ad = this.xf.top; let ae = this.xf.bottom; let af = this.xf.left; let ag = this.xf.right; ac = this.aa8.c4(e); let ah = ac.x; let ai = ac.y; let aj = ac.x; let ak = ac.y; let al = ac.x; let am = ac.y; let an = this.vv; if (an == null) { an = this.v1; } if (an == null) { an = a.vv; } let ao = this.wt(this.aar); let ap = new Rect(0, al, am, aa.width, aa.height); if (!isNaN_(ao.x) && !(ap.containsPoint(ao))) { return false; } this.aa5 = q; b.m = w; b.n = x; b.o = z; b.k = aj; b.l = ak; b.j = aa.width; b.i = aa.height; b.p = an; return true; } abm(a) { this.abn(a, this.aa5); } aa2() { return this.aa1; } abn(a, b) { if (this.contentUpdating == null) { return; } if (a == null || b == null) { return; } this.contentUpdating(this, ((() => { let $ret = new UserAnnotationToolTipContentUpdatingEventArgs(); $ret.content = a; $ret.annotationInfo = b; return $ret; })())); } qn() { this.aar = { $type: Point_$type, x: NaN, y: NaN }; this.sa(false); this.aa8.c0(false); } qo() { this.aar = { $type: Point_$type, x: NaN, y: NaN }; this.sa(false); this.aa8.c0(true); } zk(a, b) { super.zk(a, b); let c = a; if (isNaN_(c.k) || isNaN_(c.l) || c.o == null || c.n == null) { this.aa8.cz(this.aa8.cv()); return; } let d = c.k; let e = c.l; let f = c.j; let g = c.i; let h = c.m; let i = d; let j = e; if (h != null) { this.aa8.c1(h, i, j, this.aa1, this.aay, this.ab3); } } gi() { return true; } get_gb() { return true; } get_f8() { return true; } gn(a) { return false; } aba() { return this.aa9; } aaz() { return this.aay; } aax() { return this.aaw; } ab2() { return this.ab1; } b3() { return 1; } } UserAnnotationToolTipLayer.$t = /*@__PURE__*/ markType(UserAnnotationToolTipLayer, 'UserAnnotationToolTipLayer', AnnotationLayer.$); UserAnnotationToolTipLayer.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, UserAnnotationToolTipLayer, 'raisePropertyChanged', ['SkipUnknownValues:abe:abt', [0, true], 'TargetSeriesName:abj:abu', [2, null], 'TargetSeries:aa4:abv', [Series.$, null]]); return UserAnnotationToolTipLayer; })();