UNPKG

igniteui-react-charts

Version:

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

662 lines (661 loc) 24 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 { AnchoredRadialSeries } from "./AnchoredRadialSeries"; import { DependencyProperty } from "igniteui-react-core"; import { enumGetBox, Point_$type, runOn, typeCast, markType, markDep, fromEnum } from "igniteui-react-core"; import { LegendEmptyValuesMode_$type } from "igniteui-react-core"; import { Defaults } from "./Defaults"; import { Pool$1 } from "igniteui-react-core"; import { Path } from "igniteui-react-core"; import { List$1 } from "igniteui-react-core"; import { Rect } from "igniteui-react-core"; import { RadialBaseView } from "./RadialBaseView"; import { ScalerParams } from "./ScalerParams"; import { PathGeometry } from "igniteui-react-core"; import { ViewportUtils } from "./ViewportUtils"; import { SliceCoords } from "./SliceCoords"; import { PathFigure } from "igniteui-react-core"; import { LineSegment } from "igniteui-react-core"; import { ArcSegment } from "igniteui-react-core"; import { PieSliceCollisionGeometry } from "igniteui-react-core"; import { Size } from "igniteui-react-core"; import { GeometryUtil } from "igniteui-react-core"; import { MathUtil } from "igniteui-react-core"; import { ProportionalCategoryAngleAxis } from "./ProportionalCategoryAngleAxis"; import { SeriesPointOfInterest } from "./SeriesPointOfInterest"; import { DataContext } from "igniteui-react-core"; import { ChartSelection } from "./ChartSelection"; import { CollisionRect } from "igniteui-react-core"; import { PropertyMetadata } from "igniteui-react-core"; import { intDivide, isNaN_ } from "igniteui-react-core"; import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView"; /** * @hidden */ export let RadialPieSeries = /*@__PURE__*/ (() => { class RadialPieSeries extends AnchoredRadialSeries { bk() { return new RadialPieSeries(); } get_fn() { return true; } get_fl() { return true; } jk() { if (!isNaN_(this.jj)) { return super.jk(); } return Defaults.h; } ct() { return new RadialPieSeriesView(this); } q1(a) { super.q1(a); this.adt = a; } constructor() { super(); this.adu = null; this.adz = null; this.adr = 0; this.ab = RadialPieSeries.$; } get adv() { return this.adu; } set adv(a) { if (this.adu != a) { let b = this.adv; this.adu = a; this.raisePropertyChanged("LegendLabelColumn", b, this.adv); } } get ad2() { return this.adz; } set ad2(a) { if (this.adz != a) { let b = this.adz; this.adz = a; this.raisePropertyChanged("LegendLabelMemberPath", b, this.adz); } } get ads() { return this.adr; } set ads(a) { if (this.adr != a) { let b = this.adr; this.adr = a; this.raisePropertyChanged("LegendEmptyValuesMode", enumGetBox(LegendEmptyValuesMode_$type, b), enumGetBox(LegendEmptyValuesMode_$type, this.adr)); } } preferredCategoryMode(a) { return a != null && a == this.y1 ? 2 : 0; } o5(a, b) { super.o5(a, b); let c = b; if (a && c.da != null) { c.da.count = 0; } } iw() { return this.y1.k8(this.cw.b2, this.cw.b1, this.getEffectiveViewport1(this.cw)); } ar(a, b) { let c = new List$1(Rect.$, 0); let d = this.cw.b2; let e = this.cw.b1; let f = this.getEffectiveViewport1(this.cw); let g = this.wl(this.cw); let h = this.y7.k5(e, d, f, g); let i = { $type: Point_$type, x: 0.5, y: 0.5 }; let j = this.y7; let k = Math.max(0, 0.5 * j.n6); let l = k; l = Math.max(l, h.minLength); let m = this.y1.k8(d, e, f); let n = this.y1 != null && this.y1.cl; let o = this.zc; if (this.d4()) { o = this.zf; } { if (n) { m = this.z2(a, d, e, f); } if (b < 0 || b > o.h.count - 1) { return null; } let p = o.h._inner[b][0]; let q = Math.min(o.h._inner[b][2], h.maxLength); return this.adw(d, e, f, p - (m * 0.5), p + (m * 0.5), l, q, i); } } get_ee() { return true; } get_aci() { return true; } get_acc() { return true; } abe(a, b) { super.abe(a, b); let c = b; let d = b.b2; let e = b.b1; let f = this.getEffectiveViewport1(b); let g = this.wl(b); let h = this.y7.k5(e, d, f, g); let i = a.h; let j = this.y7; let k = Math.max(0, 0.5 * j.n6); let l = k; l = Math.max(l, h.minLength); let m = this.y1.k8(d, e, f); let n = this.y1.cl; let o = { $type: Point_$type, x: 0.5, y: 0.5 }; let p = this.adx; let q = this.ady; let r = (p > 0 && q > 0); let s = this.aca.count; this.zi.a2(this, this.zz(), runOn(this, this.yp), this.z8(b), this.z9(b)); this.zi.r = this.adx; this.zi.s = this.ady; this.zi.k = this.adx; this.zi.l = this.ady; let t = false; let u = this.zi.b; if (u != null) { t = true; } let v = this.y1; let w = new ScalerParams(1, b.b2, b.b1, v.ch); w.c = this.getEffectiveViewport(); let x = 0; let y = 0; for (let z = 0; z < i.count; ++z) { let aa = i._inner[z][0]; let ab = Math.min(i._inner[z][2], h.maxLength); let ac = i._inner[z][1]; let ad = i._inner[z][2]; let ae = i._inner[z][3]; if (t) { this.ac7(i, z, s, v, w, b.r); } if (n) { if (isNaN_(aa) || isNaN_(ac) || isNaN_(ad)) { continue; } let af = (b.c1.c + z) * b.c1.b; if ((b.c1.c + z) * b.c1.b > this.y1.lk - 1) { if ((af) * b.c1.b >= this.y1.lj) { af = (af) - (intDivide((this.y1.lj), b.c1.b)); } } m = ae; if (isNaN_(m)) { continue; } } let ag = c.da.item(x); x++; let ah = this.zi.k; let ai = this.zi.l; r = (ah > 0 && ai > 0); let aj = null; if (r) { aj = this.ad8(d, e, f, aa - (m * 0.5), aa + (m * 0.5), l, ab, o, ah, ai); } else { aj = this.ad9(d, e, f, aa - (m * 0.5), aa + (m * 0.5), l, ab, o); } ag.an = aj; this.zi.ad(ag, false, false, false, false); let ak = i._inner[z][2]; if (ak > y) { y = ak; } } c.c3 = ViewportUtils.f(y, d, e); c.c4 = { $type: Point_$type, x: ViewportUtils.e(o.x, d, e, f), y: ViewportUtils.i(o.y, d, e, f) }; c.da.count = x; c.df(); } ad9(a, b, c, d, e, f, g, h) { let i = SliceCoords.b(a, b, c, d, e, f, g, h); let j = new PathFigure(); j._startPoint = i.d; j._isClosed = true; j._segments.add(((() => { let $ret = new LineSegment(1); $ret.c = i.f; return $ret; })())); j._segments.add(((() => { let $ret = new ArcSegment(); $ret.e = i.h; $ret.f = i.n; $ret.d = 1; $ret.b = i.c; return $ret; })())); j._segments.add(((() => { let $ret = new LineSegment(1); $ret.c = i.j; return $ret; })())); j._segments.add(((() => { let $ret = new ArcSegment(); $ret.e = i.d; $ret.f = i.m; $ret.d = 0; $ret.b = i.c; return $ret; })())); let k = new PathGeometry(); k.c.add(j); return k; } adw(a, b, c, d, e, f, g, h) { let i = SliceCoords.b(a, b, c, d, e, f, g, h); if (isNaN_(i.n.width) || isNaN_(d) || isNaN_(e)) { return null; } let j = ViewportUtils.e(0.5, a, b, c); let k = ViewportUtils.i(0.5, a, b, c); return new PieSliceCollisionGeometry(j, k, i.n.width, i.m.width, d, e); } ad8(a, b, c, d, e, f, g, h, i, j) { let k = SliceCoords.a(a, b, c, d, e, f, g, h, i, j); if (k == null) { return this.ad9(a, b, c, d, e, f, g, h); } let l = new PathFigure(); l._startPoint = k.d; l._isClosed = true; let m = ((d + ((e - d) * 0.5)) * 180 / Math.PI) + 90; let n = new Size(1, k.l.width * (f / g), k.l.height * (f / g)); l._segments.add(((() => { let $ret = new ArcSegment(); $ret.e = k.e; $ret.f = n; $ret.c = m; $ret.d = 1; $ret.b = false; return $ret; })())); l._segments.add(((() => { let $ret = new LineSegment(1); $ret.c = k.f; return $ret; })())); l._segments.add(((() => { let $ret = new ArcSegment(); $ret.e = k.g; $ret.f = k.l; $ret.c = m; $ret.d = 1; $ret.b = false; return $ret; })())); l._segments.add(((() => { let $ret = new ArcSegment(); $ret.e = k.h; $ret.f = k.n; $ret.d = 1; $ret.b = k.c; return $ret; })())); l._segments.add(((() => { let $ret = new ArcSegment(); $ret.e = k.i; $ret.f = k.l; $ret.c = m; $ret.d = 1; $ret.b = false; return $ret; })())); l._segments.add(((() => { let $ret = new LineSegment(1); $ret.c = k.j; return $ret; })())); l._segments.add(((() => { let $ret = new ArcSegment(); $ret.e = k.k; $ret.f = n; $ret.c = m; $ret.d = 1; $ret.b = false; return $ret; })())); l._segments.add(((() => { let $ret = new ArcSegment(); $ret.e = k.d; $ret.f = k.m; $ret.d = 0; $ret.b = k.c; return $ret; })())); let o = new PathGeometry(); o.c.add(l); return o; } ra(a, b, c, d) { super.ra(a, b, c, d); switch (b) { case RadialPieSeries.$$p[0]: case RadialPieSeries.$$p[1]: this.q3(); break; case "FastItemsSource": if (c != null) { if (this.adv != null) { c.deregisterColumn(this.adv); } } if (d != null) { if (this.ad2 != null) { this.adv = this.dn(this.ad2); } } break; case "LegendLabelMemberPath": if (this.dp != null) { this.dp.deregisterColumn(this.adv); this.adv = this.dn(this.ad2); this.pe(); this.pt(); } break; } } wp(a) { let b = this.adt.b2; let c = this.adt.b1; let d = this.getEffectiveViewport1(this.adt); let e = this.wl(this.adt); let f = this.y7.k5(c, b, d, e); let g = { $type: Point_$type, x: 0.5, y: 0.5 }; let h = GeometryUtil.j(g, a); let i = this.zc.h; let j = 0; for (let k = 0; k < i.count; k++) { let l = i._inner[k][0]; let m = Math.min(i._inner[k][2], f.maxLength); let n = i._inner[k][3]; if (isNaN_(n)) { continue; } l = l % 6.28318531; if (l < 0) { l += 6.28318531; } if (h >= l - (n * 0.5) && h <= l + (n * 0.5)) { let o = Math.max(0, 0.5 * this.y7.n6); let p = o; p = Math.max(p, f.minLength); let q = SliceCoords.b(b, c, d, l - (n * 0.5), l + (n * 0.5), p, m, g); let r = GeometryUtil.u({ $type: Point_$type, x: ViewportUtils.e(g.x, b, c, d), y: ViewportUtils.i(g.y, b, c, d) }, MathUtil.f(l), q.n.width); let s = 1.7976931348623157E+308; let t = 1.7976931348623157E+308; let u = -1.7976931348623157E+308; let v = -1.7976931348623157E+308; s = Math.min(s, q.d.x); s = Math.min(s, q.f.x); s = Math.min(s, q.h.x); s = Math.min(s, q.j.x); s = Math.min(s, r.x); t = Math.min(t, q.d.y); t = Math.min(t, q.f.y); t = Math.min(t, q.h.y); t = Math.min(t, q.j.y); t = Math.min(t, r.y); u = Math.max(u, q.d.x); u = Math.max(u, q.f.x); u = Math.max(u, q.h.x); u = Math.max(u, q.j.x); u = Math.max(u, r.x); v = Math.max(v, q.d.y); v = Math.max(v, q.f.y); v = Math.max(v, q.h.y); v = Math.max(v, q.j.y); v = Math.max(v, r.y); return new Rect(0, s, t, u - s, v - t); } j++; } return new Rect(0, 0, 0, 0, 0); } ku(a) { if (this.y1 != null && this.y1.cl && a == this.y1.othersIndex) { return null; } if (this.adv != null) { return this.adv.item(a); } return null; } ec(a, b, c, d, e) { if (super.ec(a, b, c, d, e)) { let f = typeCast(ProportionalCategoryAngleAxis.$, this.y1) !== null && this.y1.hasOthersCategory; if (e && (this.ads == 1 || (this.ads == 2 && !f))) { let g = this.y1; let h = new ScalerParams(1, this.dc.v5, this.wu, g.ch); h.c = this.getEffectiveViewport1(this.cw); let i = this.y7; let j = new ScalerParams(1, this.dc.v5, this.wu, i.ch); j.c = this.getEffectiveViewport1(this.cw); let k = this.z7; for (let l = 0; l < this.dp.count; l++) { let m = this.dp.item(l); let n = NaN; if (m != null) { n = this.jc(m); } if (n == 0) { let o = new SeriesPointOfInterest(); o.f = this.aa7(n, m, l, d, k, c, b, false); o.b = ((() => { let $ret = new DataContext(); $ret.item = m; $ret.series = this; return $ret; })()); o.g = this.vi; o.c = l; if (this.g9) { o.g = this.vp(l); } let p = false; for (let q = 0; q < a.count; q++) { if (o.c < a._inner[q].c) { a.insert(q, o); p = true; break; } } if (!p) { a.add(o); } } } } return true; } return false; } ak(a, b) { let c = new List$1(ChartSelection.$, 0); this.p4(a, c, b); return c.toArray(); } p4(a, b, c) { if (this.y2 == 0) { super.p4(a, b, c); return; } let d = this.cw.b2; let e = this.cw.b1; let f = this.getEffectiveViewport1(this.cw); let g = this.dc.wd(this.wu, this.getEffectiveViewport(), d); let h = this.y7.k5(e, d, f, g); let i = { $type: Point_$type, x: 0.5, y: 0.5 }; let j = this.y7; let k = Math.max(0, 0.5 * j.n6); let l = k; l = Math.max(l, h.minLength); let m = this.y1.k8(d, e, f); let n = this.y1 != null && this.y1.cl; let o = new CollisionRect(0, this.dc.wa(a)); for (let p = 0; p < this.y1.lk; p++) { let q = typeCast(RadialBaseView.$, this.cw); let r = q.c1.getBucket(p); let s = this.acl(this.y1, d, e, f); if (n) { m = this.z2(p, d, e, f); s = this.ack(p, this.y1, d, e, f); if (isNaN_(s)) { s = 0; } } r[0] = this.y1.getScaledAngle(r[0]) + s; let t = r[0]; let u = Math.min(this.za.b.od(r[2]), h.maxLength); let v = this.adw(d, e, f, t - (m * 0.5), t + (m * 0.5), l, u, i); if (v.collidesWithHeavy(o)) { if (c == 7 || c == 6) { b.add(((() => { let $ret = new ChartSelection(); $ret.series = this; return $ret; })())); return; } if (c == 2 || c == 1) { b.add(((() => { let $ret = new ChartSelection(); $ret.item = this.dp.item(p); return $ret; })())); } else { b.add(((() => { let $ret = new ChartSelection(); $ret.item = this.dp.item(p); $ret.series = this; return $ret; })())); } } } } } RadialPieSeries.$t = /*@__PURE__*/ markType(RadialPieSeries, 'RadialPieSeries', AnchoredRadialSeries.$); RadialPieSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, RadialPieSeries, 'raisePropertyChanged', ['RadiusX:adx:ad6', [1, 2], 'RadiusY:ady:ad7', [1, 2]]); return RadialPieSeries; })(); /** * @hidden */ export let RadialPieSeriesView = /*@__PURE__*/ (() => { class RadialPieSeriesView extends AnchoredRadialSeriesView { constructor(a) { super(a); this.c9 = null; this.da = null; this.db = null; this.dg = new Path(); this.c9 = a; this.da = ((() => { let $ret = new Pool$1(Path.$); $ret.create = runOn(this, this.dh); $ret.activate = runOn(this, this.dc); $ret.disactivate = runOn(this, this.de); $ret.destroy = runOn(this, this.dd); return $ret; })()); } ax() { super.ax(); this.db = new List$1(Path.$, 0); if (!this.r) { this.c0.xc = Defaults.c; this.c0.jp = Defaults.i; } } dh() { let a = ((() => { let $ret = new Path(); $ret.dataContext = ((() => { let $ret = new DataContext(); $ret.series = this.f; return $ret; })()); return $ret; })()); this.db.add(a); a._visibility = 1; return a; } dc(a) { a._visibility = 0; } de(a) { a._visibility = 1; } dd(a) { this.db.remove(a); } bk(a, b) { super.bk(a, b); let c = a; } af(a) { return this.db._inner[a]; } ae(a) { let b = this.db._inner[a]; this.dg._visibility = b._visibility; this.dg.an = b.an; let c = this.bw(a); this.dg._fill = c; this.dg._stroke = c; this.dg.ad = this.f.ie; return this.dg; } bc(a, b) { super.bc(a, b); if (a.d) { for (let c = 0; c < this.db.count; c++) { let d = this.ad(c, b); a.t(d); } } } df() { this.av(); } aq(a) { super.aq(a); let b = 0; for (let c of fromEnum(this.da.a)) { this.f.bc.exportPathData(a, c, "slice" + b, ["Main", "Fill"]); b++; } } } RadialPieSeriesView.$t = /*@__PURE__*/ markType(RadialPieSeriesView, 'RadialPieSeriesView', AnchoredRadialSeriesView.$); return RadialPieSeriesView; })();