igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
578 lines (577 loc) • 20.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 { ScatterTriangulationSeries } from "./ScatterTriangulationSeries";
import { ColorScale } from "./ColorScale";
import { runOn, delegateRemove, delegateCombine, typeCast, Point_$type, markType, markDep } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { FastItemIntColumn } from "igniteui-react-core";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { SeriesView } from "./SeriesView";
import { TriangleRasterizer } from "./TriangleRasterizer";
import { ScalerParams } from "./ScalerParams";
import { ObservableColorCollection } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { ColorUtil } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { CustomPaletteColorScale } from "./CustomPaletteColorScale";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, intDivide } from "igniteui-react-core";
import { boxArray$1 } from "igniteui-react-core";
import { RenderingContext } from "igniteui-react-core";
import { CanvasViewRenderer } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { stringIsNullOrEmpty } from "igniteui-react-core";
/**
* @hidden
*/
var ScatterAreaSeries = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ScatterAreaSeries, _super);
function ScatterAreaSeries() {
var _this = _super.call(this) || this;
_this.y4 = null;
_this.y9 = null;
_this.y2 = null;
_this.y3 = null;
FastItemIntColumn.m();
_this.ab = ScatterAreaSeries.$;
return _this;
}
ScatterAreaSeries.prototype.bk = function () {
return new ScatterAreaSeries();
};
ScatterAreaSeries.prototype.get_ew = function () {
return true;
};
Object.defineProperty(ScatterAreaSeries.prototype, "y6", {
get: function () {
return this.y4;
},
set: function (a) {
var b = this.y4 != a;
if (b) {
var c = this.y4;
if (this.y4 != null) {
var d = this.y4;
d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.zn));
}
this.y4 = a;
if (this.y4 != null) {
var e = this.y4;
e.propertyChanged = delegateCombine(e.propertyChanged, runOn(this, this.zn));
}
this.raisePropertyChanged("ColorScale", c, this.y4);
}
},
enumerable: false,
configurable: true
});
ScatterAreaSeries.prototype.zn = function (a, b) {
this.zp();
this.rz(false);
};
ScatterAreaSeries.prototype.ku = function (a, b) {
var c = this.ni(b);
if (c == ScatterAreaSeries.$$p[3]) {
return this.kv(a, b, this.zi);
}
return _super.prototype.ku.call(this, a, b);
};
ScatterAreaSeries.prototype.mi = function (a) {
var b = this.ni(a);
if (b == ScatterAreaSeries.$$p[3]) {
return this.zi;
}
return _super.prototype.mi.call(this, a);
};
Object.defineProperty(ScatterAreaSeries.prototype, "za", {
get: function () {
return this.y9;
},
set: function (a) {
var b = this.za != a;
if (b) {
var c = this.za;
this.y9 = a;
this.raisePropertyChanged("ColorColumn", c, this.za);
}
},
enumerable: false,
configurable: true
});
ScatterAreaSeries.prototype.get_g8 = function () {
return true;
};
ScatterAreaSeries.prototype.set_g8 = function (a) {
_super.prototype.set_g8.call(this, a);
};
ScatterAreaSeries.prototype.rh = function (a, b, c, d) {
_super.prototype.rh.call(this, a, b, c, d);
switch (b) {
case ScatterAreaSeries.$$p[1]:
case ScatterAreaSeries.$$p[2]:
this.qm();
break;
case "FastItemsSource":
var e = typeCast(IFastItemsSource_$type, c);
if (e != null) {
e.deregisterColumn(this.za);
this.za = null;
}
var f = typeCast(IFastItemsSource_$type, d);
if (f != null) {
this.za = this.dl(this.zi);
}
this.rz(this.gh && c != null);
break;
case ScatterAreaSeries.$$p[3]:
if (this.dp != null) {
this.dp.deregisterColumn(this.za);
this.za = this.dl(this.zi);
}
this.rz(false);
this.qs();
break;
case "ColorScale":
this.zp();
this.rz(false);
this.qs();
break;
}
};
ScatterAreaSeries.prototype.r0 = function (a) {
_super.prototype.r0.call(this, a);
this.zo(this.cw);
};
ScatterAreaSeries.prototype.ry = function (a, b, c, d, e) {
_super.prototype.ry.call(this, a, b, c, d, e);
var f = this.ba.a$j.item(d);
f.bd(c);
if (this.d7(f)) {
return;
}
this.zo(f);
};
ScatterAreaSeries.prototype.zo = function (a) {
if (this.d7(a)) {
return;
}
var b;
var c;
var d = a.getViewInfo(c, b);
c = d.p0;
b = d.p1;
var e = a;
var f = null;
var g = null;
var h = this.w9;
var i = this.xa;
var j = this.getEffectiveViewport1(a);
var k = new ScalerParams(1, b, c, h.df);
k.c = j;
var l = new ScalerParams(1, b, c, i.df);
l.c = j;
g = this.y8(a, k, l);
if (g != null) {
e.co(g);
}
else {
e.cr(f);
}
};
ScatterAreaSeries.prototype.zl = function (a) {
var b;
var c;
var d = a.getViewInfo(b, c);
b = d.p0;
c = d.p1;
var e = truncate(Math.round(b.width)) * truncate(Math.round(b.height));
var f = a.cg;
if (f == null || f.length != e) {
f = new Array(e);
for (var g = 0; g < e; g++) {
f[g] = 0;
}
}
else {
for (var h = 0; h < e; h++) {
f[h] = 0;
}
}
a.cg = f;
};
ScatterAreaSeries.prototype.kr = function (a) {
var b = truncate(Math.round(this.w3.width));
var c = truncate(Math.round(this.w3.height));
var d = this.cw.cg;
if (d == null || d.length != (b * c) || this.xj == null || this.xj.count < 1 || this.xk == null || this.xk.count < 1 || this.xl == null || this.xl.count < 1) {
return null;
}
var e = this.dc.x6;
var f = (a.x - e.left) / e.width;
var g = (a.y - e.top) / e.height;
var h = truncate(Math.round(b * f));
var i = truncate(Math.round(c * g));
var j = (b * i) + h;
if (j < 0 || j > d.length - 1) {
return null;
}
var k = d[j] - 1;
if (k < 0 || k > this.xj.count) {
return null;
}
var l = this.y2.length;
var m = this.xj.item(k);
var n = this.xk.item(k);
var o = this.xl.item(k);
if ((m >= l) || (n >= l) || (o >= l)) {
return null;
}
var p = (this.y2[m] - this.w3.left) / this.w3.width;
var q = (this.y3[m] - this.w3.top) / this.w3.height;
var r = (this.y2[n] - this.w3.left) / this.w3.width;
var s = (this.y3[n] - this.w3.top) / this.w3.height;
var t = (this.y2[o] - this.w3.left) / this.w3.width;
var u = (this.y3[o] - this.w3.top) / this.w3.height;
var v = Math.pow(p - f, 2) + Math.pow(q - g, 2);
var w = Math.pow(r - f, 2) + Math.pow(s - g, 2);
var x = Math.pow(t - f, 2) + Math.pow(u - g, 2);
if (v < w && v < x) {
return this.dp.item(m);
}
if (w < v && w < x) {
return this.dp.item(n);
}
if (x < v && x < w) {
return this.dp.item(o);
}
return this.dp.item(m);
};
ScatterAreaSeries.prototype.y8 = function (a, b, c) {
var d;
var e;
var f = a.getViewInfo(e, d);
e = f.p0;
d = f.p1;
e = new Rect(0, 0, 0, e.width, e.height);
b = new ScalerParams(0, b.e, e, b.a, b.c);
c = new ScalerParams(0, c.e, e, c.a, c.c);
c.b = this.i0();
var g = a;
var h = this.w9;
var i = this.xa;
var j = this.xj.count;
var k;
var xArr_ = this.xm.asArray();
k = (xArr_.slice(0));
var l;
var yArr_ = this.xn.asArray();
l = (yArr_.slice(0));
var m = this.za.asArray();
var n = this.xj.asArray();
var o = this.xk.asArray();
var p = this.xl.asArray();
this.y2 = k;
this.y3 = l;
h.j6(boxArray$1(k), 0, k.length, b);
i.j6(boxArray$1(l), 0, l.length, c);
var q = this.y5;
var r = g.ci(b.d, q, this.za);
var s = e.top;
var t = e.left;
var u = e.right;
var v = e.bottom;
var w;
var x;
var y;
var z;
this.zl(g);
var aa = g.cg;
var ab = k.length;
for (var ac = 0; ac < j; ac++) {
var ad = n[ac];
var ae = o[ac];
var af = p[ac];
if ((ad >= ab) || (ae >= ab) || (af >= ab) || (ad < 0) || (ae < 0) || (af < 0)) {
continue;
}
var ag = k[ad];
var ah = l[ad];
var ai = { $type: Point_$type, x: ag, y: ah };
var aj = k[ae];
var ak = l[ae];
var al = { $type: Point_$type, x: aj, y: ak };
var am = k[af];
var an = l[af];
var ao = { $type: Point_$type, x: am, y: an };
w = al.y < ao.y ? al.y : ao.y;
w = ai.y < w ? ai.y : w;
x = al.y > ao.y ? al.y : ao.y;
x = ai.y > x ? ai.y : x;
y = al.x < ao.x ? al.x : ao.x;
y = ai.x < y ? ai.x : y;
z = al.x > ao.x ? al.x : ao.x;
z = ai.x > z ? ai.x : z;
if (w < v && x > s && y < u && z > t) {
var ap = m[ad];
var aq = m[ae];
var ar = m[af];
r.p(ac, aa, ai, al, ao, ap, aq, ar);
}
}
return r;
};
ScatterAreaSeries.prototype.zb = function () {
var a = new Color();
var b = this.vk;
if (b == null) {
a = ColorUtil.u("#000000");
}
else {
a = ColorUtil.t(b);
}
var c = new ObservableColorCollection();
c.add(ColorUtil.y(a, -0.5));
c.add(a);
return c;
};
ScatterAreaSeries.prototype.zp = function () {
var _this = this;
var a = this.y6;
if (a == null) {
a = ((function () {
var $ret = new CustomPaletteColorScale();
$ret.palette = _this.zb();
$ret.interpolationMode = 2;
return $ret;
})());
}
else if (typeCast(CustomPaletteColorScale.$, a) !== null) {
var b = a;
if (b.palette == null || b.palette.count == 0) {
b.palette = this.zb();
}
a = b;
}
var c = new ObservableColorCollection();
if (typeCast(CustomPaletteColorScale.$, a) !== null) {
c = a.palette;
}
else {
c = this.zb();
}
this.y5 = a;
};
ScatterAreaSeries.prototype.sq = function () {
_super.prototype.sq.call(this);
this.zp();
};
ScatterAreaSeries.prototype.pb = function (a, b) {
_super.prototype.pb.call(this, a, b);
var c = b;
c.cn();
};
ScatterAreaSeries.prototype.ct = function () {
return new ScatterAreaSeriesView(this);
};
ScatterAreaSeries.prototype.q8 = function (a) {
_super.prototype.q8.call(this, a);
this.y7 = typeCast(ScatterAreaSeriesView.$, a);
};
ScatterAreaSeries.prototype.zm = function (a) {
if (this.y7 != null) {
this.y7.cm(a);
}
};
ScatterAreaSeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
var c = { $type: Point_$type, x: a, y: b };
var d = this.kr(c);
var e = d == null ? NaN : this.iz(d, "XMemberPath");
var f = d == null ? NaN : this.iz(d, "YMemberPath");
var g = d == null ? NaN : this.iz(d, "ColorMemberPath");
var h = new DataLegendSeriesValueInfo();
h.l = e;
h.a = 13;
h.q = "X";
h.r = this.yb != null ? this.yb : "X";
h.s = this.x7 != null ? this.x7 : "X:";
h.t = this.x9 != null ? this.x9 : "";
var i = new DataLegendSeriesValueInfo();
i.l = f;
i.a = 14;
i.q = "Y";
i.r = this.yj != null ? this.yj : "Y";
i.s = this.yf != null ? this.yf : "Y:";
i.t = this.yh != null ? this.yh : "";
var j = new DataLegendSeriesValueInfo();
j.l = g;
j.a = 0;
j.q = "Value";
j.r = this.zi != null ? this.zi : "Value";
j.s = this.ze != null ? this.ze : "V:";
j.t = this.zg != null ? this.zg : "";
var k = new DataLegendSeriesContext();
k.e = ((function () {
var $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
$ret.add(h);
$ret.add(i);
$ret.add(j);
return $ret;
})());
k.h = this.mh();
return k;
};
ScatterAreaSeries.$t = markType(ScatterAreaSeries, 'ScatterAreaSeries', ScatterTriangulationSeries.$);
ScatterAreaSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterAreaSeries, 'raisePropertyChanged', ['ActualColorScale:y5:zq', [ColorScale.$, null], 'ColorMemberAsLegendLabel:ze:zr', [2, null], 'ColorMemberAsLegendUnit:zg:zs', [2, null], 'ColorMemberPath:zi:zt', [2, null]]);
return ScatterAreaSeries;
}(ScatterTriangulationSeries));
export { ScatterAreaSeries };
/**
* @hidden
*/
var ScatterAreaSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ScatterAreaSeriesView, _super);
function ScatterAreaSeriesView(a) {
var _this = _super.call(this, a) || this;
_this.ch = null;
_this.cd = null;
_this.cl = null;
_this.ck = null;
_this.cj = null;
_this.ch = a;
return _this;
}
Object.defineProperty(ScatterAreaSeriesView.prototype, "cg", {
get: function () {
return this.cd;
},
set: function (a) {
this.cd = a;
},
enumerable: false,
configurable: true
});
ScatterAreaSeriesView.prototype.cq = function (a, b) {
};
ScatterAreaSeriesView.prototype.cm = function (a) {
};
ScatterAreaSeriesView.prototype.ce = function () {
return this.cf(true);
};
ScatterAreaSeriesView.prototype.cf = function (a) {
this.cp();
var b = truncate(Math.round(this.b9.left));
var c = truncate(Math.round(this.b9.left));
var d = truncate(Math.round(this.b9.width));
var e = truncate(Math.round(this.b9.height));
var f = d.toString();
var g = e.toString();
if (this.ck.getAttribute("width") != f) {
this.ck.setAttribute("width", d.toString());
}
if (this.ck.getAttribute("height") != g) {
this.ck.setAttribute("height", e.toString());
}
var h = this.cj.h();
if (a) {
h.clearRect(0, 0, d, e);
}
this.cl = h.getImageData(0, 0, d, e);
var imageDataArray_ = this.cl.data;
return imageDataArray_;
};
ScatterAreaSeriesView.prototype.cp = function () {
if (this.ck == null) {
this.ck = this.f.j3.createElement("canvas");
var a = this.f.j3.get2DCanvasContext(this.ck);
this.cj = new RenderingContext(new CanvasViewRenderer(), a);
}
};
ScatterAreaSeriesView.prototype.ci = function (a, b, c) {
var d = truncate(Math.round(this.b9.left));
var e = truncate(Math.round(this.b9.left));
var f = truncate(Math.round(this.b9.width));
var g = truncate(Math.round(this.b9.height));
return new TriangleRasterizer(this.ce(), b, c.minimum, c.maximum, c, f, g);
};
ScatterAreaSeriesView.prototype.co = function (a) {
this.cr(null);
};
ScatterAreaSeriesView.prototype.cn = function () {
if (this.cj != null) {
this.cj.l(this.b9.left, this.b9.top, this.b9.width, this.b9.height);
}
this.a2();
};
ScatterAreaSeriesView.prototype.bj = function (a, b) {
_super.prototype.bj.call(this, a, b);
if (this.ck == null) {
return;
}
if (b) {
var c = new Rectangle();
c.n = this.b9.left;
c.o = this.b9.top;
c.width = this.b9.width;
c.height = this.b9.height;
c._fill = this.b3();
a.w(c);
}
else {
var d = truncate(Math.round(this.b9.left));
var e = truncate(Math.round(this.b9.top));
var f = truncate(Math.round(this.b9.width));
var g = truncate(Math.round(this.b9.height));
a.n(this.ck.getNativeElement(), 1, d, e, f, g);
}
};
ScatterAreaSeriesView.prototype.cr = function (a) {
var b = truncate(Math.round(this.b9.left));
var c = truncate(Math.round(this.b9.left));
var d = truncate(Math.round(this.b9.width));
var e = truncate(Math.round(this.b9.height));
this.cp();
this.cj.h().putImageData(this.cl, 0, 0);
this.a2();
};
ScatterAreaSeriesView.prototype.ax = function (a) {
_super.prototype.ax.call(this, a);
var b = truncate(Math.round(this.b9.width));
var c = truncate(Math.round(this.b9.height));
var d = this.cf(false);
if (d == null || d.length == 0) {
this.f.bc.exportSeriesPixelsData(a, null, b, c);
return;
}
var e = new Array(intDivide(d.length, 4));
var f;
for (var g = 0; g < intDivide(d.length, 4); g++) {
f = g * 4;
e[g] = d[f + 3] << 24 | d[f] << 16 | d[f + 1] << 8 | d[f + 2];
}
this.f.bc.exportSeriesPixelsData(a, e, b, c);
};
ScatterAreaSeriesView.prototype.getDefaultTooltipTemplate = function () {
var a = "<div class='ui-chart-default-tooltip-content'><span";
var b = this.f.ba.a$u(this.f);
if (!stringIsNullOrEmpty(b)) {
a += " style='color:" + b + "'";
}
a += ">" + this.ch.title + "</span><br/><span>" + "(${item." + this.ch.yb + "}, ${item." + this.ch.yj + "})</span>";
if (!stringIsNullOrEmpty(this.ch.zi)) {
a += "<span>, Value: ${item." + this.ch.zi + "}</span>";
}
a += "</div>";
return a;
};
ScatterAreaSeriesView.$t = markType(ScatterAreaSeriesView, 'ScatterAreaSeriesView', SeriesView.$);
return ScatterAreaSeriesView;
}(SeriesView));
export { ScatterAreaSeriesView };