igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
762 lines (761 loc) • 27.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, __values } from "tslib";
import { AnnotationLayer } from "./AnnotationLayer";
import { ValueLayerValueMode_$type } from "./ValueLayerValueMode";
import { DependencyProperty } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { Series } from "./Series";
import { Axis } from "./Axis";
import { Base, enumGetBox, Delegate_$type, Number_$type, typeCast, fromEnum, Point_$type, markType, markDep, runOn } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { Visibility_$type } from "igniteui-react-core";
import { ValueLayerFrame } from "./ValueLayerFrame";
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 { DataLegendSeriesContext } from "igniteui-react-core";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { DoubleCollection } from "igniteui-react-core";
import { DeviceUtils } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { Tuple$2 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { PathGeometry } from "igniteui-react-core";
import { PathFigure } from "igniteui-react-core";
import { LineSegment } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { Defaults } from "./Defaults";
import { TranslateTransform } from "igniteui-react-core";
import { LineGeometry } from "igniteui-react-core";
/**
* @hidden
*/
var ValueLayer = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ValueLayer, _super);
function ValueLayer() {
var _this = _super.call(this) || this;
_this.z7 = [NaN, NaN];
_this.aab = null;
_this.aac = null;
_this.adf = null;
_this.aam = null;
_this.aal = null;
var a = new ValueLayerFrame();
var b = new ValueLayerFrame();
var c = new ValueLayerFrame();
var d = _this.kd / 1000;
_this.xe = a;
_this.xd = b;
_this.xf = c;
_this.ab = ValueLayer.$;
return _this;
}
ValueLayer.prototype.bk = function () {
return new ValueLayer();
};
ValueLayer.prototype.get_eu = function () {
return true;
};
ValueLayer.prototype.ct = function () {
return new ValueLayerView(this);
};
ValueLayer.prototype.q1 = function (a) {
_super.prototype.q1.call(this, a);
this.aag = a;
};
ValueLayer.prototype.gu = function (a) {
if (this.aad == null) {
return true;
}
if (this.aad == a) {
return true;
}
return false;
};
Object.defineProperty(ValueLayer.prototype, "adh", {
get: function () {
return new Thickness(1, this.aap, this.aar, this.aaq, this.aao);
},
enumerable: false,
configurable: true
});
Object.defineProperty(ValueLayer.prototype, "adi", {
get: function () {
return new Thickness(1, this.aav, this.aax, this.aaw, this.aau);
},
enumerable: false,
configurable: true
});
ValueLayer.prototype.mc = function () {
return "Value Layer";
};
ValueLayer.prototype.get_isSummarizationSupported = function () {
return false;
};
ValueLayer.prototype.i5 = function (a, b, c) {
if (isNaN_(this.z7[0]) && isNaN_(this.z7[1])) {
return _super.prototype.i5.call(this, a, b, c);
}
if (!isNaN_(this.z7[0])) {
return this.z7[0];
}
return this.z7[1];
};
ValueLayer.prototype.getDataLegendSeriesContextAt = function (a, b) {
if (isNaN_(this.z7[0]) || isNaN_(this.z7[1])) {
return _super.prototype.getDataLegendSeriesContextAt.call(this, a, b);
}
if (this.aad == null) {
var c_1 = new DataLegendSeriesValueInfo();
c_1.l = this.z7[0];
c_1.a = 0;
c_1.q = "Value";
c_1.r = "Value";
c_1.s = "";
var d_1 = new DataLegendSeriesValueInfo();
d_1.l = this.z7[1];
d_1.a = 0;
d_1.q = "Value";
d_1.r = "Value";
d_1.s = "";
var e = new DataLegendSeriesContext();
e.e = ((function () {
var $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
$ret.add(c_1);
$ret.add(d_1);
return $ret;
})());
e.h = this.mc();
return e;
}
var f = this.aad.getDataLegendSeriesContextAt(a, b);
var g = typeCast(DataLegendSeriesContext.$, f);
if (g == null || g.e == null) {
return _super.prototype.getDataLegendSeriesContextAt.call(this, a, b);
}
if (g.e.count == 0) {
g.e._inner[0].l = isNaN_(this.z7[0]) ? this.z7[1] : this.z7[0];
}
else {
g.e._inner[0].l = this.z7[0];
g.e._inner[1].l = this.z7[1];
}
return g;
};
ValueLayer.prototype.yt = function (a, b) {
if (this.aad == null || this.aad == a) {
if (!this.a1.c) {
this.rs(b);
}
}
};
ValueLayer.prototype.yv = function (a, b) {
var e_1, _a, e_2, _b;
_super.prototype.yv.call(this, a, b);
var c = a;
var d = this.aak;
var e = this.aaj;
c.af.clear();
c.ag.clear();
c.ae.clear();
c.ah.clear();
AxisAnnotationFrameManager.b(c);
this.z7 = [NaN, NaN];
this.aab = null;
this.aac = null;
var f = this.aae();
if (this.xk(this.aad)) {
var g = this.aad.aq(f);
this.z7 = g;
this.ab3(c, d, e, this.aad);
}
else {
if (f == 5 || f == 4 || f == 6) {
var h = null;
var i = null;
var j = [NaN, NaN];
var k = 0;
try {
for (var _c = __values(fromEnum(this.dc.series)), _d = _c.next(); !_d.done; _d = _c.next()) {
var l = _d.value;
if (!this.xk(l)) {
continue;
}
var m = l.ai();
for (var o = 0; o < m.length; o++) {
var n = m[o];
if (!this.aai(n)) {
continue;
}
var p = n.cp ? 1 : 0;
var q = j[p];
var r = null;
if (f == 5) {
var s = l.i8(2, n);
if (!isNaN_(s) && (s > q || isNaN_(q))) {
r = l;
}
q = !isNaN_(q) ? Math.max(s, q) : s;
}
else if (f == 4) {
var t = l.i8(1, n);
if (!isNaN_(t) && (t < q || isNaN_(q))) {
r = l;
}
q = !isNaN_(q) ? Math.min(t, q) : t;
}
else if (f == 6) {
var u = l.i8(3, n);
r = l;
q = !isNaN_(q) ? q + u : u;
}
if (n.cp) {
i = r != null ? r : i;
}
else {
h = r != null ? r : h;
}
j[p] = q;
}
k++;
}
}
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;
}
}
if (f == 6) {
j[0] = !isNaN_(j[0]) ? j[0] / k : NaN;
j[1] = !isNaN_(j[1]) ? j[1] / k : NaN;
}
if (h != null && !isNaN_(j[0])) {
var v = h.wi(j);
this.ab5(h, { $type: Point_$type, x: v.x, y: NaN }, c, d, e);
}
if (i != null && !isNaN_(j[1])) {
var w = i.wi(j);
this.ab5(i, { $type: Point_$type, x: NaN, y: w.y }, c, d, e);
}
this.z7 = j;
this.aab = h;
this.aac = i;
}
else {
try {
for (var _e = __values(fromEnum(this.dc.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
var x = _f.value;
this.ab3(c, d, e, x);
}
}
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;
}
}
}
}
};
ValueLayer.prototype.ab3 = function (a, b, c, d) {
var _this = this;
if (this.xk(d)) {
this.ab4(d, a, b, c);
}
if (d.isStacked) {
d.p3(function (e) {
if (_this.xk(e)) {
_this.ab4(e, a, b, c);
}
if (e.eh) {
e.p1(function (f) {
if (_this.xk(f)) {
_this.ab4(f, a, b, c);
}
return true;
});
}
return true;
});
}
if (d.eh) {
d.p1(function (e) {
if (_this.xk(e)) {
_this.ab4(e, a, b, c);
}
return true;
});
}
};
ValueLayer.prototype.xk = function (a) {
if (!_super.prototype.xk.call(this, a)) {
return false;
}
if (this.aa9 != null) {
if (a.isFragment) {
var b = a.nc();
if (!Base.equalsStatic(this.aa9, b)) {
return false;
}
}
else {
if (!Base.equalsStatic(this.aa9, a.name)) {
return false;
}
}
}
return true;
};
ValueLayer.prototype.aai = function (a) {
if (!a.cj) {
return false;
}
if (this.z8 != null && this.z8 != a) {
return false;
}
if (this.aa6 != null && !Base.equalsStatic(this.aa6, a.name)) {
return false;
}
return true;
};
ValueLayer.prototype.qp = function () {
_super.prototype.qp.call(this);
if (!this.a1.c && !this.d4()) {
return;
}
if (this.d4()) {
this.ab6(this.xf, false);
}
else {
this.ab6(this.xd, false);
}
};
ValueLayer.prototype.aae = function () {
if (this.aaf == 0) {
return 2;
}
return this.aaf;
};
ValueLayer.prototype.w4 = function () {
return 3;
};
ValueLayer.prototype.xr = function () {
return 0.3;
};
ValueLayer.prototype.xu = function () {
return -0.4;
};
ValueLayer.prototype.xt = function () {
return 0.5;
};
ValueLayer.prototype.zw = function () {
return this.w1 == 3 ? this.adg() : null;
};
ValueLayer.prototype.zx = function () {
return this.w2 == 3 ? this.adg() : null;
};
ValueLayer.prototype.adg = function () {
if (this.adf == null) {
this.adf = new DoubleCollection();
this.adf.add(DeviceUtils.g(5));
this.adf.add(DeviceUtils.g(5));
}
return this.adf;
};
ValueLayer.prototype.ab5 = function (a, b, c, d, e) {
var f = false;
var g = this.ac6;
if (g == null) {
g = a.vb;
f = true;
}
var h = false;
var i = this.ac9;
if (i == null) {
if (this.ac6 != null) {
i = this.ac6;
}
else {
i = a.vb;
h = true;
}
}
var j = false;
var k = this.adc;
if (k == null) {
if (this.ac6 != null) {
k = this.ac6;
}
else {
k = a.vb;
j = true;
}
}
var l = g;
var m = g;
var n = i;
var o = k;
if (this.ac7 != null) {
l = this.ac7;
}
else if (f) {
switch (this.w1) {
case 1:
l = this.aag.cb(l, this.xo);
break;
case 2:
l = this.aag.cd(l, this.xo);
break;
case 4:
l = this.aag.cc(l, this.xo);
break;
}
}
if (this.ac8 != null) {
m = this.ac8;
}
else if (f) {
switch (this.w2) {
case 1:
m = this.aag.cb(m, this.xq);
break;
case 2:
m = this.aag.cd(m, this.xq);
break;
case 4:
m = this.aag.cc(m, this.xq);
break;
}
}
if (h) {
switch (this.w2) {
case 1:
n = this.aag.cb(n, this.xq);
break;
case 2:
n = this.aag.cd(n, this.xq);
break;
}
}
if (j) {
switch (this.w1) {
case 1:
o = this.aag.cb(o, this.xo);
break;
case 2:
o = this.aag.cd(o, this.xo);
break;
}
}
c.ae.add(l);
c.ah.add(m);
c.af.add(b.y);
c.ag.add(b.x);
if (this.aah) {
AxisAnnotationFrameManager.c(c, b, a, this.dc, this.getEffectiveViewport(), g, n, this.aan, this.adb, this.ada, this.adh, this.aas, o, this.aat, this.ade, this.add, this.adi, this.aay, this.adk == 0, this.adj == 0);
}
};
ValueLayer.prototype.ab4 = function (a, b, c, d) {
var e = { $type: Point_$type, x: NaN, y: NaN };
var f = this.aae();
switch (f) {
case 5:
e = a.wh(2);
break;
case 4:
e = a.wh(1);
break;
case 6:
e = a.wh(3);
break;
default:
e = a.wh(f);
break;
}
var i = a.ai();
for (var h = 0; h < i.length; h++) {
var g = i[h];
if (!this.aai(g)) {
continue;
}
if (g.cp) {
this.ab5(a, { $type: Point_$type, x: NaN, y: e.y }, b, c, d);
}
else {
this.ab5(a, { $type: Point_$type, x: e.x, y: NaN }, b, c, d);
}
}
};
ValueLayer.prototype.ab6 = function (a, b) {
var c = false;
if (this.aal == null) {
c = true;
this.aam = new List$1(Axis.$, 0);
this.aal = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
}
AxisAnnotationFrameManager.d(this, a, c, this.aal, this.aam, b, this.aaz, this.aa0, this.z9, this.aaa);
};
ValueLayer.prototype.ab2 = function (a, b, c, d, e) {
var f = a.item(b);
b++;
if (e) {
f._stroke = d.ah._inner[c];
f._fill = d.ah._inner[c];
}
else {
f._stroke = d.ae._inner[c];
f._fill = d.ae._inner[c];
}
f.ad = this.ie;
f.ai = e ? this.zu : this.zt;
f.am = this.v7;
f.al = this.v6;
f.ak = this.v6;
f.aj = this.v5;
f.ac = this.jh;
return new Tuple$2(Path.$, Number_$type, f, b);
};
ValueLayer.prototype.yy = function (a, b) {
_super.prototype.yy.call(this, a, b);
var c = this.aag.cf;
var d = a;
var e = d.af.count;
var f = 0;
var g = b.b1.left;
var h = b.b1.right;
var i = b.b1.top;
var j = b.b1.bottom;
var k = this.adk == 0;
var l = this.adj == 0;
for (var m = 0; m < e; m++) {
var n = Math.floor(d.af._inner[m]);
var o = Math.floor(d.ag._inner[m]);
var p = null;
if (k) {
if (!isNaN_(o)) {
var q = this.ab2(c, f, m, d, true);
p = q.c;
f = q.d;
var r = new PathGeometry();
var s = new PathFigure();
s._startPoint = { $type: Point_$type, x: o, y: i };
var t = new LineSegment(1);
t.c = { $type: Point_$type, x: o, y: j };
s._segments.add(t);
r.c.add(s);
p.an = r;
}
}
if (l) {
if (!isNaN_(n)) {
var u = this.ab2(c, f, m, d, false);
p = u.c;
f = u.d;
var v = new PathGeometry();
var w = new PathFigure();
w._startPoint = { $type: Point_$type, x: g, y: n };
var x = new LineSegment(1);
x.c = { $type: Point_$type, x: h, y: n };
w._segments.add(x);
v.c.add(w);
p.an = v;
}
}
}
c.count = f;
if (this.d4()) {
this.ab6(this.xf, true);
}
else {
this.ab6(this.xd, false);
}
};
ValueLayer.prototype.ga = function () {
return true;
};
ValueLayer.prototype.ra = function (a, b, c, d) {
_super.prototype.ra.call(this, a, b, c, d);
switch (b) {
case "SeriesViewer":
if (d == null) {
if (this.aal != null && this.aal.count > 0) {
var e = void 0;
if (this.d4()) {
e = this.xf;
}
else {
e = this.xd;
}
AxisAnnotationFrameManager.b(e);
AxisAnnotationFrameManager.d(this, e, true, this.aal, this.aam, true, this.aaz, this.aa0, this.z9, this.aaa);
}
}
break;
case ValueLayer.$$p[2]:
this.rs(true);
break;
case ValueLayer.$$p[12]:
this.rs(true);
break;
case ValueLayer.$$p[7]:
case ValueLayer.$$p[8]:
case "Visibility":
this.rs(true);
break;
case ValueLayer.$$p[3]:
case ValueLayer.$$p[14]:
case ValueLayer.$$p[13]:
case ValueLayer.$$p[17]:
case ValueLayer.$$p[19]:
case ValueLayer.$$p[21]:
case ValueLayer.$$p[20]:
case ValueLayer.$$p[18]:
case ValueLayer.$$p[22]:
case ValueLayer.$$p[23]:
case ValueLayer.$$p[25]:
case ValueLayer.$$p[28]:
case ValueLayer.$$p[30]:
case ValueLayer.$$p[32]:
case ValueLayer.$$p[31]:
case ValueLayer.$$p[29]:
case ValueLayer.$$p[33]:
case ValueLayer.$$p[34]:
case ValueLayer.$$p[1]:
case ValueLayer.$$p[11]:
case ValueLayer.$$p[9]:
this.rs(true);
break;
case "Brush":
case ValueLayer.$$p[10]:
if (this.vh != null) {
this.ac6 = this.vh;
}
else {
switch (this.aaf) {
case 6:
this.ac6 = BrushUtil.h(255, 248, 173, 118);
break;
case 4:
this.ac6 = BrushUtil.h(255, 246, 93, 80);
break;
case 5:
this.ac6 = BrushUtil.h(255, 99, 208, 0);
break;
default:
this.ac6 = this.aad != null ? this.aad.vb : null;
break;
}
}
break;
}
};
ValueLayer.prototype.o5 = function (a, b) {
_super.prototype.o5.call(this, a, b);
if (a) {
AxisAnnotationFrameManager.b(this.xd);
this.ab6(this.xd, false);
}
};
ValueLayer.$t = markType(ValueLayer, 'ValueLayer', AnnotationLayer.$);
ValueLayer.$$p = markDep(DependencyProperty, PropertyMetadata, ValueLayer, 'raisePropertyChanged', ['ActualValueLayerBrush:ac6:ab7', [Brush.$, null], 'HorizontalLineStroke:ac7:ab8', [Brush.$, null], 'HorizontalLineVisibility:adj:ab9', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'IsAxisAnnotationEnabled:aah:aca', [0, false], 'SkipUnknownValues:aaj:acb', [0, true], 'TargetAxisName:aa6:acc', [2, null], 'TargetAxis:z8:acd', [Axis.$, null], 'TargetSeriesName:aa9:ace', [2, null], 'TargetSeries:aad:acf', [Series.$, null], 'UseInterpolation:aak:acg', [0, true], 'ValueMode:aaf:ach', [ValueLayerValueMode_$type, enumGetBox(ValueLayerValueMode_$type, 2)], 'VerticalLineStroke:ac8:aci', [Brush.$, null], 'VerticalLineVisibility:adk:acj', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'XAxisAnnotationBackgroundCornerRadius:aan:ack', [1, DeviceUtils.g(3)], 'XAxisAnnotationBackground:ac9:acl', [Brush.$, null], 'XAxisAnnotationFormatLabel:z9:acm', [Delegate_$type], 'XAxisAnnotationInterpolatedValuePrecision:aaz:acn', [1, -1], 'XAxisAnnotationOutline:ada:aco', [Brush.$, null], 'XAxisAnnotationPaddingBottom:aao:acp', [1, NaN], 'XAxisAnnotationPaddingLeft:aap:acq', [1, NaN], 'XAxisAnnotationPaddingRight:aaq:acr', [1, NaN], 'XAxisAnnotationPaddingTop:aar:acs', [1, NaN], 'XAxisAnnotationStrokeThickness:aas:act', [1, NaN], 'XAxisAnnotationTextColor:adb:acu', [Brush.$, null], 'YAxisAnnotationBackgroundCornerRadius:aat:acv', [1, DeviceUtils.g(3)], 'YAxisAnnotationBackground:adc:acw', [Brush.$, null], 'YAxisAnnotationFormatLabel:aaa:acx', [Delegate_$type], 'YAxisAnnotationInterpolatedValuePrecision:aa0:acy', [1, -1], 'YAxisAnnotationOutline:add:acz', [Brush.$, null], 'YAxisAnnotationPaddingBottom:aau:ac0', [1, NaN], 'YAxisAnnotationPaddingLeft:aav:ac1', [1, NaN], 'YAxisAnnotationPaddingRight:aaw:ac2', [1, NaN], 'YAxisAnnotationPaddingTop:aax:ac3', [1, NaN], 'YAxisAnnotationStrokeThickness:aay:ac4', [1, NaN], 'YAxisAnnotationTextColor:ade:ac5', [Brush.$, null]]);
return ValueLayer;
}(AnnotationLayer));
export { ValueLayer };
/**
* @hidden
*/
var ValueLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ValueLayerView, _super);
function ValueLayerView(a) {
var _this = _super.call(this, a) || this;
_this.ce = null;
_this.cf = null;
_this.cg = null;
_this.ce = a;
_this.cg = new List$1(Path.$, 0);
return _this;
}
ValueLayerView.prototype.ax = function () {
var _this = this;
_super.prototype.ax.call(this);
this.cf = ((function () {
var $ret = new Pool$1(Path.$);
$ret.create = runOn(_this, _this.cl);
$ret.activate = runOn(_this, _this.ch);
$ret.disactivate = runOn(_this, _this.cj);
$ret.destroy = runOn(_this, _this.ci);
return $ret;
})());
this.ce.jp = Defaults.j;
};
ValueLayerView.prototype.cl = function () {
var a = new Path();
a.j = new TranslateTransform();
this.cg.add(a);
return a;
};
ValueLayerView.prototype.ch = function (a) {
a._visibility = 0;
};
ValueLayerView.prototype.cj = function (a) {
a._visibility = 1;
};
ValueLayerView.prototype.ci = function (a) {
this.cg.remove(a);
};
ValueLayerView.prototype.ck = function (a, b, c, d) {
if (a.an == null || a.an.c.x != d || a.an.d.x != c) {
var e = ((function () {
var $ret = new LineGeometry();
$ret.d = { $type: Point_$type, x: c, y: b };
$ret.c = { $type: Point_$type, x: d, y: b };
return $ret;
})());
a.an = e;
}
};
ValueLayerView.prototype.bc = function (a, b) {
_super.prototype.bc.call(this, a, b);
if (a.d && !b) {
for (var c = 0; c < this.cg.count; c++) {
var d = this.cg._inner[c];
if (d._visibility == 0) {
a.t(d);
}
}
}
};
ValueLayerView.prototype.aq = function (a) {
_super.prototype.aq.call(this, a);
for (var b = 0; b < this.cg.count; b++) {
this.f.bc.exportPathData(a, this.cg._inner[b], "crosshairLine", ["Main", "Crosshair"]);
}
};
ValueLayerView.$t = markType(ValueLayerView, 'ValueLayerView', AnnotationLayerView.$);
return ValueLayerView;
}(AnnotationLayerView));
export { ValueLayerView };