igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
574 lines (573 loc) • 18.7 kB
JavaScript
/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { Axis } from "./Axis";
import { DependencyProperty } from "igniteui-react-core";
import { CategoryTooltipLayerPosition_$type } from "./CategoryTooltipLayerPosition";
import { Brush } from "igniteui-react-core";
import { Series } from "./Series";
import { CategoryToolTipLayerFrame } from "./CategoryToolTipLayerFrame";
import { Base, enumGetBox, typeCast, fromEnum, Point_$type, markType, markDep, String_$type } from "igniteui-react-core";
import { CategoryTooltipSeriesInfo } from "./CategoryTooltipSeriesInfo";
import { XamDataChart } from "./XamDataChart";
import { List$1 } from "igniteui-react-core";
import { DataContext } from "igniteui-react-core";
import { Size } from "igniteui-react-core";
import { CanvasScalingHelpers } 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
*/
export let CategoryToolTipLayer = /*@__PURE__*/ (() => {
class CategoryToolTipLayer extends AnnotationLayer {
bk() {
return new CategoryToolTipLayer();
}
get_f7() {
return true;
}
get_eu() {
return true;
}
constructor() {
super();
let a = new CategoryToolTipLayerFrame();
let b = new CategoryToolTipLayerFrame();
let c = new CategoryToolTipLayerFrame();
this.xx = a;
this.xw = b;
this.xy = c;
this.ab = CategoryToolTipLayer.$;
}
ct() {
return new CategoryToolTipLayerView(this);
}
rh(a) {
super.rh(a);
this.aau = a;
}
get_e5() {
return true;
}
rq(a, b, c, d) {
super.rq(a, b, c, d);
switch (b) {
case CategoryToolTipLayer.$$p[0]:
this.r8(true);
break;
case CategoryToolTipLayer.$$p[5]:
this.r8(true);
break;
case CategoryToolTipLayer.$$p[4]:
this.r8(true);
break;
case "SeriesViewer":
this.aau.cy();
break;
case CategoryToolTipLayer.$$p[1]:
case CategoryToolTipLayer.$$p[2]:
case CategoryToolTipLayer.$$p[3]:
this.r8(true);
break;
}
}
zc(a, b) {
if (this.aas == a) {
if (!this.a1.c) {
this.r8(b);
}
}
}
zd(a, b) {
if (!this.a1.c) {
this.r8(b);
}
}
zf(a, b) {
super.zf(a, b);
let c = a;
let d = this.aaw;
c.o = NaN;
c.n = NaN;
c.j = NaN;
c.k = NaN;
c.n = NaN;
c.o = NaN;
if (isNaN_(this.aap.x) && isNaN_(this.aap.y)) {
this.aau.cw(this.aau.ct());
return;
}
if (this.aas != null) {
let e = this.aas;
if (e == null || !e.df || e.dc) {
return;
}
if (!e.dx()) {
return;
}
let f = e;
let g = this.aav(f.es, d);
this.aa5(g, c, d);
}
else {
if (typeCast(XamDataChart.$, this.dc) !== null) {
let h = this.dc;
let i = true;
let j = false;
let k = new List$1(Series.$, 0);
for (let l of fromEnum(h.zq)) {
if (l.df && !l.dc) {
if (!l.dx()) {
continue;
}
if (i) {
i = false;
j = l.dy;
}
else {
if (l.dy != j) {
continue;
}
}
for (let m of fromEnum(l.es)) {
k.add(m);
}
}
}
let n = this.aav(k, d);
this.aa5(n, c, d);
}
}
}
aav(a, b) {
let c = 1.7976931348623157E+308;
let d = -1.7976931348623157E+308;
let e = new List$1(DataContext.$, 0);
let f = new List$1(Base.$, 0);
let g = false;
let h = true;
for (let i = 0; i < a.count; i++) {
let j = a.item(i);
if (!j.fa && !j.e1) {
continue;
}
if (j.isStacked) {
continue;
}
let k = j;
if (!k.categoryAxis.dx()) {
continue;
}
if (h) {
g = j.isVertical;
}
else {
if (g != j.isVertical) {
continue;
}
}
let l = this.oz(j, this.aap);
if (!l.c) {
continue;
}
let m = j.ww(l.d, b, false);
if (g) {
if (!isNaN_(m.y)) {
c = Math.min(c, m.y);
d = Math.max(d, m.y);
}
}
else {
if (!isNaN_(m.x)) {
c = Math.min(c, m.x);
d = Math.max(d, m.x);
}
}
let n = this.aay(j);
if (n == null) {
continue;
}
let o = null;
let p = j.kw(this.aap);
if (j.e7 && p != null) {
o = j.a3(p);
}
else {
o = new DataContext();
o.item = p;
o.series = j;
}
e.add(o);
f.add1(n);
}
let q = 0;
let r = 0;
if (g) {
r = (c + d) / 2;
q = this.xd.right;
if (this.aat == 2 || this.aat == 1) {
q = this.xd.left;
}
if (r < 0 || r > this.xd.bottom) {
r = NaN;
}
}
else {
q = (c + d) / 2;
r = this.xd.top;
if (this.aat == 2 || this.aat == 1) {
r = this.xd.bottom;
}
if (q < 0 || q > this.xd.right) {
q = NaN;
}
}
let s = new CategoryTooltipSeriesInfo();
s.c = { $type: Point_$type, x: q, y: r };
s.a = e;
s.b = f;
return s;
}
ql() {
this.aap = { $type: Point_$type, x: NaN, y: NaN };
this.cw.a1();
}
aa5(a, b, c) {
let d = a.c;
let e = CanvasScalingHelpers.c(this.dc.dw.j.ae.rootWrapper);
d = { $type: Point_$type, x: d.x * e, y: d.y * e };
let f = a.a;
let g = a.b;
d = this.aau.cz(d);
let h = 0;
let i = this.cw.b9;
let j = this.aau.ct();
this.aau.cv();
let k = false;
if (f.count == 0) {
this.cw.a1();
return;
}
let l = false;
for (let m = 0; m < f.count; m++) {
let n = f._inner[m].series;
k = n.isVertical;
let o = f._inner[m];
let p = g._inner[m];
if (this.aau.cq(n, p, o)) {
l = true;
}
h++;
}
if (!l) {
this.aau.cw(j);
return;
}
let q = this.aau.c0(j);
let r = 0;
let s = 0;
let t = 0;
let u = 0;
let v = false;
let w = false;
let x = this.aat;
if (x == 2 || x == 3) {
w = true;
}
if (x == 2 || x == 1) {
v = true;
}
let y = this.aau.c1();
if (k) {
if (!v && !w && d.x + (q.width + DeviceUtils.g(10)) > y.width) {
w = true;
}
if (v && !w && d.x - (q.width + DeviceUtils.g(10)) < 0) {
w = true;
}
}
else {
if (!v && !w && d.y - (q.height + 10) < 0) {
w = true;
}
if (v && !w && d.y + (q.height + 10) > y.height) {
w = true;
}
}
let z = DeviceUtils.g(10);
let aa = DeviceUtils.g(5);
if (!v) {
if (!k) {
aa = q.height + z;
}
if (w) {
if (k) {
aa = aa + q.width + z;
}
else {
aa = 0;
}
}
}
else {
if (k) {
aa = q.width + z;
if (w) {
aa = 0;
}
}
else {
aa = DeviceUtils.g(5);
if (w) {
aa = aa + q.height + z;
}
}
}
if (k) {
s = 0 - (z + DeviceUtils.g(5));
if (v) {
s = (s * -1) + q.width;
}
r = q.height / 2;
u = d.y - q.height / 2;
t = d.x - aa;
}
else {
r = q.height + DeviceUtils.g(10) + DeviceUtils.g(5);
if (v) {
r = 0 - (z + DeviceUtils.g(5));
}
s = q.width / 2;
t = d.x - q.width / 2;
u = d.y - aa;
}
if (k) {
if (u < 0) {
r -= 0 - u;
u = 0;
}
if (u + q.height > y.height) {
r += (u + q.height) - y.height;
u = y.height - q.height;
}
}
else {
if (t < 0) {
s -= 0 - t;
t = 0;
}
if (t + q.width > y.width) {
s += (t + q.width) - y.width;
t = y.width - q.width;
}
}
b.n = t;
b.o = u;
b.j = s;
b.k = r;
b.m = q.width;
b.l = q.height;
}
aay(a) {
return a.toolTip;
}
zi(a, b) {
super.zi(a, b);
let c = a;
let d = b.b9.left;
let e = b.b9.right;
let f = b.b9.top;
let g = b.b9.bottom;
let h = this.aau.ct();
if (isNaN_(c.n) || isNaN_(c.o) || isNaN_(c.j) || isNaN_(c.k)) {
this.aau.cw(h);
return;
}
let i = c.n;
let j = c.o;
let k = c.j;
let l = c.k;
if (h != null) {
this.aau.cx(h, i, j, k, l);
}
}
gg() {
return true;
}
}
CategoryToolTipLayer.$t = /*@__PURE__*/ markType(CategoryToolTipLayer, 'CategoryToolTipLayer', AnnotationLayer.$);
CategoryToolTipLayer.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryToolTipLayer, 'raisePropertyChanged', ['TargetAxis:aas:aa6', [Axis.$, null], 'ToolTipBackground:abc:aa7', [Brush.$, null], 'ToolTipBorderBrush:abd:aa8', [Brush.$, null], 'ToolTipBorderThickness:aax:aa9', [1, NaN], 'ToolTipPosition:aat:aba', [CategoryTooltipLayerPosition_$type, /*@__PURE__*/ enumGetBox(CategoryTooltipLayerPosition_$type, 0)], 'UseInterpolation:aaw:abb', [0, false]]);
return CategoryToolTipLayer;
})();
/**
* @hidden
*/
export let CategoryToolTipLayerView = /*@__PURE__*/ (() => {
class CategoryToolTipLayerView extends AnnotationLayerView {
constructor(a) {
super(a);
this.cn = null;
this.co = null;
this._tooltips = null;
this.cr = null;
this.cp = false;
this._htmlTest = null;
this.cn = a;
this.htmlTest = /^[^<]*(<[\w\W]+>)[^>]*$/;
}
ct() {
if (this.co == null) {
this.co = new PointerTooltip();
this.co.b0(this.f.j8);
this.co.ap = this.f.dc.dw.k;
this._tooltips = this.f.j8.createElement("div");
this.cr = this.f.j8.createElement("div");
this.co._visibility = 0;
}
return this.co;
}
a4() {
super.a4();
if (this.co != null) {
this.co._visibility = 1;
}
}
as() {
super.as();
if (this.co != null) {
this.co.bv();
this.co = null;
}
}
get htmlTest() {
return this._htmlTest;
}
set htmlTest(a) {
this._htmlTest = a;
}
cq(a, b, c) {
if (a.lb == "default") {
a.lb = a.cw.getDefaultTooltipTemplate();
}
let template_ = a.lb;
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', '');
tooltip_.remove();
}
this._tooltips.append(a.toolTip);
return true;
}
c0(a) {
let b = a;
b.content = this._tooltips;
let c = new Size(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
b.c2 = 1;
let d = b.c1(new Size(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY));
b.c2 = 0;
return d;
}
cz(a) {
let b = 0;
let c = 0;
if (this.f.dc != null) {
let d = this.f.dc.yk();
b += d.x;
c += d.y;
}
return { $type: Point_$type, x: b + a.x, y: c + a.y };
}
cx(a, b, c, d, e) {
let f = a;
let g = f.content;
f.cw = { $type: Point_$type, x: d, y: e };
f._visibility = 0;
f.n = b;
f.o = c;
}
c1() {
let a = (window.innerWidth);
let b = (window.innerHeight);
return new Size(1, a, b);
}
cw(a) {
this._tooltips.removeChildren();
this.cr.removeChildren();
this.co._visibility = 1;
}
cv() {
if (this._tooltips != null) {
this._tooltips.removeChildren();
}
}
cy() {
}
bj(a, b) {
super.bj(a, b);
if (b) {
return;
}
let c = new PointerTooltipStyle();
if (this.f.dc != null && this.f.dc.dw != null && this.f.dc.dw.j != null) {
let d = this.f.dc.dw.j.i();
c = new PointerTooltipStyle();
PointerTooltipUtils.a(d, c, this.cn.abc, this.cn.abd, this.cn.aax, 0);
}
let e = 0;
let f = 0;
let g = this.f.dc;
if (g != null) {
let h = g.dw.j.b8();
e += h.x;
f += h.y;
}
if (this.co != null) {
this.co.aq = c;
this.co.b2(this.co.n, this.co.o);
}
}
ax(a) {
super.ax(a);
let b = this.co;
let c = 0;
let d = 0;
if (this.f.dc != null) {
let e = this.f.dc.yk();
c += e.x;
d += e.y;
}
let f = b.a9();
let g = b.n - c;
let h = b.o - d;
let i = new List$1(String_$type, 0);
let j = this._tooltips.getChildCount();
for (let k = 0; k < j; k++) {
let indexliteral_ = k.toString();
let l = this._tooltips.getChildAt(k).getText();
let m = l.toString();
i.add(m);
}
this.f.bc.addPointerTooltipData(a, f, g, h, i);
}
}
CategoryToolTipLayerView.$t = /*@__PURE__*/ markType(CategoryToolTipLayerView, 'CategoryToolTipLayerView', AnnotationLayerView.$);
return CategoryToolTipLayerView;
})();