UNPKG

igniteui-react-charts

Version:

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

859 lines (858 loc) 30.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 { CategorySeries } from "./CategorySeries"; import { IIsCategoryBased_$type } from "./IIsCategoryBased"; import { IHasSingleValueCategory_$type } from "./IHasSingleValueCategory"; import { IHasCategoryTrendline_$type } from "./IHasCategoryTrendline"; import { ITrendLineSeries_$type } from "./ITrendLineSeries"; import { IAnchoredCategorySeriesInteractionManager_$type } from "./IAnchoredCategorySeriesInteractionManager"; import { DVContainer } from "igniteui-react-core"; import { Point_$type, enumGetBox, typeCast, runOn, delegateCombine, markType, markDep } from "igniteui-react-core"; import { DependencyProperty } from "igniteui-react-core"; import { Series } from "./Series"; import { TrendLineType_$type } from "igniteui-react-core"; import { Brush } from "igniteui-react-core"; import { PenLineCap_$type } from "igniteui-react-core"; import { DoubleCollection } from "igniteui-react-core"; import { CategoryFrame } from "./CategoryFrame"; import { ICategoryScaler_$type } from "./ICategoryScaler"; import { IScaler_$type } from "./IScaler"; import { CategorySeriesView } from "./CategorySeriesView"; import { CategorySeriesMarkerCollisionAvoidance_$type } from "./CategorySeriesMarkerCollisionAvoidance"; import { ConsolidatedItemHitTestBehavior_$type } from "./ConsolidatedItemHitTestBehavior"; import { CategoryFramePreparer } from "./CategoryFramePreparer"; import { DataLegendSeriesValueInfo } from "igniteui-react-core"; import { DataLegendSeriesContext } from "igniteui-react-core"; import { List$1 } from "igniteui-react-core"; import { Rect } from "igniteui-react-core"; import { ISortingAxis_$type } from "./ISortingAxis"; import { IFastItemsSource_$type } from "igniteui-react-core"; import { NumericAxisBase } from "./NumericAxisBase"; import { CategoryBucketCalculator } from "./CategoryBucketCalculator"; import { AxisRange } from "./AxisRange"; import { NumericYAxis } from "./NumericYAxis"; import { ScalerParams } from "./ScalerParams"; import { SeriesLayerPropertyOverlay } from "./SeriesLayerPropertyOverlay"; import { CategoryMarkerManager } from "./CategoryMarkerManager"; import { CollisionAvoider } from "./CollisionAvoider"; import { NonCollisionAvoider } from "./NonCollisionAvoider"; import { CategoryAxisBase } from "./CategoryAxisBase"; import { ChartSelection } from "./ChartSelection"; import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory"; import { PropertyMetadata } from "igniteui-react-core"; import { truncate, isNaN_, isInfinity } from "igniteui-react-core"; /** * @hidden */ export let AnchoredCategorySeries = /*@__PURE__*/ (() => { class AnchoredCategorySeries extends CategorySeries { get aa1() { if (this.aa0 == null) { this.aa0 = DVContainer.instance.createInstance(IAnchoredCategorySeriesInteractionManager_$type, () => this.ds.n); } return this.aa0; } getHostReferenceValue() { return this.iy(); } me() { return AnchoredCategorySeries.$$p[5]; } ct() { let a = new AnchoredCategorySeriesView(this); return a; } q1(a) { super.q1(a); this.aaw = a; } constructor() { super(); this.aa0 = null; this.aa7 = false; this.aa2 = null; this.aax = null; this.abe = null; this.abd = null; this.aa4 = true; this.aa8 = 0; this.aa9 = 0; this.y1 = new CategoryFramePreparer(1, this, this.y5, this, this, this.y5.c0); } kq(a, b) { let c = this.nd(b); if (c == AnchoredCategorySeries.$$p[5]) { return this.kr(a, b, this.abo); } if (c == AnchoredCategorySeries.$$p[1]) { return this.kr(a, b, this.abg); } return super.kq(a, b); } md(a) { let b = this.nd(a); if (b == AnchoredCategorySeries.$$p[5]) { return this.abo; } if (b == AnchoredCategorySeries.$$p[1]) { return this.abg; } return super.md(a); } get valueColumn() { return this.aa2; } set valueColumn(a) { if (this.aa2 != a) { let b = this.aa2; this.aa2 = a; if (!this.aa7) { this.raisePropertyChanged("ValueColumn", b, this.aa2); } } } getDataLegendSeriesContextAt(a, b) { let c = new DataLegendSeriesValueInfo(); c.a = 0; c.l = this.i5({ $type: Point_$type, x: a, y: b }, false, false); c.r = this.abo != null ? this.abo : "Value"; c.q = "Value"; c.s = this.abk != null ? this.abk : "V:"; c.t = this.abm != null ? this.abm : ""; let d = new DataLegendSeriesContext(); d.e = ((() => { let $ret = new List$1(DataLegendSeriesValueInfo.$, 0); $ret.add(c); return $ret; })()); d.h = this.mc(); return d; } get acb() { return this.c(AnchoredCategorySeries.abx); } set acb(a) { this.h(AnchoredCategorySeries.abx, a); } gd(a) { let b = new Rect(0, 0, 0, 1, 1); let c = this.fetchXAxis(); let d = this.fetchYAxis(); let e = this.wn(this.cw); let f = c != null ? this.y1.r(typeCast(ICategoryScaler_$type, c), b, b, e) : 0; return this.aa1.c$a(this, this.valueColumn, c, d, f, a); } aat(a, b, c) { if (b < a || a < 0 || a > this.valueColumn.count || b < 0 || b > this.valueColumn.count || c == null) { return null; } let d = new Array((b - a) + 1); let e = c.cn; let f = null; if (e) { f = c.i$b; } for (let g = a; g <= b; g++) { let h = g; if (e) { h = f._inner[h]; } d[g - a] = this.dp.item(g); } return d; } ra(a, b, c, d) { super.ra(a, b, c, d); if (this.aaw.dc && this.aaw.db.g$e(a, b, c, d)) { let e = false; if (b == "FastItemsSource") { e = this.gg && c != null; } this.rs(e); this.ql(); } switch (b) { case AnchoredCategorySeries.$$p[3]: case AnchoredCategorySeries.$$p[4]: this.qf(); break; case "FastItemsSource": if (typeCast(IFastItemsSource_$type, c) != null) { c.deregisterColumn(this.valueColumn); this.valueColumn = null; } if (typeCast(IFastItemsSource_$type, d) != null) { this.valueColumn = this.dl(this.abo); } let f = typeCast(NumericAxisBase.$, this.fetchYAxis()); if (f != null && !f.c1()) { this.aaw.c0.g(this.id); this.rs(this.gg && c != null); } break; case AnchoredCategorySeries.$$p[5]: if (this.dp != null) { this.dp.deregisterColumn(this.valueColumn); this.valueColumn = this.dl(this.abo); } this.abe = this.abo; break; case AnchoredCategorySeries.$$p[1]: this.abd = this.abg; this.rs(true); break; case "ValueColumn": if (this.aaw.dc) { this.aaw.db.g$m(); } for (let g = 0; g < this.aaw.w.count; g++) { let h = this.aaw.w._inner[g]; h.g$m(); } let i = typeCast(NumericAxisBase.$, this.fetchYAxis()); if (i != null && !i.c1()) { this.aaw.c0.g(this.id); this.rs(this.gg && this.d8); } this.abw(); this.sp(); break; case "TrendLineBrush": this.rg(b); break; case "ErrorBarSettings": this.rs(false); break; case "TrendLineType": this.ql(); if (this.aaw.dc) { this.aaw.db.g$b = this.trendLineType; } break; case "TrendLinePeriod": if (this.aaw.dc) { this.aaw.db.g$f = this.trendLinePeriod; } break; case AnchoredCategorySeries.$$p[2]: this.rs(false); break; } } ay(a) { if (this.valueColumn == null || this.valueColumn.count == 0) { return null; } if (a == this.fetchXAxis()) { return new AxisRange(0, this.valueColumn.count - 1); } if (a == this.fetchYAxis()) { return new AxisRange(this.valueColumn.minimum, this.valueColumn.maximum); } return null; } pb(a, b, c, d) { switch (a) { case 4: case 1: case 0: this.aaw.c0.g(this.id); break; } if (this.aaw.dc) { this.aaw.db.g$i(a, b, c, d); } for (let e = 0; e < this.aaw.w.count; e++) { let f = this.aaw.w._inner[e]; f.g$i(a, b, c, d); } this.abw(); this.sp(); if (a == 0 || a == 2 || a == 3 || a == 4) { this.aa4 = true; } else if (a == 1) { for (let g = b; g < b + c; g++) { this.aa8 += this.valueColumn.item(g); } this.aa9 = this.aa8 / this.valueColumn.count; } } zw() { return this.aba(this.y5); } aba(a) { let b = 0; let c = a.b2; let d = a.b1; let e = this.getEffectiveViewport1(a); let f = typeCast(NumericYAxis.$, this.fetchYAxis()); if (!c.isEmpty && !d.isEmpty && f != null) { let g = new ScalerParams(0, c, d, f.ch, e); if (f.cp) { g.b = this.iy(); } b = f.el(f.me, g); } return b; } abu(a, b, c) { let d = this.aba(c); if (a.count > 0) { let e = d; a.add({ $type: Point_$type, x: a._inner[a.count - 1].x, y: e }); a.add({ $type: Point_$type, x: a._inner[0].x, y: e }); } } aau(a, b, c, d) { return this.aav(a, b, c, d, false); } aav(a, b, c, d, e) { return CategorySeries.yp(a, b, c, d, e); } gb() { return this.highlightedItemsSource != null || this.abg != null; } ht() { let a = super.ht(); { let b = ((() => { let $ret = new SeriesLayerPropertyOverlay(); $ret.ad = "ValueMemberPath"; $ret.p = true; $ret.y = "HighlightedValueMemberPath"; $ret.q = true; return $ret; })()); b.valueResolving = delegateCombine(b.valueResolving, runOn(this, this.abq)); a.add(b); } return a; } abq(a, b) { if (this.abg != null) { b.value = this.abg; return; } b.value = this.abo; } he(a, b, c) { let d = super.he(a, b, c); let e = c; if (this.valueColumn == null || this.valueColumn.count == 0 || e.c0.d < 1) { d = false; } return d; } o5(a, b) { super.o5(a, b); let c = b; c.c6(); if (c.dc) { c.db.g$h(); } for (let d = 0; d < b.w.count; d++) { let e = c.w._inner[d]; e.g$h(); } } aaj(a, b) { super.aaj(a, b); let c = this.y2(b); c.d(a, b); a.f.clear(); if (b.w.count > 0) { let d = c.i(a); if (d == null || c.g == null) { return; } let e = c.j(d); let f = c.s(d); for (let g = 0; g < b.w.count; g++) { a.f.add(new List$1(Point_$type, 0)); let h = b.w._inner[g]; h.prepareLine1(this, a.f._inner[g], d, e, f); } } } aam(a, b) { super.aam(a, b); let c = typeCast(AnchoredCategorySeriesView.$, b); c.cb = true; if (c.dc) { c.db.g$k(a.s); } for (let d = 0; d < b.w.count; d++) { let e = b.w._inner[d]; e.g$k(a.f._inner[d]); } if (this.xi()) { CategoryMarkerManager.e(this, a.p, b.c3, this.xk); this.aab(b, a); b.cv(); } this.abr(a, b); } rr(a, b, c, d, e) { super.rr(a, b, c, d, e); let f = this.ba.a$j.item(d); let g = f; g.c0.g(this.id); f.a6(c); if (this.d6(g)) { return; } if (this.aax == null) { this.aax = new CategoryFrame(3); } this.aax.x(); this.aaj(this.aax, g); this.aam(this.aax, g); } abr(a, b) { } sj() { super.sj(); if (this.index < 0) { return; } this.aaw.dg(); if (this.trendLineBrush != null) { this.aaw.de(); } else { this.aaw.dd(); } } kx(a, b) { if (this.aaw.dc && a == this.aaw.db.g$n) { return null; } return super.kx(a, b); } get currentCategoryMode() { return this.preferredCategoryMode(typeCast(CategoryAxisBase.$, this.yu())); } get scaler() { return typeCast(ICategoryScaler_$type, this.yu()); } get yScaler() { return typeCast(IScaler_$type, this.zb()); } get bucketizer() { return this.aaw.c0; } get currentMode2Index() { return this.z0(); } provideCollisionDetector() { if (this.aay == 1) { return new CollisionAvoider(); } return NonCollisionAvoider.b; } get trendlinePreparer() { return this.aaw.dc ? this.aaw.db : null; } pz(a) { super.pz(a); if (this.aaw.dc) { this.bc.exportTrendlineData(this, a, this.aaw.db.g$n); } } kn(a) { let b = this.fetchXAxis(); let c = this.fetchYAxis(); return this.aa1.c$b(this, a, this.zx(this.cw), this.valueColumn, b, c, this.aaz == 1, (d) => super.kn(d)); } get mayContainUnknowns() { return this.valueColumn == null || this.valueColumn.mayContainUnknowns; } iy() { return Series.iz(this.valueColumn, typeCast(ISortingAxis_$type, this.fetchXAxis())); } get_abc() { return 0; } get abc() { return this.get_abc(); } az(a) { if (a.isEmpty && this.dc != null) { a = this.dc.v5; } if (this.valueColumn == null) { return null; } let b = this.wl(this.cw); let c = this.yu(); let d = new ScalerParams(0, a, this.dc.wn, c.ch, this.getEffectiveViewport()); let e = (c.eo(b.left, d)); let f = (c.eo(b.right, d)); if (c.ch) { let g = e; e = f; f = g; } e -= this.abc; f += this.abc; let h = null; if (c.cn) { h = c; e = h.i$f(e); f = h.i$f(f); } else { e = Math.floor(e); f = Math.ceil(f); } if (isNaN_(e) || isNaN_(f)) { return null; } e = Math.max(0, Math.min(this.valueColumn.count - 1, e)); f = Math.max(0, Math.min(this.valueColumn.count - 1, f)); let i = 1.7976931348623157E+308; let j = -1.7976931348623157E+308; if (truncate(e) <= truncate(f)) { for (let k = truncate(e); k <= truncate(f); k++) { let l = k; if (h != null) { l = h.i$b._inner[k]; } let m = this.valueColumn.item(l); if (this.valueColumn.mayContainUnknowns) { if (isInfinity(m) || isNaN_(m)) { continue; } } i = Math.min(i, m); j = Math.max(j, m); } } let n = new AxisRange(i, j); n = this.ax(n, this.zb(), a); return n; } abw() { this.im = this.valueColumn == null || this.valueColumn.count == 0 ? NaN : this.valueColumn.item(this.valueColumn.count - 1); } abv() { if (this.aa4) { this.aa8 = 0; for (let a = 0; a < this.valueColumn.count; a++) { this.aa8 += this.valueColumn.item(a); } this.aa9 = this.aa8 / this.valueColumn.count; this.aa4 = false; } } i8(a, b) { if (b == null || !b.cj) { return NaN; } let c = this.zb(); if (b != c) { return NaN; } let d = this.aq(a); if (c.cp) { return d[1]; } else { return d[0]; } } aq(a) { let b = NaN; switch (a) { case 5: case 2: b = this.valueColumn.maximum; break; case 4: case 1: b = this.valueColumn.minimum; break; case 6: case 3: if (this.aa4) { this.abv(); } b = this.aa9; break; } let c = this.zb(); if (c.cp) { return [NaN, b]; } else { return [b, NaN]; } } wh(a) { let b = NaN; switch (a) { case 5: case 2: b = this.valueColumn.maximum; break; case 4: case 1: b = this.valueColumn.minimum; break; case 6: case 3: if (this.aa4) { this.abv(); } b = this.aa9; break; } if (isNaN_(b)) { return { $type: Point_$type, x: NaN, y: NaN }; } let c = this.zb(); let d = this.getEffectiveViewport1(this.cw); let e = new ScalerParams(0, this.cw.b2, this.cw.b1, c.ch, d); if (c.cp) { e.b = this.iy(); } e.c = d; if (c.cp) { return { $type: Point_$type, x: NaN, y: c.el(b, e) }; } else { return { $type: Point_$type, x: c.el(b, e), y: NaN }; } } wi(a) { let b = this.zb(); let c = this.getEffectiveViewport1(this.cw); let d = new ScalerParams(0, this.cw.b2, this.cw.b1, b.ch, c); if (b.cp) { d.b = this.iy(); } d.c = c; if (b.cp) { return { $type: Point_$type, x: NaN, y: b.el(a[1], d) }; } else { return { $type: Point_$type, x: b.el(a[0], d), y: NaN }; } } aaf(a, b, c, d, e, f, g) { if (c < 0 || d < 0) { return; } for (let h = c; h <= d; h++) { if (a == 1) { if (this.aa5(e, f, h)) { if (g == 7 || g == 6) { b.add(((() => { let $ret = new ChartSelection(); $ret.series = this; return $ret; })())); return; } this.z9(b, h, g); } } else { if (this.aa6(e, f, h)) { if (g == 7 || g == 6) { b.add(((() => { let $ret = new ChartSelection(); $ret.series = this; return $ret; })())); return; } this.z9(b, h, g); } } } } aa6(a, b, c) { return this.valueColumn.item(c) < b && a < this.valueColumn.item(c); } aa5(a, b, c) { return 0 < b && a < this.valueColumn.item(c); } z9(a, b, c) { if (c == 2 || c == 1) { a.add(((() => { let $ret = new ChartSelection(); $ret.item = this.dp.item(b); return $ret; })())); } else { a.add(((() => { let $ret = new ChartSelection(); $ret.item = this.dp.item(b); $ret.series = this; return $ret; })())); } } bd() { return CategoryTrendLineManagerFactory.a(null, this.a0(), null, this, this.ds); } get useHighMarkerFidelity() { return this.zs; } } AnchoredCategorySeries.$t = /*@__PURE__*/ markType(AnchoredCategorySeries, 'AnchoredCategorySeries', CategorySeries.$, [IIsCategoryBased_$type, IHasSingleValueCategory_$type, IHasCategoryTrendline_$type, ITrendLineSeries_$type]); AnchoredCategorySeries.abx = /*@__PURE__*/ DependencyProperty.i("ActualTrendLineBrush", Brush.$, AnchoredCategorySeries.$, /*@__PURE__*/ new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue))); AnchoredCategorySeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, AnchoredCategorySeries, 'raisePropertyChanged', ['ConsolidatedItemHitTestBehavior:aaz:aby', [ConsolidatedItemHitTestBehavior_$type, /*@__PURE__*/ enumGetBox(ConsolidatedItemHitTestBehavior_$type, 0)], 'HighlightedValueMemberPath:abg:abz', [2, null], 'MarkerCollisionAvoidance:aay:ab0', [CategorySeriesMarkerCollisionAvoidance_$type, /*@__PURE__*/ enumGetBox(CategorySeriesMarkerCollisionAvoidance_$type, 1)], 'ValueMemberAsLegendLabel:abk:ab8', [2, null], 'ValueMemberAsLegendUnit:abm:ab9', [2, null], 'ValueMemberPath:abo:aca', [2, null], 'TrendLineType::ab6', [TrendLineType_$type, /*@__PURE__*/ enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ab5', [1, 1.5], 'TrendLinePeriod::ab4', [1, 7], 'TrendLineBrush::ab1', [Brush.$, null], 'TrendLineZIndex:abb:ab7', [1, 1001], 'TrendLineDashArray:acc:ab2', [DoubleCollection.$], 'TrendLineDashCap:acd:ab3', [PenLineCap_$type, /*@__PURE__*/ enumGetBox(PenLineCap_$type, 0)]]); return AnchoredCategorySeries; })(); /** * @hidden */ export let AnchoredCategoryBucketCalculator = /*@__PURE__*/ (() => { class AnchoredCategoryBucketCalculator extends CategoryBucketCalculator { constructor(a) { super(a); this.i = null; this.h = null; this.j = 0; this.i = a; } getBucketWithoutUnknowns(a) { let b = this.h; let c = this.j; let d = a * this.d; let e = d + this.d - 1; let f = c - 1; d = d < f ? d : f; e = e < f ? e : f; let g = 1.7976931348623157E+308; let h = -1.7976931348623157E+308; let i = true; for (let j = d; j <= e; ++j) { let k = b[j]; g = g < k ? g : k; h = h > k ? h : k; i = false; } if (!i) { return [0.5 * (d + e), g, h]; } return [0.5 * (d + e), NaN, NaN]; } getBucket(a) { let b = this.h; let c = this.j; let d = a * this.d; let e = d + this.d - 1; let f = c - 1; d = d < f ? d : f; e = e < f ? e : f; let g = 0; let h = 0; let i = true; for (let j = d; j <= e; ++j) { let k = b[j]; if (!i) { if (!isNaN_(k)) { g = g < k ? g : k; h = h > k ? h : k; } } else { if (!isNaN_(k)) { g = k; h = k; i = false; } } } if (!i) { return [0.5 * (d + e), g, h]; } return [0.5 * (d + e), NaN, NaN]; } cacheValues() { this.j = this.i.c9.valueColumn.count; this.h = this.i.c9.valueColumn.asArray(); } unCacheValues() { this.h = null; } } AnchoredCategoryBucketCalculator.$t = /*@__PURE__*/ markType(AnchoredCategoryBucketCalculator, 'AnchoredCategoryBucketCalculator', CategoryBucketCalculator.$); return AnchoredCategoryBucketCalculator; })(); /** * @hidden */ export let AnchoredCategorySeriesView = /*@__PURE__*/ (() => { class AnchoredCategorySeriesView extends CategorySeriesView { constructor(a) { super(a); this.c9 = null; this.da = null; this.c9 = a; } get db() { if (this.da == null) { this.da = CategoryTrendLineManagerFactory.a(this.da, this.f.a0(), this.f.sx, this.f, this.f.ds); this.da.g$b = this.c9.trendLineType; this.da.g$f = this.c9.trendLinePeriod; } return this.da; } set db(a) { this.da = a; } get dc() { return this.da != null; } dg() { this.c9.acb = null; } de() { this.c9.acb = this.c9.trendLineBrush; } dd() { this.c9.acb = this.c9.vb; } c1() { return new AnchoredCategoryBucketCalculator(this); } df() { this.c0.cacheValues(); } dh() { this.c0.unCacheValues(); } di(a) { let b = this.c3.item(a); return this.cy(b); } bb(a, b) { if (a.d) { if (this.c9.trendLineType != 0 && !b) { let c = this.db.g$n; c.ad = this.c9.trendLineThickness; c._stroke = this.c9.acb; c.ai = this.c9.acc; c.aj = this.c9.acd; a.v(c); } } super.bb(a, b); } getDefaultTooltipTemplate() { return this.c9.aa1.c$c(this.f, this.c9.abo); } } AnchoredCategorySeriesView.$t = /*@__PURE__*/ markType(AnchoredCategorySeriesView, 'AnchoredCategorySeriesView', CategorySeriesView.$); return AnchoredCategorySeriesView; })();