igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
669 lines (668 loc) • 25.3 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 } 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.yb = 0;
_this.yc = 0;
_this.xy = 0;
_this.xd = null;
_this.xr = null;
_this.xq = null;
_this.stylingOverlayText = null;
_this.xi = null;
_this.ab = ValueOverlay.$;
_this.xi = OverlayTextUtil.c();
return _this;
}
ValueOverlay.prototype.bk = function () {
return new ValueOverlay();
};
ValueOverlay.prototype.i8 = function (a, b, c) {
return this.yd;
};
ValueOverlay.prototype.xz = 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.wn = function (a, b, c) {
if (this.xc == null) {
return { $type: Point_$type, x: NaN, y: NaN };
}
var d = this.ya();
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.xc.bk) {
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.xz(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.j7 = function (a) {
throw new NotImplementedException(0);
};
ValueOverlay.prototype.kr = function (a) {
return this;
};
ValueOverlay.prototype.ge = function (a) {
return false;
};
ValueOverlay.prototype.ay = function (a) {
var b = typeCast(NumericAxisBase.$, a);
var c = this.yd;
if (isNaN_(c) || isInfinity(c)) {
return null;
}
return new AxisRange(c, c);
};
ValueOverlay.prototype.r0 = function (a) {
this.pb(true, this.cw);
if (!this.xp()) {
if (this.xd != null) {
this.zl(NaN, this.d4());
}
return;
}
if (this.gg(a)) {
if (this.d4()) {
if (this.dd.g) {
this.dd.t();
}
var b = this.yb;
this.yb = this.yc;
this.yc = b;
}
else {
this.yb = this.xy;
}
this.xy = this.ya();
this.sg();
}
else {
this.xy = this.ya();
this.zk(this.xy, this.xh);
}
};
ValueOverlay.prototype.ya = 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.xc.df, d);
return this.xc.ft(this.yd, e);
};
ValueOverlay.prototype.zk = function (a, b) {
if (this.xc == null) {
return;
}
var c = typeCast(CategoryAxisBase.$, this.xc);
if (c != null && !c.dc) {
if (this.yd > c.o6 - 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.dq && !c.df) {
f = true;
}
if (typeCast(CategoryXAxis.$, c) !== null && c.df) {
f = true;
}
if (f) {
e = -e;
}
a += e;
}
}
var g = typeCast(NumericAxisBase.$, this.xc);
if (g != null) {
if (this.yd < g.pr || this.yd > g.pq) {
return;
}
if (g.pc && this.yd < 0) {
return;
}
}
var h;
switch (this.xc.bk) {
case 2:
case 3:
h = this.xc.ns(a, b.ca, b.b9, this.getEffectiveViewport1(b), this.wu(b));
break;
default:
h = this.xc.ns(a, b.ca, b.b9, this.getEffectiveViewport1(b), this.wu(b));
break;
}
if (h != null) {
b.cp(h);
}
if (!b.t) {
this.zl(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.xc == null || this.xc.b0 == null) {
d = false;
}
return d;
};
ValueOverlay.prototype.s0 = function (a, b) {
this.rz(false);
};
ValueOverlay.prototype.sz = function (a, b) {
this.rz(false);
};
ValueOverlay.prototype.ph = function (a, b, c, d) {
throw new NotImplementedException(0);
};
ValueOverlay.prototype.rh = function (a, b, c, d) {
_super.prototype.rh.call(this, a, b, c, d);
switch (b) {
case ValueOverlay.$$p[11]:
if (c != null) {
c.cq(this);
}
if (d != null) {
d.du(this);
}
this.rz(false);
this.qs();
break;
case "TransitionProgress":
this.yc = this.yb + this.ju * (this.xy - this.yb);
if (this.d7(this.cw)) {
return;
}
if (this.ju == 1) {
this.zk(this.xy, this.xh);
this.qv();
}
else {
this.zk(this.yc, this.xh);
}
if (this.dc != null) {
this.dc.r0(this);
}
break;
case ValueOverlay.$$p[35]:
var e = typeCast(NumericAxisBase.$, this.xc);
if (e != null) {
e.d2();
}
this.rz(true);
this.qt();
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.rz(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.rz(true);
break;
case "SeriesViewer":
if (d == null) {
if (this.xq != null && this.xq.count > 0 && this.xd != null) {
this.zl(NaN, this.d4());
}
}
break;
}
};
ValueOverlay.prototype.qh = function () {
_super.prototype.qh.call(this);
if (this.xc != null) {
this.xc.k3(false);
}
};
ValueOverlay.prototype.pb = function (a, b) {
_super.prototype.pb.call(this, a, b);
var c = b;
c.ci();
};
ValueOverlay.prototype.xp = function () {
if (this.xc == null || this.xc.b0 == null || isNaN_(this.yd) || this._visibility != 0) {
return false;
}
var a = typeCast(CategoryAxisBase.$, this.xc);
if (a != null && a.o6 == 0) {
return false;
}
return true;
};
ValueOverlay.prototype.preferredCategoryMode = function (a) {
return 0;
};
Object.defineProperty(ValueOverlay.prototype, "categoryAxis", {
get: function () {
return typeCast(CategoryAxisBase.$, this.xc);
},
enumerable: false,
configurable: true
});
ValueOverlay.prototype.ct = function () {
return new ValueOverlayView(this);
};
ValueOverlay.prototype.q8 = function (a) {
_super.prototype.q8.call(this, a);
this.xh = typeCast(ValueOverlayView.$, a);
};
ValueOverlay.prototype.r1 = function (a, b) {
_super.prototype.r1.call(this, a, b);
if (!this.g1) {
this.cw.be(b);
return;
}
this.cw.be(b);
if (this.d7(this.cv) || !this.xp()) {
return;
}
var c = this.getEffectiveViewport1(this.cw);
var d = this.xc.ft(this.yd, new ScalerParams(0, this.cv.ca, a, this.xc.df, c));
this.zk(d, typeCast(ValueOverlayView.$, this.cv));
this.g1 = false;
};
ValueOverlay.prototype.getOffsetValue = function () {
return 0;
};
ValueOverlay.prototype.getCategoryWidth = function () {
return 0;
};
Object.defineProperty(ValueOverlay.prototype, "aas", {
get: function () {
return new Thickness(1, this.xu, this.xw, this.xv, this.xt);
},
enumerable: false,
configurable: true
});
ValueOverlay.prototype.ai = function () {
return [this.xc];
};
ValueOverlay.prototype.zj = function () {
if (OverlayTextUtil.q(this.xi)) {
this.xi = OverlayTextUtil.c();
}
else if (OverlayTextUtil.k(this.xi)) {
this.xi = this.cw.l(this.xi.fontString);
}
};
ValueOverlay.prototype.zl = function (a, b) {
if (isNaN_(a)) {
if (this.xd != null) {
AxisAnnotationFrameManager.b(this.xd);
AxisAnnotationFrameManager.d(this, this.xd, true, this.xq, this.xr, b, this.ye, this.ye, this.xe, this.xe);
}
return;
}
var c = false;
if (this.xq == null) {
c = true;
this.xr = new List$1(Axis.$, 0);
this.xq = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
}
this.xd = new AxisAnnotationFrame();
var d = this.vk;
if (d == null) {
d = this.vq;
}
this.xh.ch();
if (this.xc.bk == 0 || this.xc.bk == 1) {
this.zj();
var e = this.xj;
var f = OverlayTextUtil.o(e, this.xo);
var g = this.xf;
if (g == 18) {
f = false;
}
if (f && !stringIsNullOrEmpty(this.yu)) {
var h = this.xc.dq;
var i = this.vk;
var j = this.aar;
if (j == null && this.xn) {
j = i;
}
var k = this.aap;
if (k == null && this.xl) {
k = i;
}
var l = this.aaq;
if (l == null && this.xm) {
l = i;
}
var m = new OverlayTextUpdatingEventArgs();
m.textLocation = this.xf;
m.textAngle = this.x0;
m.textVisible = this.xo;
m.textContent = this.yu;
m.textColorMode = this.xb;
m.textColorShift = this.x5;
m.textColor = j;
m.backgroundMode = this.w9;
m.backgroundShift = this.x1;
m.background = k;
m.borderMode = this.xa;
m.borderShift = this.x3;
m.borderStroke = l;
m.borderRadius = this.x2;
m.borderThickness = this.x4;
m.shapeBrush = this.vk;
m.shapeOutline = this.vo;
m.f = h;
m.horizontalMargin = this.x6;
m.verticalPadding = this.x9;
m.verticalMargin = this.x8;
m.horizontalPadding = this.x7;
if (this.stylingOverlayText != null) {
this.stylingOverlayText(this, m);
}
OverlayTextUtil.ad(m);
var n = OverlayTextInfo.d(m);
if (n.textVisible && !n.h) {
this.xh.ce.count = 1;
this.xh.cd.count = 1;
n.f = e;
n.ad = this.cw.cc(n.textContent, n.f);
n.u = this.xh.ce.item(0);
n.ac = this.xh.cd.item(0);
if (n.g) {
var o = this.dc.xf({ $type: Point_$type, x: 0, y: NaN });
var p = this.dc.xf({ $type: Point_$type, x: 1, y: NaN });
var q = p.x - o.x;
n.ab = new Rect(0, o.x, a, q, 1);
}
else {
var r = this.dc.xf({ $type: Point_$type, x: NaN, y: 0 });
var s = this.dc.xf({ $type: Point_$type, x: NaN, y: 1 });
var t = s.y - r.y;
n.ab = new Rect(0, a, r.y, 1, t);
}
OverlayTextUtil.ac(n);
this.cw.av(n.u, n.f);
this.cw.aw(n.u, n.f);
}
}
}
var u = this.xc.dq;
AxisAnnotationFrameManager.c(this.xd, { $type: Point_$type, x: a, y: a }, this, this.dc, this.getEffectiveViewport(), d, this.aam, this.xs, this.aao, this.aan, this.aas, this.xx, this.aam, this.xs, this.aao, this.aan, this.aas, this.xx, !u && this.xk, u && this.xk);
AxisAnnotationFrameManager.d(this, this.xd, c, this.xq, this.xr, b, this.ye, this.ye, this.xe, this.xe);
};
ValueOverlay.prototype.get_isValueOverlay = function () {
return true;
};
ValueOverlay.prototype.yr = function (a) {
if (this.xc != null) {
return this.xc.ih(a);
}
return null;
};
Object.defineProperty(ValueOverlay.prototype, "yt", {
get: function () {
var a = this.yr(this.yd);
return a != null ? a : stringFormat("{0:0.##}", this.yd);
},
enumerable: false,
configurable: true
});
Object.defineProperty(ValueOverlay.prototype, "xj", {
get: function () {
return this.xi;
},
set: function (a) {
var b = this.xi;
if (OverlayTextUtil.q(a)) {
a = OverlayTextUtil.c();
}
this.xi = a;
if (b != this.xi) {
this.raisePropertyChanged("OverlayTextStyle", b, this.xi);
}
},
enumerable: false,
configurable: true
});
ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:xs:zm', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:aam:zn', [Brush.$, null], 'AxisAnnotationFormatLabel:xe:zo', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:ye:zp', [1, -1], 'AxisAnnotationOutline:aan:zq', [Brush.$, null], 'AxisAnnotationPaddingBottom:xt:zr', [1, NaN], 'AxisAnnotationPaddingLeft:xu:zs', [1, NaN], 'AxisAnnotationPaddingRight:xv:zt', [1, NaN], 'AxisAnnotationPaddingTop:xw:zu', [1, NaN], 'AxisAnnotationStrokeThickness:xx:zv', [1, NaN], 'AxisAnnotationTextColor:aao:zw', [Brush.$, null], 'Axis:xc:zx', [Axis.$, null], 'IsAxisAnnotationEnabled:xk:zy', [0, false], 'OverlayTextAngle:x0:zz', [1, NaN], 'OverlayTextBackgroundMatchLayer:xl:z0', [0, false], 'OverlayTextBackgroundMode:w9:z1', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextBackground:aap:z2', [Brush.$, null], 'OverlayTextBackgroundShift:x1:z3', [1, NaN], 'OverlayTextBorderColor:aaq:z4', [Brush.$, null], 'OverlayTextBorderMatchLayer:xm:z5', [0, false], 'OverlayTextBorderMode:xa:z6', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextBorderRadius:x2:z7', [1, NaN], 'OverlayTextBorderShift:x3:z8', [1, NaN], 'OverlayTextBorderThickness:x4:z9', [1, 1], 'OverlayTextColorMatchLayer:xn:aaa', [0, true], 'OverlayTextColorMode:xb:aab', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'OverlayTextColor:aar:aac', [Brush.$, null], 'OverlayTextColorShift:x5:aad', [1, NaN], 'OverlayTextHorizontalMargin:x6:aae', [1, NaN], 'OverlayTextHorizontalPadding:x7:aaf', [1, NaN], 'OverlayTextLocation:xf:aag', [OverlayTextLocation_$type, enumGetBox(OverlayTextLocation_$type, 0)], 'OverlayText:yu:aah', [2, null], 'OverlayTextVerticalMargin:x8:aai', [1, NaN], 'OverlayTextVerticalPadding:x9:aaj', [1, NaN], 'OverlayTextVisible:xo:aak', [0, true], 'Value:yd:aal', [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.vk;
this.cr.ad = this.f.ig;
this.cr.ai = this.f.wd;
this.cr.aj = this.f.we;
};
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.ae(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 };