igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
656 lines (655 loc) • 23.5 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 { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core";
import { CategoryItemHighlightType_$type } from "./CategoryItemHighlightType";
import { MarkerType_$type } from "./MarkerType";
import { Brush } from "igniteui-react-core";
import { DataTemplate } from "igniteui-react-core";
import { CategoryItemHighlightLayerFrame } from "./CategoryItemHighlightLayerFrame";
import { Base, enumGetBox, fromEnum, typeCast, Point_$type, markType, markDep, runOn } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { ItemHighlightFrameRect } from "./ItemHighlightFrameRect";
import { List$1 } from "igniteui-react-core";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { Rect } from "igniteui-react-core";
import { MarkerSeries } from "./MarkerSeries";
import { DataContext } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { ContentControl } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, isInfinity, truncate } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { Marker } from "./Marker";
import { BrushUtil } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { DataTemplatePassInfo } from "igniteui-react-core";
import { DataTemplateRenderInfo } from "igniteui-react-core";
import { DataTemplateMeasureInfo } from "igniteui-react-core";
/**
* @hidden
*/
export let CategoryItemHighlightLayer = /*@__PURE__*/ (() => {
class CategoryItemHighlightLayer extends AnnotationLayer {
bk() {
return new CategoryItemHighlightLayer();
}
get_es() {
return true;
}
constructor() {
super();
this.aad = false;
this.aac = true;
this.aag = 10;
let a = new CategoryItemHighlightLayerFrame();
let b = new CategoryItemHighlightLayerFrame();
let c = new CategoryItemHighlightLayerFrame();
this.xe = a;
this.xd = b;
this.xf = c;
this.ab = CategoryItemHighlightLayer.$;
}
ct() {
return new CategoryItemHighlightLayerView(this);
}
q1(a) {
super.q1(a);
this.z7 = a;
}
yt(a, b) {
if (this.aab == null || this.aab == a) {
if (!this.a1.c) {
this.rs(b);
}
}
}
xk(a) {
if (!super.xk(a)) {
return false;
}
if (this.aap != null) {
if (a.isFragment) {
let b = a.nc();
if (!Base.equalsStatic(this.aap, b)) {
return false;
}
}
else {
if (!Base.equalsStatic(this.aap, a.name)) {
return false;
}
}
}
let c = this.yo(a);
if (!c.c) {
return false;
}
return true;
}
yv(a, b) {
super.yv(a, b);
let c = a;
let d = this.aaf;
c.g.clear();
if (isNaN_(this.z4.x) && isNaN_(this.z4.y)) {
return;
}
if (this.xk(this.aab)) {
this.aav(this.aab, c, d);
}
else {
for (let e of fromEnum(this.dc.series)) {
if (this.xk(e)) {
this.aav(e, c, d);
}
if (e.isStacked) {
e.p3((f) => {
if (this.xk(f)) {
this.aav(f, c, d);
}
if (f.eh) {
f.p1((g) => {
if (this.xk(g)) {
this.aav(g, c, d);
}
return true;
});
}
return true;
});
}
if (e.eh) {
e.p1((f) => {
if (this.xk(f)) {
this.aav(f, c, d);
}
return true;
});
}
}
}
}
ra(a, b, c, d) {
super.ra(a, b, c, d);
switch (b) {
case CategoryItemHighlightLayer.$$p[4]:
case CategoryItemHighlightLayer.$$p[5]:
case CategoryItemHighlightLayer.$$p[2]:
case CategoryItemHighlightLayer.$$p[3]:
this.rs(true);
break;
case CategoryItemHighlightLayer.$$p[7]:
case CategoryItemHighlightLayer.$$p[8]:
this.rs(true);
break;
case CategoryItemHighlightLayer.$$p[9]:
this.aad = d;
this.rs(true);
break;
case CategoryItemHighlightLayer.$$p[1]:
this.rs(true);
break;
case CategoryItemHighlightLayer.$$p[0]:
this.aag = this.aah;
this.rs(true);
break;
case CategoryItemHighlightLayer.$$p[6]:
this.aac = d;
this.rs(true);
break;
}
}
aav(a, b, c) {
if (this.cw == null || this.cw.b2.isEmpty || this.cw.b1.isEmpty) {
return;
}
if (!a.ez && !a.e7) {
return;
}
let d = a;
if (d.categoryAxis == null) {
return;
}
let e = this.z4.x;
e = this.cw.b1.left + this.cw.b1.width * (e - this.cw.b2.left) / this.cw.b2.width;
let f = this.z4.y;
f = this.cw.b1.top + this.cw.b1.height * (f - this.cw.b2.top) / this.cw.b2.height;
let g = this.aae;
let h = true;
let i = typeCast(IHasCategoryModePreference_$type, a);
let j = 0;
if (i != null) {
j = i.preferredCategoryMode(d.categoryAxis);
if (j == 2) {
h = false;
}
}
let k = true;
if (!h || this.z8 == 2) {
k = false;
}
if (this.z8 == 1) {
k = true;
}
let l = this.yo(a);
if (!l.c) {
return;
}
if (k) {
let m = a.we(l.d, this.aaf, g);
if (j != 0 && !d.categoryAxis.cn) {
let n = m.x;
if (a.e7) {
n -= a.getOffsetValue();
n += a.getCategoryWidth() * 0.5;
m = { $type: Point_$type, x: n, y: m.y };
}
else if (a.ez) {
n -= a.getOffsetValue();
n += a.getCategoryWidth() * 0.5;
m = { $type: Point_$type, x: n, y: m.y };
}
}
if (!isNaN_(m.x) && !isNaN_(m.y)) {
m = this.wj(m);
}
this.aat(m, b, a);
}
else {
let o = a.we(l.d, this.aaf, g);
let p;
let q = this.getEffectiveViewport1(this.cw);
if (a.isVertical) {
let r = o.y;
let s = d.categoryAxis;
let t = this.aag;
if (j != 0) {
t = s.k8(this.cw.b2, this.cw.b1, q);
}
if (isNaN_(t) || isInfinity(t)) {
return;
}
p = new Rect(0, this.wu.left, r - t / 2, this.wu.width, t);
}
else {
let u = o.x;
let v = d.categoryAxis;
let w = this.aag;
if (j != 0) {
w = v.k8(this.cw.b2, this.cw.b1, q);
}
if (isNaN_(w) || isInfinity(w)) {
return;
}
p = new Rect(0, u - w / 2, this.wu.top, w, this.wu.height);
}
p.intersect(this.cw.b1);
this.aau(p, b, a);
}
}
aat(a, b, c) {
let d = new ItemHighlightFrameRect();
d.b = a.x;
d.e = a.y;
d.i = this.zq();
if (this.aa9 != null) {
d.i = this.aa9;
}
d.j = this.zr();
if (this.aba != null) {
d.j = this.aba;
}
if (d.i == null) {
if (c.hasMarkers) {
d.i = this.z7.cs(c.vn());
}
else {
d.i = this.z7.cs(c.vb);
}
}
if (d.j == null) {
if (c.hasMarkers) {
d.j = this.z7.cs(c.vo());
}
else {
d.j = this.z7.cs(c.vf);
}
}
d.d = this.ie;
d.f = Base.getHashCodeStatic(c);
d.g = this.z9(c, a);
let e = (typeCast(MarkerSeries.$, c) !== null) ? c.x2 : null;
if (e == null || e == MarkerSeries.x5 || (this.aaa != 2 && this.aaa != 0)) {
let f = MarkerSeries.xd(c, 2);
if (this.aaa != 2 && this.aaa != 0) {
f = this.aaa;
}
switch (f) {
case 3:
case 13:
e = this.dc.r2;
break;
case 4:
e = this.dc.sb;
break;
case 5:
e = this.dc.r8;
break;
case 6:
e = this.dc.r9;
break;
case 7:
e = this.dc.r3;
break;
case 8:
e = this.dc.r6;
break;
case 9:
e = this.dc.r4;
break;
case 10:
e = this.dc.sa;
break;
case 11:
e = this.dc.r7;
break;
case 12:
e = this.dc.r5;
break;
}
}
d.h = this.aay != null ? this.aay : e;
if (!isNaN_(d.b) && !isNaN_(d.e)) {
b.g.addItem(d.f, d);
}
}
z9(a, b) {
let c = a.kn(b);
let d = a.ir(b);
if (this.aaf && d != Math.floor(d)) {
c = null;
}
return ((() => {
let $ret = new DataContext();
$ret.series = a;
$ret.item = c;
return $ret;
})());
}
aau(a, b, c) {
let d = new ItemHighlightFrameRect();
d.b = a.left;
d.e = a.top;
d.c = a.right;
d.a = a.bottom;
d.i = this.zq();
d.j = this.zr();
if (d.i == null) {
if (c != null) {
d.i = this.z7.ct(c.vb);
}
}
if (d.j == null) {
if (c != null) {
d.j = this.z7.ct(c.vf);
}
}
d.d = this.ie;
d.f = Base.getHashCodeStatic(c);
if (!a.isEmpty) {
b.g.addItem(d.f, d);
}
}
yy(a, b) {
super.yy(a, b);
let c = this.z7.cg;
let d = this.z7.cf;
let e = 0;
let f = 0;
let g = a;
for (let h of fromEnum(g.g.values)) {
if (h.h != null) {
let i = d.item(f);
this.aaw(h, i);
f++;
}
else {
let j = c.item(e);
this.aax(h, j);
e++;
}
}
c.count = e;
d.count = f;
}
aaw(a, b) {
if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.d) || a.g == null) {
b._visibility = 1;
return;
}
let c = { $type: Point_$type, x: a.b, y: a.e };
let d = a.g;
d.itemBrush = a.i;
let e = d.series.we(c, this.d4() || this.aad, this.aac);
if (isNaN_(e.x) || isNaN_(e.y)) {
b._visibility = 1;
return;
}
this.z7.cm(b, e.x, e.y);
b.ah = a.h;
b.content = a.g;
}
aax(a, b) {
if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.a) || isNaN_(a.c) || isNaN_(a.d)) {
b._visibility = 1;
return;
}
this.z7.cn(b, a.b, a.e, a.c - a.b, a.a - a.e);
b._fill = a.i;
b._stroke = a.j;
b.ad = a.d;
if (this.v4 != null) {
b.ai = this.v4;
}
else {
b.ai = null;
}
b.aj = this.v5;
b.am = this.v7;
b.al = this.v6;
b.ak = this.v6;
b.ac = this.jh;
}
ga() {
return true;
}
}
CategoryItemHighlightLayer.$t = /*@__PURE__*/ markType(CategoryItemHighlightLayer, 'CategoryItemHighlightLayer', AnnotationLayer.$);
CategoryItemHighlightLayer.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryItemHighlightLayer, 'raisePropertyChanged', ['BandHighlightWidth:aah:aaz', [1, 10], 'HighlightType:z8:aa0', [CategoryItemHighlightType_$type, /*@__PURE__*/ enumGetBox(CategoryItemHighlightType_$type, 0)], 'MarkerBrush:aa9:aa1', [Brush.$, null], 'MarkerOutline:aba:aa2', [Brush.$, null], 'MarkerTemplate:aay:aa3', [DataTemplate.$, null], 'MarkerType:aaa:aa4', [MarkerType_$type, /*@__PURE__*/ enumGetBox(MarkerType_$type, 2)], 'SkipUnknownValues:aae:aa5', [0, true], 'TargetSeriesName:aap:aa6', [2, null], 'TargetSeries:aab:aa7', [Series.$, null], 'UseInterpolation:aaf:aa8', [0, false]]);
return CategoryItemHighlightLayer;
})();
/**
* @hidden
*/
export let CategoryItemHighlightLayerView = /*@__PURE__*/ (() => {
class CategoryItemHighlightLayerView extends AnnotationLayerView {
constructor(a) {
super(a);
this.ce = null;
this.cg = null;
this.cf = null;
this.ch = null;
this.ci = null;
this.ce = a;
this.ch = new List$1(ContentControl.$, 0);
this.ci = new List$1(Rectangle.$, 0);
}
ax() {
super.ax();
this.cg = ((() => {
let $ret = new Pool$1(Rectangle.$);
$ret.create = runOn(this, this.cu);
$ret.activate = runOn(this, this.co);
$ret.disactivate = runOn(this, this.cq);
$ret.destroy = runOn(this, this.cp);
return $ret;
})());
this.cf = ((() => {
let $ret = new Pool$1(ContentControl.$);
$ret.create = runOn(this, this.cr);
$ret.activate = runOn(this, this.cj);
$ret.disactivate = runOn(this, this.cl);
$ret.destroy = runOn(this, this.ck);
return $ret;
})());
}
cu() {
let a = new Rectangle();
a.ab = false;
this.ci.add(a);
return a;
}
co(a) {
a._visibility = 0;
}
cq(a) {
a._visibility = 1;
}
cp(a) {
this.ci.remove(a);
}
cr() {
let a = new Marker();
this.ch.add(a);
return a;
}
cj(a) {
a._visibility = 0;
}
cl(a) {
a._visibility = 1;
}
ck(a) {
this.ch.remove(a);
}
cs(a) {
if (a == null) {
return a;
}
return BrushUtil.m(a, 0.3);
}
ct(a) {
if (a != null) {
let b = BrushUtil.m(a, 0.3);
if (b.isGradient) {
let c = b;
if (c.gradientStops != null) {
for (let d = 0; d < c.gradientStops.length; d++) {
let e = c.gradientStops[d];
e.color = Color.u(truncate(Math.round((e.color.l) * 0.3)), e.color.o, e.color.n, e.color.m);
e.color = e.color;
}
}
}
else {
b.color = Color.u(truncate(Math.round((b.color.l & 255) * 0.3)), b.color.o, b.color.n, b.color.m);
b.color = b.color;
}
return b;
}
else {
return null;
}
}
cn(a, b, c, d, e) {
a._visibility = 0;
a.n = b;
a.o = c;
a.width = d;
a.height = e;
}
cm(a, b, c) {
a.n = b;
a.o = c;
}
bn(a, b) {
super.bn(a, b);
let c = a;
let d = c.content;
if (d != null) {
if (d.itemBrush != null) {
d.actualItemBrush = d.itemBrush;
}
let e = d.series;
if (e.hasMarkers) {
d.outline = e.vo();
}
d.thickness = e.io();
}
}
bc(a, b) {
super.bc(a, b);
if (a.d && !b) {
for (let c = 0; c < this.ci.count; c++) {
let d = this.ci._inner[c];
if (d._visibility == 0) {
a.w(d);
}
}
if (this.ch.count > 0) {
let e = new DataTemplatePassInfo();
e.isHitTestRender = b;
e.context = a.h();
e.viewportTop = this.b1.top;
e.viewportLeft = this.b1.left;
e.viewportWidth = this.b1.width;
e.viewportHeight = this.b1.height;
e.passID = "ItemMarkers";
let f = new DataTemplateRenderInfo();
f.isHitTestRender = b;
f.passInfo = e;
let g = new DataTemplateMeasureInfo();
g.passInfo = e;
let h = false;
let i = a.h();
g.context = i;
f.context = i;
g.renderContext = a;
f.renderContext = a;
let j = 0;
let k = 0;
let l = new Dictionary$2(DataTemplate.$, DataTemplate.$, 0);
for (let m = 0; m < this.ch.count; m++) {
let n = this.ch._inner[m];
if (n == null || n.ah == null) {
continue;
}
let o = n.ah;
if (!l.containsKey(o)) {
l.addItem(o, o);
if (o != null && o.passStarting != null) {
o.passStarting(e);
}
}
if (n._visibility == 1) {
continue;
}
this.bm(n, m, b);
if (!h) {
g.data = n.content;
g.width = n.width;
g.height = n.height;
if (o.measure != null) {
g.data = n.content;
o.measure(g);
h = g.isConstant;
if (h) {
j = g.width;
k = g.height;
}
}
f.availableWidth = g.width;
f.availableHeight = g.height;
}
else {
f.availableWidth = j;
f.availableHeight = k;
}
if (!isNaN_(n.width) && !isInfinity(n.width)) {
f.availableWidth = n.width;
}
if (!isNaN_(n.height) && !isInfinity(n.height)) {
f.availableHeight = n.height;
}
a.q(f, n);
n.m = f.availableWidth;
n.l = f.availableHeight;
}
for (let p of fromEnum(l.keys)) {
if (p != null && p.passCompleted != null) {
p.passCompleted(e);
}
}
}
}
}
aq(a) {
super.aq(a);
for (let b = 0; b < this.ci.count; b++) {
this.f.bc.exportRectangleData(a, this.ci._inner[b], "catItemRect", ["Main", "CategoryItem"]);
}
for (let c = 0; c < this.ch.count; c++) {
this.f.bc.exportMarkerVisualDataFromMarker(this.f, a, this.ch._inner[c]);
}
}
}
CategoryItemHighlightLayerView.$t = /*@__PURE__*/ markType(CategoryItemHighlightLayerView, 'CategoryItemHighlightLayerView', AnnotationLayerView.$);
return CategoryItemHighlightLayerView;
})();