UNPKG

igniteui-react-charts

Version:

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

578 lines (577 loc) 20.3 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.yv = null; _this.y0 = null; _this.yt = null; _this.yu = null; FastItemIntColumn.m(); _this.ab = ScatterAreaSeries.$; return _this; } ScatterAreaSeries.prototype.bk = function () { return new ScatterAreaSeries(); }; ScatterAreaSeries.prototype.get_ev = function () { return true; }; Object.defineProperty(ScatterAreaSeries.prototype, "yx", { get: function () { return this.yv; }, set: function (a) { var b = this.yv != a; if (b) { var c = this.yv; if (this.yv != null) { var d = this.yv; d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.ze)); } this.yv = a; if (this.yv != null) { var e = this.yv; e.propertyChanged = delegateCombine(e.propertyChanged, runOn(this, this.ze)); } this.raisePropertyChanged("ColorScale", c, this.yv); } }, enumerable: false, configurable: true }); ScatterAreaSeries.prototype.ze = function (a, b) { this.zg(); this.rs(false); }; ScatterAreaSeries.prototype.kq = function (a, b) { var c = this.nd(b); if (c == ScatterAreaSeries.$$p[3]) { return this.kr(a, b, this.y9); } return _super.prototype.kq.call(this, a, b); }; ScatterAreaSeries.prototype.md = function (a) { var b = this.nd(a); if (b == ScatterAreaSeries.$$p[3]) { return this.y9; } return _super.prototype.md.call(this, a); }; Object.defineProperty(ScatterAreaSeries.prototype, "y1", { get: function () { return this.y0; }, set: function (a) { var b = this.y1 != a; if (b) { var c = this.y1; this.y0 = a; this.raisePropertyChanged("ColorColumn", c, this.y1); } }, enumerable: false, configurable: true }); ScatterAreaSeries.prototype.get_g7 = function () { return true; }; ScatterAreaSeries.prototype.set_g7 = function (a) { _super.prototype.set_g7.call(this, a); }; ScatterAreaSeries.prototype.ra = function (a, b, c, d) { _super.prototype.ra.call(this, a, b, c, d); switch (b) { case ScatterAreaSeries.$$p[1]: case ScatterAreaSeries.$$p[2]: this.qf(); break; case "FastItemsSource": var e = typeCast(IFastItemsSource_$type, c); if (e != null) { e.deregisterColumn(this.y1); this.y1 = null; } var f = typeCast(IFastItemsSource_$type, d); if (f != null) { this.y1 = this.dl(this.y9); } this.rs(this.gg && c != null); break; case ScatterAreaSeries.$$p[3]: if (this.dp != null) { this.dp.deregisterColumn(this.y1); this.y1 = this.dl(this.y9); } this.rs(false); this.ql(); break; case "ColorScale": this.zg(); this.rs(false); this.ql(); break; } }; ScatterAreaSeries.prototype.rt = function (a) { _super.prototype.rt.call(this, a); this.zf(this.cw); }; ScatterAreaSeries.prototype.rr = function (a, b, c, d, e) { _super.prototype.rr.call(this, a, b, c, d, e); var f = this.ba.a$j.item(d); f.a6(c); if (this.d6(f)) { return; } this.zf(f); }; ScatterAreaSeries.prototype.zf = function (a) { if (this.d6(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.w0; var i = this.w1; var j = this.getEffectiveViewport1(a); var k = new ScalerParams(1, b, c, h.ch); k.c = j; var l = new ScalerParams(1, b, c, i.ch); l.c = j; g = this.yz(a, k, l); if (g != null) { e.cf(g); } else { e.ci(f); } }; ScatterAreaSeries.prototype.zc = 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.b7; 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.b7 = f; }; ScatterAreaSeries.prototype.kn = function (a) { var b = truncate(Math.round(this.wu.width)); var c = truncate(Math.round(this.wu.height)); var d = this.cw.b7; if (d == null || d.length != (b * c) || this.xa == null || this.xa.count < 1 || this.xb == null || this.xb.count < 1 || this.xc == null || this.xc.count < 1) { return null; } var e = this.dc.wo; 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.xa.count) { return null; } var l = this.yt.length; var m = this.xa.item(k); var n = this.xb.item(k); var o = this.xc.item(k); if ((m >= l) || (n >= l) || (o >= l)) { return null; } var p = (this.yt[m] - this.wu.left) / this.wu.width; var q = (this.yu[m] - this.wu.top) / this.wu.height; var r = (this.yt[n] - this.wu.left) / this.wu.width; var s = (this.yu[n] - this.wu.top) / this.wu.height; var t = (this.yt[o] - this.wu.left) / this.wu.width; var u = (this.yu[o] - this.wu.top) / this.wu.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.yz = 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.iy(); var g = a; var h = this.w0; var i = this.w1; var j = this.xa.count; var k; var xArr_ = this.xd.asArray(); k = (xArr_.slice(0)); var l; var yArr_ = this.xe.asArray(); l = (yArr_.slice(0)); var m = this.y1.asArray(); var n = this.xa.asArray(); var o = this.xb.asArray(); var p = this.xc.asArray(); this.yt = k; this.yu = l; h.hq(boxArray$1(k), 0, k.length, b); i.hq(boxArray$1(l), 0, l.length, c); var q = this.yw; var r = g.b9(b.d, q, this.y1); 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.zc(g); var aa = g.b7; 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.y2 = function () { var a = new Color(); var b = this.vb; 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.zg = function () { var _this = this; var a = this.yx; if (a == null) { a = ((function () { var $ret = new CustomPaletteColorScale(); $ret.palette = _this.y2(); $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.y2(); } a = b; } var c = new ObservableColorCollection(); if (typeCast(CustomPaletteColorScale.$, a) !== null) { c = a.palette; } else { c = this.y2(); } this.yw = a; }; ScatterAreaSeries.prototype.sj = function () { _super.prototype.sj.call(this); this.zg(); }; ScatterAreaSeries.prototype.o5 = function (a, b) { _super.prototype.o5.call(this, a, b); var c = b; c.ce(); }; ScatterAreaSeries.prototype.ct = function () { return new ScatterAreaSeriesView(this); }; ScatterAreaSeries.prototype.q1 = function (a) { _super.prototype.q1.call(this, a); this.yy = typeCast(ScatterAreaSeriesView.$, a); }; ScatterAreaSeries.prototype.zd = function (a) { if (this.yy != null) { this.yy.cd(a); } }; ScatterAreaSeries.prototype.getDataLegendSeriesContextAt = function (a, b) { var c = { $type: Point_$type, x: a, y: b }; var d = this.kn(c); var e = d == null ? NaN : this.ix(d, "XMemberPath"); var f = d == null ? NaN : this.ix(d, "YMemberPath"); var g = d == null ? NaN : this.ix(d, "ColorMemberPath"); var h = new DataLegendSeriesValueInfo(); h.l = e; h.a = 13; h.q = "X"; h.r = this.x2 != null ? this.x2 : "X"; h.s = this.xy != null ? this.xy : "X:"; h.t = this.x0 != null ? this.x0 : ""; var i = new DataLegendSeriesValueInfo(); i.l = f; i.a = 14; i.q = "Y"; i.r = this.ya != null ? this.ya : "Y"; i.s = this.x6 != null ? this.x6 : "Y:"; i.t = this.x8 != null ? this.x8 : ""; var j = new DataLegendSeriesValueInfo(); j.l = g; j.a = 0; j.q = "Value"; j.r = this.y9 != null ? this.y9 : "Value"; j.s = this.y5 != null ? this.y5 : "V:"; j.t = this.y7 != null ? this.y7 : ""; 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.mc(); return k; }; ScatterAreaSeries.$t = markType(ScatterAreaSeries, 'ScatterAreaSeries', ScatterTriangulationSeries.$); ScatterAreaSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterAreaSeries, 'raisePropertyChanged', ['ActualColorScale:yw:zh', [ColorScale.$, null], 'ColorMemberAsLegendLabel:y5:zi', [2, null], 'ColorMemberAsLegendUnit:y7:zj', [2, null], 'ColorMemberPath:y9:zk', [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.b8 = null; _this.b4 = null; _this.cc = null; _this.cb = null; _this.ca = null; _this.b8 = a; return _this; } Object.defineProperty(ScatterAreaSeriesView.prototype, "b7", { get: function () { return this.b4; }, set: function (a) { this.b4 = a; }, enumerable: false, configurable: true }); ScatterAreaSeriesView.prototype.ch = function (a, b) { }; ScatterAreaSeriesView.prototype.cd = function (a) { }; ScatterAreaSeriesView.prototype.b5 = function () { return this.b6(true); }; ScatterAreaSeriesView.prototype.b6 = function (a) { this.cg(); var b = truncate(Math.round(this.b1.left)); var c = truncate(Math.round(this.b1.left)); var d = truncate(Math.round(this.b1.width)); var e = truncate(Math.round(this.b1.height)); var f = d.toString(); var g = e.toString(); if (this.cb.getAttribute("width") != f) { this.cb.setAttribute("width", d.toString()); } if (this.cb.getAttribute("height") != g) { this.cb.setAttribute("height", e.toString()); } var h = this.ca.h(); if (a) { h.clearRect(0, 0, d, e); } this.cc = h.getImageData(0, 0, d, e); var imageDataArray_ = this.cc.data; return imageDataArray_; }; ScatterAreaSeriesView.prototype.cg = function () { if (this.cb == null) { this.cb = this.f.jz.createElement("canvas"); var a = this.f.jz.get2DCanvasContext(this.cb); this.ca = new RenderingContext(new CanvasViewRenderer(), a); } }; ScatterAreaSeriesView.prototype.b9 = function (a, b, c) { var d = truncate(Math.round(this.b1.left)); var e = truncate(Math.round(this.b1.left)); var f = truncate(Math.round(this.b1.width)); var g = truncate(Math.round(this.b1.height)); return new TriangleRasterizer(this.b5(), b, c.minimum, c.maximum, c, f, g); }; ScatterAreaSeriesView.prototype.cf = function (a) { this.ci(null); }; ScatterAreaSeriesView.prototype.ce = function () { if (this.ca != null) { this.ca.l(this.b1.left, this.b1.top, this.b1.width, this.b1.height); } this.av(); }; ScatterAreaSeriesView.prototype.bc = function (a, b) { _super.prototype.bc.call(this, a, b); if (this.cb == null) { return; } if (b) { var c = new Rectangle(); c.n = this.b1.left; c.o = this.b1.top; c.width = this.b1.width; c.height = this.b1.height; c._fill = this.bv(); a.w(c); } else { var d = truncate(Math.round(this.b1.left)); var e = truncate(Math.round(this.b1.top)); var f = truncate(Math.round(this.b1.width)); var g = truncate(Math.round(this.b1.height)); a.n(this.cb.getNativeElement(), 1, d, e, f, g); } }; ScatterAreaSeriesView.prototype.ci = function (a) { var b = truncate(Math.round(this.b1.left)); var c = truncate(Math.round(this.b1.left)); var d = truncate(Math.round(this.b1.width)); var e = truncate(Math.round(this.b1.height)); this.cg(); this.ca.h().putImageData(this.cc, 0, 0); this.av(); }; ScatterAreaSeriesView.prototype.aq = function (a) { _super.prototype.aq.call(this, a); var b = truncate(Math.round(this.b1.width)); var c = truncate(Math.round(this.b1.height)); var d = this.b6(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.b8.title + "</span><br/><span>" + "(${item." + this.b8.x2 + "}, ${item." + this.b8.ya + "})</span>"; if (!stringIsNullOrEmpty(this.b8.y9)) { a += "<span>, Value: ${item." + this.b8.y9 + "}</span>"; } a += "</div>"; return a; }; ScatterAreaSeriesView.$t = markType(ScatterAreaSeriesView, 'ScatterAreaSeriesView', SeriesView.$); return ScatterAreaSeriesView; }(SeriesView)); export { ScatterAreaSeriesView };