igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
716 lines (715 loc) • 26.4 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 { 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
*/
export let ValueLayer = /*@__PURE__*/ (() => {
class ValueLayer extends AnnotationLayer {
bk() {
return new ValueLayer();
}
get_eu() {
return true;
}
constructor() {
super();
this.z7 = [NaN, NaN];
this.aab = null;
this.aac = null;
this.adf = null;
this.aam = null;
this.aal = null;
let a = new ValueLayerFrame();
let b = new ValueLayerFrame();
let c = new ValueLayerFrame();
let d = this.kd / 1000;
this.xe = a;
this.xd = b;
this.xf = c;
this.ab = ValueLayer.$;
}
ct() {
return new ValueLayerView(this);
}
q1(a) {
super.q1(a);
this.aag = a;
}
gu(a) {
if (this.aad == null) {
return true;
}
if (this.aad == a) {
return true;
}
return false;
}
get adh() {
return new Thickness(1, this.aap, this.aar, this.aaq, this.aao);
}
get adi() {
return new Thickness(1, this.aav, this.aax, this.aaw, this.aau);
}
mc() {
return "Value Layer";
}
get_isSummarizationSupported() {
return false;
}
i5(a, b, c) {
if (isNaN_(this.z7[0]) && isNaN_(this.z7[1])) {
return super.i5(a, b, c);
}
if (!isNaN_(this.z7[0])) {
return this.z7[0];
}
return this.z7[1];
}
getDataLegendSeriesContextAt(a, b) {
if (isNaN_(this.z7[0]) || isNaN_(this.z7[1])) {
return super.getDataLegendSeriesContextAt(a, b);
}
if (this.aad == null) {
let c = new DataLegendSeriesValueInfo();
c.l = this.z7[0];
c.a = 0;
c.q = "Value";
c.r = "Value";
c.s = "";
let d = new DataLegendSeriesValueInfo();
d.l = this.z7[1];
d.a = 0;
d.q = "Value";
d.r = "Value";
d.s = "";
let e = new DataLegendSeriesContext();
e.e = ((() => {
let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
$ret.add(c);
$ret.add(d);
return $ret;
})());
e.h = this.mc();
return e;
}
let f = this.aad.getDataLegendSeriesContextAt(a, b);
let g = typeCast(DataLegendSeriesContext.$, f);
if (g == null || g.e == null) {
return super.getDataLegendSeriesContextAt(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;
}
yt(a, b) {
if (this.aad == null || this.aad == a) {
if (!this.a1.c) {
this.rs(b);
}
}
}
yv(a, b) {
super.yv(a, b);
let c = a;
let d = this.aak;
let 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;
let f = this.aae();
if (this.xk(this.aad)) {
let g = this.aad.aq(f);
this.z7 = g;
this.ab3(c, d, e, this.aad);
}
else {
if (f == 5 || f == 4 || f == 6) {
let h = null;
let i = null;
let j = [NaN, NaN];
let k = 0;
for (let l of fromEnum(this.dc.series)) {
if (!this.xk(l)) {
continue;
}
let m = l.ai();
for (let o = 0; o < m.length; o++) {
let n = m[o];
if (!this.aai(n)) {
continue;
}
let p = n.cp ? 1 : 0;
let q = j[p];
let r = null;
if (f == 5) {
let 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) {
let 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) {
let 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++;
}
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])) {
let v = h.wi(j);
this.ab5(h, { $type: Point_$type, x: v.x, y: NaN }, c, d, e);
}
if (i != null && !isNaN_(j[1])) {
let 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 {
for (let x of fromEnum(this.dc.series)) {
this.ab3(c, d, e, x);
}
}
}
}
ab3(a, b, c, d) {
if (this.xk(d)) {
this.ab4(d, a, b, c);
}
if (d.isStacked) {
d.p3((e) => {
if (this.xk(e)) {
this.ab4(e, a, b, c);
}
if (e.eh) {
e.p1((f) => {
if (this.xk(f)) {
this.ab4(f, a, b, c);
}
return true;
});
}
return true;
});
}
if (d.eh) {
d.p1((e) => {
if (this.xk(e)) {
this.ab4(e, a, b, c);
}
return true;
});
}
}
xk(a) {
if (!super.xk(a)) {
return false;
}
if (this.aa9 != null) {
if (a.isFragment) {
let b = a.nc();
if (!Base.equalsStatic(this.aa9, b)) {
return false;
}
}
else {
if (!Base.equalsStatic(this.aa9, a.name)) {
return false;
}
}
}
return true;
}
aai(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;
}
qp() {
super.qp();
if (!this.a1.c && !this.d4()) {
return;
}
if (this.d4()) {
this.ab6(this.xf, false);
}
else {
this.ab6(this.xd, false);
}
}
aae() {
if (this.aaf == 0) {
return 2;
}
return this.aaf;
}
w4() {
return 3;
}
xr() {
return 0.3;
}
xu() {
return -0.4;
}
xt() {
return 0.5;
}
zw() {
return this.w1 == 3 ? this.adg() : null;
}
zx() {
return this.w2 == 3 ? this.adg() : null;
}
adg() {
if (this.adf == null) {
this.adf = new DoubleCollection();
this.adf.add(DeviceUtils.g(5));
this.adf.add(DeviceUtils.g(5));
}
return this.adf;
}
ab5(a, b, c, d, e) {
let f = false;
let g = this.ac6;
if (g == null) {
g = a.vb;
f = true;
}
let h = false;
let i = this.ac9;
if (i == null) {
if (this.ac6 != null) {
i = this.ac6;
}
else {
i = a.vb;
h = true;
}
}
let j = false;
let k = this.adc;
if (k == null) {
if (this.ac6 != null) {
k = this.ac6;
}
else {
k = a.vb;
j = true;
}
}
let l = g;
let m = g;
let n = i;
let 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);
}
}
ab4(a, b, c, d) {
let e = { $type: Point_$type, x: NaN, y: NaN };
let 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;
}
let i = a.ai();
for (let h = 0; h < i.length; h++) {
let 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);
}
}
}
ab6(a, b) {
let 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);
}
ab2(a, b, c, d, e) {
let 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);
}
yy(a, b) {
super.yy(a, b);
let c = this.aag.cf;
let d = a;
let e = d.af.count;
let f = 0;
let g = b.b1.left;
let h = b.b1.right;
let i = b.b1.top;
let j = b.b1.bottom;
let k = this.adk == 0;
let l = this.adj == 0;
for (let m = 0; m < e; m++) {
let n = Math.floor(d.af._inner[m]);
let o = Math.floor(d.ag._inner[m]);
let p = null;
if (k) {
if (!isNaN_(o)) {
let q = this.ab2(c, f, m, d, true);
p = q.c;
f = q.d;
let r = new PathGeometry();
let s = new PathFigure();
s._startPoint = { $type: Point_$type, x: o, y: i };
let 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)) {
let u = this.ab2(c, f, m, d, false);
p = u.c;
f = u.d;
let v = new PathGeometry();
let w = new PathFigure();
w._startPoint = { $type: Point_$type, x: g, y: n };
let 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);
}
}
ga() {
return true;
}
ra(a, b, c, d) {
super.ra(a, b, c, d);
switch (b) {
case "SeriesViewer":
if (d == null) {
if (this.aal != null && this.aal.count > 0) {
let e;
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;
}
}
o5(a, b) {
super.o5(a, b);
if (a) {
AxisAnnotationFrameManager.b(this.xd);
this.ab6(this.xd, false);
}
}
}
ValueLayer.$t = /*@__PURE__*/ markType(ValueLayer, 'ValueLayer', AnnotationLayer.$);
ValueLayer.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ValueLayer, 'raisePropertyChanged', ['ActualValueLayerBrush:ac6:ab7', [Brush.$, null], 'HorizontalLineStroke:ac7:ab8', [Brush.$, null], 'HorizontalLineVisibility:adj:ab9', [Visibility_$type, /*@__PURE__*/ 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, /*@__PURE__*/ enumGetBox(ValueLayerValueMode_$type, 2)], 'VerticalLineStroke:ac8:aci', [Brush.$, null], 'VerticalLineVisibility:adk:acj', [Visibility_$type, /*@__PURE__*/ enumGetBox(Visibility_$type, 0)], 'XAxisAnnotationBackgroundCornerRadius:aan:ack', [1, /*@__PURE__*/ 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, /*@__PURE__*/ 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;
})();
/**
* @hidden
*/
export let ValueLayerView = /*@__PURE__*/ (() => {
class ValueLayerView extends AnnotationLayerView {
constructor(a) {
super(a);
this.ce = null;
this.cf = null;
this.cg = null;
this.ce = a;
this.cg = new List$1(Path.$, 0);
}
ax() {
super.ax();
this.cf = ((() => {
let $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;
}
cl() {
let a = new Path();
a.j = new TranslateTransform();
this.cg.add(a);
return a;
}
ch(a) {
a._visibility = 0;
}
cj(a) {
a._visibility = 1;
}
ci(a) {
this.cg.remove(a);
}
ck(a, b, c, d) {
if (a.an == null || a.an.c.x != d || a.an.d.x != c) {
let e = ((() => {
let $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;
}
}
bc(a, b) {
super.bc(a, b);
if (a.d && !b) {
for (let c = 0; c < this.cg.count; c++) {
let d = this.cg._inner[c];
if (d._visibility == 0) {
a.t(d);
}
}
}
}
aq(a) {
super.aq(a);
for (let b = 0; b < this.cg.count; b++) {
this.f.bc.exportPathData(a, this.cg._inner[b], "crosshairLine", ["Main", "Crosshair"]);
}
}
}
ValueLayerView.$t = /*@__PURE__*/ markType(ValueLayerView, 'ValueLayerView', AnnotationLayerView.$);
return ValueLayerView;
})();