igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
614 lines (613 loc) • 19.9 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 { __extends, __values } from "tslib";
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
*/
var CategoryToolTipLayer = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(CategoryToolTipLayer, _super);
function CategoryToolTipLayer() {
var _this = _super.call(this) || this;
var a = new CategoryToolTipLayerFrame();
var b = new CategoryToolTipLayerFrame();
var c = new CategoryToolTipLayerFrame();
_this.xx = a;
_this.xw = b;
_this.xy = c;
_this.ab = CategoryToolTipLayer.$;
return _this;
}
CategoryToolTipLayer.prototype.bk = function () {
return new CategoryToolTipLayer();
};
CategoryToolTipLayer.prototype.get_f7 = function () {
return true;
};
CategoryToolTipLayer.prototype.get_eu = function () {
return true;
};
CategoryToolTipLayer.prototype.ct = function () {
return new CategoryToolTipLayerView(this);
};
CategoryToolTipLayer.prototype.rh = function (a) {
_super.prototype.rh.call(this, a);
this.aau = a;
};
CategoryToolTipLayer.prototype.get_e5 = function () {
return true;
};
CategoryToolTipLayer.prototype.rq = function (a, b, c, d) {
_super.prototype.rq.call(this, 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;
}
};
CategoryToolTipLayer.prototype.zc = function (a, b) {
if (this.aas == a) {
if (!this.a1.c) {
this.r8(b);
}
}
};
CategoryToolTipLayer.prototype.zd = function (a, b) {
if (!this.a1.c) {
this.r8(b);
}
};
CategoryToolTipLayer.prototype.zf = function (a, b) {
var e_1, _a, e_2, _b;
_super.prototype.zf.call(this, a, b);
var c = a;
var 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) {
var e = this.aas;
if (e == null || !e.df || e.dc) {
return;
}
if (!e.dx()) {
return;
}
var f = e;
var g = this.aav(f.es, d);
this.aa5(g, c, d);
}
else {
if (typeCast(XamDataChart.$, this.dc) !== null) {
var h = this.dc;
var i = true;
var j = false;
var k = new List$1(Series.$, 0);
try {
for (var _c = __values(fromEnum(h.zq)), _d = _c.next(); !_d.done; _d = _c.next()) {
var l = _d.value;
if (l.df && !l.dc) {
if (!l.dx()) {
continue;
}
if (i) {
i = false;
j = l.dy;
}
else {
if (l.dy != j) {
continue;
}
}
try {
for (var _e = (e_2 = void 0, __values(fromEnum(l.es))), _f = _e.next(); !_f.done; _f = _e.next()) {
var m = _f.value;
k.add(m);
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_f && !_f.done && (_b = _e.return))
_b.call(_e);
}
finally {
if (e_2)
throw e_2.error;
}
}
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_d && !_d.done && (_a = _c.return))
_a.call(_c);
}
finally {
if (e_1)
throw e_1.error;
}
}
var n = this.aav(k, d);
this.aa5(n, c, d);
}
}
};
CategoryToolTipLayer.prototype.aav = function (a, b) {
var c = 1.7976931348623157E+308;
var d = -1.7976931348623157E+308;
var e = new List$1(DataContext.$, 0);
var f = new List$1(Base.$, 0);
var g = false;
var h = true;
for (var i = 0; i < a.count; i++) {
var j = a.item(i);
if (!j.fa && !j.e1) {
continue;
}
if (j.isStacked) {
continue;
}
var k = j;
if (!k.categoryAxis.dx()) {
continue;
}
if (h) {
g = j.isVertical;
}
else {
if (g != j.isVertical) {
continue;
}
}
var l = this.oz(j, this.aap);
if (!l.c) {
continue;
}
var 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);
}
}
var n = this.aay(j);
if (n == null) {
continue;
}
var o = null;
var 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);
}
var q = 0;
var 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;
}
}
var s = new CategoryTooltipSeriesInfo();
s.c = { $type: Point_$type, x: q, y: r };
s.a = e;
s.b = f;
return s;
};
CategoryToolTipLayer.prototype.ql = function () {
this.aap = { $type: Point_$type, x: NaN, y: NaN };
this.cw.a1();
};
CategoryToolTipLayer.prototype.aa5 = function (a, b, c) {
var d = a.c;
var e = CanvasScalingHelpers.c(this.dc.dw.j.ae.rootWrapper);
d = { $type: Point_$type, x: d.x * e, y: d.y * e };
var f = a.a;
var g = a.b;
d = this.aau.cz(d);
var h = 0;
var i = this.cw.b9;
var j = this.aau.ct();
this.aau.cv();
var k = false;
if (f.count == 0) {
this.cw.a1();
return;
}
var l = false;
for (var m = 0; m < f.count; m++) {
var n = f._inner[m].series;
k = n.isVertical;
var o = f._inner[m];
var p = g._inner[m];
if (this.aau.cq(n, p, o)) {
l = true;
}
h++;
}
if (!l) {
this.aau.cw(j);
return;
}
var q = this.aau.c0(j);
var r = 0;
var s = 0;
var t = 0;
var u = 0;
var v = false;
var w = false;
var x = this.aat;
if (x == 2 || x == 3) {
w = true;
}
if (x == 2 || x == 1) {
v = true;
}
var 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;
}
}
var z = DeviceUtils.g(10);
var 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;
};
CategoryToolTipLayer.prototype.aay = function (a) {
return a.toolTip;
};
CategoryToolTipLayer.prototype.zi = function (a, b) {
_super.prototype.zi.call(this, a, b);
var c = a;
var d = b.b9.left;
var e = b.b9.right;
var f = b.b9.top;
var g = b.b9.bottom;
var h = this.aau.ct();
if (isNaN_(c.n) || isNaN_(c.o) || isNaN_(c.j) || isNaN_(c.k)) {
this.aau.cw(h);
return;
}
var i = c.n;
var j = c.o;
var k = c.j;
var l = c.k;
if (h != null) {
this.aau.cx(h, i, j, k, l);
}
};
CategoryToolTipLayer.prototype.gg = function () {
return true;
};
CategoryToolTipLayer.$t = markType(CategoryToolTipLayer, 'CategoryToolTipLayer', AnnotationLayer.$);
CategoryToolTipLayer.$$p = 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, enumGetBox(CategoryTooltipLayerPosition_$type, 0)], 'UseInterpolation:aaw:abb', [0, false]]);
return CategoryToolTipLayer;
}(AnnotationLayer));
export { CategoryToolTipLayer };
/**
* @hidden
*/
var CategoryToolTipLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(CategoryToolTipLayerView, _super);
function CategoryToolTipLayerView(a) {
var _this = _super.call(this, a) || this;
_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]+>)[^>]*$/;
return _this;
}
CategoryToolTipLayerView.prototype.ct = function () {
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;
};
CategoryToolTipLayerView.prototype.a4 = function () {
_super.prototype.a4.call(this);
if (this.co != null) {
this.co._visibility = 1;
}
};
CategoryToolTipLayerView.prototype.as = function () {
_super.prototype.as.call(this);
if (this.co != null) {
this.co.bv();
this.co = null;
}
};
Object.defineProperty(CategoryToolTipLayerView.prototype, "htmlTest", {
get: function () {
return this._htmlTest;
},
set: function (a) {
this._htmlTest = a;
},
enumerable: false,
configurable: true
});
CategoryToolTipLayerView.prototype.cq = function (a, b, c) {
if (a.lb == "default") {
a.lb = a.cw.getDefaultTooltipTemplate();
}
var template_ = a.lb;
var context_ = c;
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', '');
tooltip_.remove();
}
this._tooltips.append(a.toolTip);
return true;
};
CategoryToolTipLayerView.prototype.c0 = function (a) {
var b = a;
b.content = this._tooltips;
var c = new Size(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
b.c2 = 1;
var d = b.c1(new Size(1, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY));
b.c2 = 0;
return d;
};
CategoryToolTipLayerView.prototype.cz = function (a) {
var b = 0;
var c = 0;
if (this.f.dc != null) {
var d = this.f.dc.yk();
b += d.x;
c += d.y;
}
return { $type: Point_$type, x: b + a.x, y: c + a.y };
};
CategoryToolTipLayerView.prototype.cx = function (a, b, c, d, e) {
var f = a;
var g = f.content;
f.cw = { $type: Point_$type, x: d, y: e };
f._visibility = 0;
f.n = b;
f.o = c;
};
CategoryToolTipLayerView.prototype.c1 = function () {
var a = (window.innerWidth);
var b = (window.innerHeight);
return new Size(1, a, b);
};
CategoryToolTipLayerView.prototype.cw = function (a) {
this._tooltips.removeChildren();
this.cr.removeChildren();
this.co._visibility = 1;
};
CategoryToolTipLayerView.prototype.cv = function () {
if (this._tooltips != null) {
this._tooltips.removeChildren();
}
};
CategoryToolTipLayerView.prototype.cy = function () {
};
CategoryToolTipLayerView.prototype.bj = function (a, b) {
_super.prototype.bj.call(this, a, b);
if (b) {
return;
}
var c = new PointerTooltipStyle();
if (this.f.dc != null && this.f.dc.dw != null && this.f.dc.dw.j != null) {
var d = this.f.dc.dw.j.i();
c = new PointerTooltipStyle();
PointerTooltipUtils.a(d, c, this.cn.abc, this.cn.abd, this.cn.aax, 0);
}
var e = 0;
var f = 0;
var g = this.f.dc;
if (g != null) {
var 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);
}
};
CategoryToolTipLayerView.prototype.ax = function (a) {
_super.prototype.ax.call(this, a);
var b = this.co;
var c = 0;
var d = 0;
if (this.f.dc != null) {
var e = this.f.dc.yk();
c += e.x;
d += e.y;
}
var f = b.a9();
var g = b.n - c;
var h = b.o - d;
var i = new List$1(String_$type, 0);
var j = this._tooltips.getChildCount();
for (var k = 0; k < j; k++) {
var indexliteral_ = k.toString();
var l = this._tooltips.getChildAt(k).getText();
var m = l.toString();
i.add(m);
}
this.f.bc.addPointerTooltipData(a, f, g, h, i);
};
CategoryToolTipLayerView.$t = markType(CategoryToolTipLayerView, 'CategoryToolTipLayerView', AnnotationLayerView.$);
return CategoryToolTipLayerView;
}(AnnotationLayerView));
export { CategoryToolTipLayerView };