igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
574 lines (573 loc) • 21.7 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 { ScatterTriangulationSeries } from "./ScatterTriangulationSeries";
import { DependencyProperty } from "igniteui-react-core";
import { Point_$type, typeCast, Number_$type, fromEnum, runOn, delegateRemove, delegateCombine, markType, markDep } from "igniteui-react-core";
import { ValueBrushScale } from "./ValueBrushScale";
import { FastItemIntColumn } from "igniteui-react-core";
import { LinearContourValueResolver } from "./LinearContourValueResolver";
import { SeriesView } from "./SeriesView";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { ContourBuilder } from "./ContourBuilder";
import { Clipper } from "igniteui-react-core";
import { RectUtil } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { BrushCollection } from "igniteui-react-core";
import { DataContext } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { boxArray$1 } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { PathGeometry } from "igniteui-react-core";
import { PathFigure } from "igniteui-react-core";
import { PointCollectionUtil } from "igniteui-react-core";
import { PolyLineSegment } from "igniteui-react-core";
import { Tuple$2 } from "igniteui-react-core";
import { GeometryUtil } from "igniteui-react-core";
import { stringIsNullOrEmpty } from "igniteui-react-core";
/**
* @hidden
*/
export let ScatterContourSeries = /*@__PURE__*/ (() => {
class ScatterContourSeries extends ScatterTriangulationSeries {
bk() {
return new ScatterContourSeries();
}
get_fk() {
return true;
}
constructor() {
super();
this.y1 = null;
this.yw = null;
FastItemIntColumn.m();
this.ab = ScatterContourSeries.$;
this.yx = new LinearContourValueResolver();
}
kr(a, b) {
let c = this.nf(b);
if (c == ScatterContourSeries.$$p[4]) {
return this.ks(a, b, this.za);
}
return super.kr(a, b);
}
mf(a) {
let b = this.nf(a);
if (b == ScatterContourSeries.$$p[4]) {
return this.za;
}
return super.mf(a);
}
ct() {
this.yy = new ScatterContourSeriesView(this);
return this.yy;
}
get y2() {
return this.y1;
}
set y2(a) {
let b = this.y2 != a;
if (b) {
let c = this.y2;
this.y1 = a;
this.raisePropertyChanged("ValueColumn", c, this.y2);
}
}
getDataLegendSeriesContextAt(a, b) {
let c = { $type: Point_$type, x: a, y: b };
let d = this.ko(c);
let e = d == null ? NaN : this.iy(d, "XMemberPath");
let f = d == null ? NaN : this.iy(d, "YMemberPath");
let g = d == null ? NaN : this.iy(d, "ValueMemberPath");
let h = new DataLegendSeriesValueInfo();
h.a = 13;
h.l = e;
h.q = "X";
h.r = this.x5 != null ? this.x5 : "X";
h.s = this.x1 != null ? this.x1 : "X:";
h.t = this.x3 != null ? this.x3 : "";
let i = new DataLegendSeriesValueInfo();
i.a = 14;
i.l = f;
i.q = "Y";
i.r = this.yd != null ? this.yd : "Y";
i.s = this.x9 != null ? this.x9 : "Y:";
i.t = this.yb != null ? this.yb : "";
let j = new DataLegendSeriesValueInfo();
j.a = 0;
j.l = g;
j.q = "Value";
j.r = this.za != null ? this.za : "Value";
j.s = this.y6 != null ? this.y6 : "V:";
j.t = this.y8 != null ? this.y8 : "";
let k = new DataLegendSeriesContext();
k.e = ((() => {
let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
$ret.add(h);
$ret.add(i);
$ret.add(j);
return $ret;
})());
k.h = this.me();
return k;
}
rc(a, b, c, d) {
super.rc(a, b, c, d);
switch (b) {
case ScatterContourSeries.$$p[2]:
case ScatterContourSeries.$$p[3]:
this.qh();
break;
case "FastItemsSource":
let e = typeCast(IFastItemsSource_$type, c);
if (e != null) {
e.deregisterColumn(this.y2);
this.y2 = null;
}
let f = typeCast(IFastItemsSource_$type, d);
if (f != null) {
this.y2 = this.dl(this.za);
}
this.ru(this.gh && c != null);
break;
case ScatterContourSeries.$$p[4]:
if (this.dp != null) {
this.dp.deregisterColumn(this.y2);
this.y2 = this.dl(this.za);
}
this.ru(false);
this.qn();
break;
case "ValueResolver":
this.ru(false);
this.qn();
break;
case ScatterContourSeries.$$p[1]:
let g = c;
let h = d;
if (g != null) {
g.unregisterSeries(this);
}
if (h != null) {
h.registerSeries(this);
}
this.ze();
this.ru(false);
this.qn();
break;
case "ActualBrush":
this.ze();
this.ru(false);
this.qn();
break;
}
}
o7(a, b) {
super.o7(a, b);
if (a) {
b.cj(a);
}
}
rv(a) {
super.rv(a);
this.zd(this.cw);
}
rt(a, b, c, d, e) {
super.rt(a, b, c, d, e);
let f = this.ba.a$j.item(d);
f.bd(c);
if (this.d7(f)) {
return;
}
this.zd(f);
}
zd(a) {
if (this.d7(a)) {
return;
}
let b;
let c;
let d = a;
let e = a.getViewInfo(c, b);
c = e.p0;
b = e.p1;
let f = new ScalerParams(1, b, c, this.w3.ch);
f.c = this.getEffectiveViewport1(a);
let g = new ScalerParams(1, b, c, this.w4.ch);
g.c = this.getEffectiveViewport1(a);
let h = this.w3;
let i = this.w4;
let j = this.xd.count;
let k;
let xArr_ = this.xg.asArray();
k = (xArr_.slice(0));
let l;
let yArr_ = this.xh.asArray();
l = (yArr_.slice(0));
let m = this.y2.asArray();
let n = this.xd.asArray();
let o = this.xe.asArray();
let p = this.xf.asArray();
let q = this.yx.j(this.y2);
let r = new List$1(Number_$type, 1, q).toArray();
h.hq(boxArray$1(k), 0, k.length, f);
i.hq(boxArray$1(l), 0, l.length, g);
let s = r.length;
let t = new Array(s);
for (let u = 0; u < s; ++u) {
t[u] = new ContourBuilder();
}
let v = c.top;
let w = c.left;
let x = c.right;
let y = c.bottom;
let z;
let aa;
let ab;
let ac;
let ad = k.length;
for (let ae = 0; ae < j; ae++) {
let af = n[ae];
let ag = o[ae];
let ah = p[ae];
if ((af >= ad) || (ag >= ad) || (ah >= ad) || (af < 0) || (ag < 0) || (ah < 0)) {
continue;
}
let ai = k[af];
let aj = l[af];
let ak = { $type: Point_$type, x: ai, y: aj };
let al = k[ag];
let am = l[ag];
let an = { $type: Point_$type, x: al, y: am };
let ao = k[ah];
let ap = l[ah];
let aq = { $type: Point_$type, x: ao, y: ap };
z = an.y < aq.y ? an.y : aq.y;
z = ak.y < z ? ak.y : z;
aa = an.y > aq.y ? an.y : aq.y;
aa = ak.y > aa ? ak.y : aa;
ab = an.x < aq.x ? an.x : aq.x;
ab = ak.x < ab ? ak.x : ab;
ac = an.x > aq.x ? an.x : aq.x;
ac = ak.x > ac ? ak.x : ac;
if (z < y && aa > v && ab < x && ac > w) {
let ar = m[af];
let as = m[ag];
let at = m[ah];
if (isNaN_(ar) || isNaN_(as) || isNaN_(at)) {
continue;
}
for (let au = 0; au < s; au++) {
let av = r[au];
let aw = t[au];
switch ((ar < av ? 1 : 0) | (as < av ? 2 : 0) | (at < av ? 4 : 0)) {
case 0: break;
case 1:
aw.d(aw.k(af, ak.x, ak.y, ar, ag, an.x, an.y, as, av), aw.k(ah, aq.x, aq.y, at, af, ak.x, ak.y, ar, av));
break;
case 2:
aw.d(aw.k(ag, an.x, an.y, as, ah, aq.x, aq.y, at, av), aw.k(af, ak.x, ak.y, ar, ag, an.x, an.y, as, av));
break;
case 3:
aw.d(aw.k(ag, an.x, an.y, as, ah, aq.x, aq.y, at, av), aw.k(ah, aq.x, aq.y, at, af, ak.x, ak.y, ar, av));
break;
case 4:
aw.d(aw.k(ah, aq.x, aq.y, at, af, ak.x, ak.y, ar, av), aw.k(ag, an.x, an.y, as, ah, aq.x, aq.y, at, av));
break;
case 5:
aw.d(aw.k(af, ak.x, ak.y, ar, ag, an.x, an.y, as, av), aw.k(ag, an.x, an.y, as, ah, aq.x, aq.y, at, av));
break;
case 6:
aw.d(aw.k(ah, aq.x, aq.y, at, af, ak.x, ak.y, ar, av), aw.k(af, ak.x, ak.y, ar, ag, an.x, an.y, as, av));
break;
case 7: break;
}
}
}
}
let ax = new Clipper(0, RectUtil.r(c, 2), false);
let ay = new List$1(List$1.$.specialize(List$1.$.specialize(Point_$type)), 0);
for (let az = 0; az < s; ++az) {
let a0 = t[az];
let a1 = new List$1(List$1.$.specialize(Point_$type), 0);
let a2 = a0.c();
for (let a3 = 0; a3 < a2.count; a3++) {
let a4 = a2._inner[a3];
let a5 = new List$1(Point_$type, 0);
ax.i = a5;
for (let a6 of fromEnum(a4)) {
ax.j({ $type: Point_$type, x: a0.g.item(a6), y: a0.h.item(a6) });
}
ax.i = null;
a1.add(a5);
}
ay.add(a1);
}
d.ci(ay, r);
}
sl() {
super.sl();
this.ze();
}
ze() {
let a = this.ve;
if (a == null) {
a = this.vk;
}
if (a == null) {
a = BrushUtil.j(255, 255, 255, 255);
}
let b = new ValueBrushScale();
b.brushes = new BrushCollection();
if (this.y0 == null || this.y0.brushes == null || this.y0.brushes.count == 0) {
b.brushes.add(BrushUtil.o(a, -0.5));
b.brushes.add(a);
}
else {
for (let c of fromEnum(this.y0.brushes)) {
b.brushes.add(c);
}
}
if (this.y0 != null) {
if (!isNaN_(this.y0.minimumValue)) {
b.minimumValue = this.y0.minimumValue;
}
if (!isNaN_(this.y0.maximumValue)) {
b.maximumValue = this.y0.maximumValue;
}
b.logarithmBase = this.y0.logarithmBase;
b.isLogarithmic = this.y0.isLogarithmic;
}
this.yz = b;
}
get yx() {
return this.yw;
}
set yx(a) {
let b = a != this.yx;
if (b) {
if (this.yw != null) {
let c = this.yw;
c.updated = delegateRemove(c.updated, runOn(this, this.zf));
}
let d = this.yw;
this.yw = a;
if (this.yw != null) {
let e = this.yw;
e.updated = delegateCombine(e.updated, runOn(this, this.zf));
}
this.raisePropertyChanged("ValueResolver", d, a);
this.ru(false);
}
}
zf(a, b) {
this.ru(false);
}
hf(a, b, c) {
return super.hf(a, b, c) && this.yx != null && this.xg != null && this.xh != null && this.xd != null && this.xe != null && this.xf != null && this.xg.count > 0 && this.xh.count > 0 && this.xd.count > 0 && this.xe.count > 0 && this.xf.count > 0;
}
a2(a, b) {
let c = this.yy.cn(a, b);
if (c != null) {
return c.dataContext;
}
return null;
}
}
ScatterContourSeries.$t = /*@__PURE__*/ markType(ScatterContourSeries, 'ScatterContourSeries', ScatterTriangulationSeries.$);
ScatterContourSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ScatterContourSeries, 'raisePropertyChanged', ['ActualFillScale:yz:zg', [ValueBrushScale.$, null], 'FillScale:y0:zh', [ValueBrushScale.$, null], 'ValueMemberAsLegendLabel:y6:zi', [2, null], 'ValueMemberAsLegendUnit:y8:zj', [2, null], 'ValueMemberPath:za:zk', [2, null]]);
return ScatterContourSeries;
})();
/**
* @hidden
*/
export let ScatterContourSeriesView = /*@__PURE__*/ (() => {
class ScatterContourSeriesView extends SeriesView {
constructor(a) {
super(a);
this.cf = null;
this.ce = null;
this.ch = null;
this.cg = new List$1(Brush.$, 0);
this.cd = null;
this.ch = new List$1(Path.$, 0);
this.ce = a;
this.cf = ((() => {
let $ret = new Pool$1(Path.$);
$ret.create = runOn(this, this.co);
$ret.destroy = runOn(this, this.cm);
$ret.activate = runOn(this, this.ck);
$ret.disactivate = runOn(this, this.cl);
return $ret;
})());
}
co() {
let a = new Path();
a.dataContext = ((() => {
let $ret = new DataContext();
$ret.series = this.f;
return $ret;
})());
this.ch.add(a);
return a;
}
ck(a) {
a._visibility = 0;
}
cl(a) {
a._visibility = 1;
}
cm(a) {
this.ch.remove(a);
}
ci(a, b) {
let c = 0;
this.cd = b;
this.cg.clear();
let d = this.ce.yz;
for (let e = 0; e < b.length; e++) {
let f = b[e];
let g = a._inner[c];
let h = new PathGeometry();
for (let i = 0; i < g.count; i++) {
let j = g._inner[i];
if (j.count == 0) {
continue;
}
let k = PointCollectionUtil.f(j);
let l = ((() => {
let $ret = new PathFigure();
$ret.isClosed = false;
$ret.isFilled = false;
$ret.startPoint = k._inner[0];
return $ret;
})());
l._segments.add(((() => {
let $ret = new PolyLineSegment();
$ret.points = k;
return $ret;
})()));
h.c.add(l);
}
this.cf.item(c).an = h;
if (this.cf.item(c).dataContext != null) {
this.cf.item(c).dataContext.item = f;
}
if (d != null) {
let m = d.getBrushByValue(f, this.ce.y2);
if (m == null) {
m = this.f.ve;
}
this.cg.add(m);
}
else {
this.cg.add(this.f.ve);
}
c++;
}
this.cf.count = c;
this.a2();
}
bs(a, b) {
super.bs(a, b);
let c = a;
c._stroke = this.cg._inner[b];
c.ad = this.f.ig;
if (c.y != null) {
this.m.j(c, c.y);
}
}
bt(a, b) {
super.bt(a, b);
let c = a;
let d = this.b4(b);
c._stroke = d;
c.ad = this.f.ig + 3;
}
bj(a, b) {
super.bj(a, b);
for (let c = 0; c < this.ch.count; c++) {
let d = this.ch._inner[c];
if (d._visibility != 1) {
this.br(d, c, b);
a.t(d);
}
}
}
cj(a) {
this.cf.count = 0;
this.a2();
}
ax(a) {
super.ax(a);
let b = new List$1(Tuple$2.$.specialize(Number_$type, Path.$), 0);
if (this.cd != null) {
for (let c = 0; c < this.cf.count; c++) {
b.add(new Tuple$2(Number_$type, Path.$, this.cd[c], this.cf.item(c)));
}
}
b.aa((d, e) => {
if (d.c < e.c) {
return -1;
}
else if (d.c > e.c) {
return 1;
}
return 0;
});
for (let d = 0; d < b.count; d++) {
let e = typeCast(Path.$, b._inner[d].d);
if (e._visibility != 1) {
this.f.bc.exportPathData(a, e, "contour" + d, ["Main "]);
}
}
}
getDefaultTooltipTemplate() {
let a = "<div class='ui-chart-default-tooltip-content'><span";
let b = this.f.ba.a$u(this.f);
if (!stringIsNullOrEmpty(b)) {
a += " style='color:" + b + "'";
}
a += ">" + this.ce.title + "</span><br/>";
if (!stringIsNullOrEmpty(this.ce.za)) {
a += "<span>Value: ${item}</span>";
}
a += "</div>";
return a;
}
cn(a, b) {
for (let c = 0; c < this.ch.count; c++) {
let d = this.ch._inner[c];
let e = typeCast(PathGeometry.$, d.an);
if (e != null) {
for (let f = 0; f < e.c.count; f++) {
let g = e.c._inner[f];
let h = e.c._inner[f]._startPoint;
for (let i = 0; i < g._segments.count; i++) {
let j = typeCast(PolyLineSegment.$, g._segments._inner[i]);
if (j != null) {
let k = this.ce.ig / 2 + this.ce.iv(b);
if (j._points.count > 0 && GeometryUtil.e(a, h, j._points, k)) {
return d;
}
}
}
}
}
}
return null;
}
}
ScatterContourSeriesView.$t = /*@__PURE__*/ markType(ScatterContourSeriesView, 'ScatterContourSeriesView', SeriesView.$);
return ScatterContourSeriesView;
})();