UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

585 lines (584 loc) 20.5 kB
/* 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.ze = null; _this.zj = null; _this.zc = null; _this.zd = null; FastItemIntColumn.m(); _this.ab = ScatterAreaSeries.$; return _this; } ScatterAreaSeries.prototype.bk = function () { return new ScatterAreaSeries(); }; ScatterAreaSeries.prototype.get_ex = function () { return true; }; ScatterAreaSeries.prototype.g2 = function (a, b) { var c = this.kw(a); if (c != null) { return true; } return false; }; Object.defineProperty(ScatterAreaSeries.prototype, "zg", { get: function () { return this.ze; }, set: function (a) { var b = this.ze != a; if (b) { var c = this.ze; if (this.ze != null) { var d = this.ze; d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.zx)); } this.ze = a; if (this.ze != null) { var e = this.ze; e.propertyChanged = delegateCombine(e.propertyChanged, runOn(this, this.zx)); } this.raisePropertyChanged("ColorScale", c, this.ze); } }, enumerable: false, configurable: true }); ScatterAreaSeries.prototype.zx = function (a, b) { this.zz(); this.r8(false); }; ScatterAreaSeries.prototype.kz = function (a, b) { var c = this.no(b); if (c == ScatterAreaSeries.$$p[3]) { return this.k0(a, b, this.zs); } return _super.prototype.kz.call(this, a, b); }; ScatterAreaSeries.prototype.mo = function (a) { var b = this.no(a); if (b == ScatterAreaSeries.$$p[3]) { return this.zs; } return _super.prototype.mo.call(this, a); }; Object.defineProperty(ScatterAreaSeries.prototype, "zk", { get: function () { return this.zj; }, set: function (a) { var b = this.zk != a; if (b) { var c = this.zk; this.zj = a; this.raisePropertyChanged("ColorColumn", c, this.zk); } }, enumerable: false, configurable: true }); ScatterAreaSeries.prototype.get_hd = function () { return true; }; ScatterAreaSeries.prototype.set_hd = function (a) { _super.prototype.set_hd.call(this, a); }; ScatterAreaSeries.prototype.rq = function (a, b, c, d) { _super.prototype.rq.call(this, a, b, c, d); switch (b) { case ScatterAreaSeries.$$p[1]: case ScatterAreaSeries.$$p[2]: this.qu(); break; case "FastItemsSource": var e = typeCast(IFastItemsSource_$type, c); if (e != null) { e.deregisterColumn(this.zk); this.zk = null; } var f = typeCast(IFastItemsSource_$type, d); if (f != null) { this.zk = this.dl(this.zs); } this.r8(this.gm && c != null); break; case ScatterAreaSeries.$$p[3]: if (this.dp != null) { this.dp.deregisterColumn(this.zk); this.zk = this.dl(this.zs); } this.r8(false); this.q0(); break; case "ColorScale": this.zz(); this.r8(false); this.q0(); break; } }; ScatterAreaSeries.prototype.r9 = function (a) { _super.prototype.r9.call(this, a); this.zy(this.cw); }; ScatterAreaSeries.prototype.r7 = function (a, b, c, d, e) { _super.prototype.r7.call(this, a, b, c, d, e); var f = this.ba.a$k.item(d); f.bd(c); if (this.d7(f)) { return; } this.zy(f); }; ScatterAreaSeries.prototype.zy = 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.xj; var i = this.xk; var j = this.getEffectiveViewport1(a); var k = new ScalerParams(1, b, c, h.dn); k.c = j; var l = new ScalerParams(1, b, c, i.dn); l.c = j; g = this.zi(a, k, l); if (g != null) { e.co(g); } else { e.cr(f); } }; ScatterAreaSeries.prototype.zv = 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.kw = function (a) { var b = truncate(Math.round(this.xd.width)); var c = truncate(Math.round(this.xd.height)); var d = this.cw.cg; if (d == null || d.length != (b * c) || this.xt == null || this.xt.count < 1 || this.xu == null || this.xu.count < 1 || this.xv == null || this.xv.count < 1) { return null; } var e = this.dc.za; 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.xt.count) { return null; } var l = this.zc.length; var m = this.xt.item(k); var n = this.xu.item(k); var o = this.xv.item(k); if ((m >= l) || (n >= l) || (o >= l)) { return null; } var p = (this.zc[m] - this.xd.left) / this.xd.width; var q = (this.zd[m] - this.xd.top) / this.xd.height; var r = (this.zc[n] - this.xd.left) / this.xd.width; var s = (this.zd[n] - this.xd.top) / this.xd.height; var t = (this.zc[o] - this.xd.left) / this.xd.width; var u = (this.zd[o] - this.xd.top) / this.xd.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.zi = 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.i5(); var g = a; var h = this.xj; var i = this.xk; var j = this.xt.count; var k; var xArr_ = this.xw.asArray(); k = (xArr_.slice(0)); var l; var yArr_ = this.xx.asArray(); l = (yArr_.slice(0)); var m = this.zk.asArray(); var n = this.xt.asArray(); var o = this.xu.asArray(); var p = this.xv.asArray(); this.zc = k; this.zd = l; h.k1(boxArray$1(k), 0, k.length, b); i.k1(boxArray$1(l), 0, l.length, c); var q = this.zf; var r = g.ci(b.d, q, this.zk); 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.zv(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.zl = function () { var a = new Color(); var b = this.vt; 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.zz = function () { var _this = this; var a = this.zg; if (a == null) { a = ((function () { var $ret = new CustomPaletteColorScale(); $ret.palette = _this.zl(); $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.zl(); } a = b; } var c = new ObservableColorCollection(); if (typeCast(CustomPaletteColorScale.$, a) !== null) { c = a.palette; } else { c = this.zl(); } this.zf = a; }; ScatterAreaSeries.prototype.sz = function () { _super.prototype.sz.call(this); this.zz(); }; ScatterAreaSeries.prototype.pi = function (a, b) { _super.prototype.pi.call(this, a, b); var c = b; c.cn(); }; ScatterAreaSeries.prototype.ct = function () { return new ScatterAreaSeriesView(this); }; ScatterAreaSeries.prototype.rh = function (a) { _super.prototype.rh.call(this, a); this.zh = typeCast(ScatterAreaSeriesView.$, a); }; ScatterAreaSeries.prototype.zw = function (a) { if (this.zh != null) { this.zh.cm(a); } }; ScatterAreaSeries.prototype.getDataLegendSeriesContextAt = function (a, b) { var c = { $type: Point_$type, x: a, y: b }; var d = this.kw(c); var e = d == null ? NaN : this.i4(d, "XMemberPath"); var f = d == null ? NaN : this.i4(d, "YMemberPath"); var g = d == null ? NaN : this.i4(d, "ColorMemberPath"); var h = new DataLegendSeriesValueInfo(); h.l = e; h.a = 13; h.q = "X"; h.r = this.yl != null ? this.yl : "X"; h.s = this.yh != null ? this.yh : "X:"; h.t = this.yj != null ? this.yj : ""; var i = new DataLegendSeriesValueInfo(); i.l = f; i.a = 14; i.q = "Y"; i.r = this.yt != null ? this.yt : "Y"; i.s = this.yp != null ? this.yp : "Y:"; i.t = this.yr != null ? this.yr : ""; var j = new DataLegendSeriesValueInfo(); j.l = g; j.a = 0; j.q = "Value"; j.r = this.zs != null ? this.zs : "Value"; j.s = this.zo != null ? this.zo : "V:"; j.t = this.zq != null ? this.zq : ""; 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.mn(); return k; }; ScatterAreaSeries.$t = markType(ScatterAreaSeries, 'ScatterAreaSeries', ScatterTriangulationSeries.$); ScatterAreaSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterAreaSeries, 'raisePropertyChanged', ['ActualColorScale:zf:z0', [ColorScale.$, null], 'ColorMemberAsLegendLabel:zo:z1', [2, null], 'ColorMemberAsLegendUnit:zq:z2', [2, null], 'ColorMemberPath:zs:z3', [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.j8.createElement("canvas"); var a = this.f.j8.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$v(this.f); if (!stringIsNullOrEmpty(b)) { a += " style='color:" + b + "'"; } a += ">" + this.ch.title + "</span><br/><span>" + "(${item." + this.ch.yl + "}, ${item." + this.ch.yt + "})</span>"; if (!stringIsNullOrEmpty(this.ch.zs)) { a += "<span>, Value: ${item." + this.ch.zs + "}</span>"; } a += "</div>"; return a; }; ScatterAreaSeriesView.$t = markType(ScatterAreaSeriesView, 'ScatterAreaSeriesView', SeriesView.$); return ScatterAreaSeriesView; }(SeriesView)); export { ScatterAreaSeriesView };