UNPKG

igniteui-react-core

Version:
222 lines (221 loc) 9.6 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 { Base, fromEnum, EnumUtil, String_$type, markType } from "./type"; import { IDataSeriesAdapterRule_$type } from "./IDataSeriesAdapterRule"; import { List$1 } from "./List$1"; import { DataSeriesIntent_$type } from "./DataSeriesIntent"; import { DataSeries } from "./DataSeries"; import { DataSeriesMemberPathHint } from "./DataSeriesMemberPathHint"; import { truncate } from "./number"; import { stringJoin } from "./string"; /** * @hidden */ export let SimpleFinancialPriceSeriesRule = /*@__PURE__*/ (() => { class SimpleFinancialPriceSeriesRule extends Base { constructor() { super(); this._priority = 0; this._distinctCheckThreshold = 0; this.priority = 10; this.distinctCheckThreshold = 50000; } get priority() { return this._priority; } set priority(a) { this._priority = a; } get distinctCheckThreshold() { return this._distinctCheckThreshold; } set distinctCheckThreshold(a) { this._distinctCheckThreshold = a; } f(a, b) { for (let c of fromEnum(b)) { if (a.contains(c)) { a.remove(c); } } } static e(a, b) { let c = a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (17))); if (c.length > 0) { return c[0]; } return (((d) => d != null ? d : a.analyzer.getFirstDateTimeProperty())(a.analyzer.getFirstDistinctDateTimeProperty(b))); } getPrimaryAxisLabelsString(a) { return SimpleFinancialPriceSeriesRule.d(a.analyzer, this.distinctCheckThreshold); } static d(a, b) { let c = a.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (17))); if (c.length > 0) { return c[0]; } c = a.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (16))); if (c.length > 0) { return c[0]; } return (((d) => d != null ? d : (((e) => e != null ? e : (((f) => f != null ? f : a.getFirstStringProperty())(a.getFirstDistinctMonotonicNumericProperty(b))))(a.getFirstDistinctStringProperty(b))))(a.getFirstDistinctDateTimeProperty(b))); } static b(a, b) { return SimpleFinancialPriceSeriesRule.d(a.analyzer, b); } evaluate(a) { let b = 0.5; let c = SimpleFinancialPriceSeriesRule.e(a, this.distinctCheckThreshold); let d = SimpleFinancialPriceSeriesRule.b(a, this.distinctCheckThreshold); let e = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (11)))); let f = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (12)))); let g = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (13)))); let h = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (14)))); let i = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (15)))); let j = Math.min(e.count, Math.min(f.count, Math.min(g.count, h.count))); if (j > 0) { b = 1.2; } let k = a.getCurrentDataSource().actualCount; if (a.adjustPrioritiesBasedOnFitness && k == 1) { b *= 0.8; } if (j == 0) { let l = new List$1(String_$type, 1, a.analyzer.getAllNumericProperties()); for (let m of fromEnum(l)) { if (Base.equalsStatic(m.toLowerCase(), "open")) { e.add(m); continue; } if (Base.equalsStatic(m.toLowerCase(), "high")) { f.add(m); continue; } if (Base.equalsStatic(m.toLowerCase(), "low")) { g.add(m); continue; } if (Base.equalsStatic(m.toLowerCase(), "close")) { h.add(m); continue; } if (Base.equalsStatic(m.toLowerCase(), "volume")) { i.add(m); continue; } } this.f(l, e); this.f(l, f); this.f(l, g); this.f(l, h); this.f(l, i); let n = e.count + f.count + g.count + h.count + l.count; if ((e.count + f.count + g.count + h.count) >= 4) { b = 1.2; } if (n == 0) { return; } j = n <= 4 ? 1 : truncate(Math.floor(n / 5)); let o = [e, f, g, h, i]; let p = 0; while (l.count > 0) { o[p++ % o.length].add(l._inner[0]); l.removeAt(0); } } let q = this.c(a.getCurrentDataSource()); for (let r = 0; r < j; r++) { a.pushParentTitle(j == 1 ? q : q + (r + 1)); let s = e.count > r ? e._inner[r] : null; let t = f.count > r ? f._inner[r] : null; let u = g.count > r ? g._inner[r] : null; let v = h.count > r ? h._inner[r] : null; let w = ((() => { let $ret = new DataSeries(); $ret.name = stringJoin("_", ...[s, t, u, v]); $ret.title = a.analyzer.getTitleString(null, [s, t, u, v]); $ret.suggestedSeries = 20; $ret.suggestedPrimaryAxis = 0; $ret.suggestedSecondaryAxis = 1; return $ret; })()); if (a.adjustPrioritiesBasedOnFitness) { w.priority = truncate(Math.round(this.priority * b)); } w.addMemberPathHint(((() => { let $ret = new DataSeriesMemberPathHint(); $ret.intent = 11; $ret.path = s; return $ret; })())); w.addMemberPathHint(((() => { let $ret = new DataSeriesMemberPathHint(); $ret.intent = 12; $ret.path = t; return $ret; })())); w.addMemberPathHint(((() => { let $ret = new DataSeriesMemberPathHint(); $ret.intent = 13; $ret.path = u; return $ret; })())); w.addMemberPathHint(((() => { let $ret = new DataSeriesMemberPathHint(); $ret.intent = 14; $ret.path = v; return $ret; })())); if (i.count > r) { w.addMemberPathHint(((() => { let $ret = new DataSeriesMemberPathHint(); $ret.intent = 15; $ret.path = i._inner[r]; return $ret; })())); } if (c != null) { w.addMemberPathHint(((() => { let $ret = new DataSeriesMemberPathHint(); $ret.intent = 17; $ret.path = c; return $ret; })())); } w.addMemberPathHint(((() => { let $ret = new DataSeriesMemberPathHint(); $ret.intent = 16; $ret.path = d; return $ret; })())); a.addDataSeries(w, this); a.popParentTitle(); } } c(a) { let b = a == null ? null : a.dataSource; if (b == null) { return null; } let c = (typeof b.title === 'function'); return c ? (b.title()) : (b.title) ? (b.title) : null; } getAdditionalValuePropertyStrings(a) { return null; } getPrimaryAxisLabelsStrings(a) { let b = this.getPrimaryAxisLabelsString(a); if (b == null) { return null; } return [b]; } } SimpleFinancialPriceSeriesRule.$t = /*@__PURE__*/ markType(SimpleFinancialPriceSeriesRule, 'SimpleFinancialPriceSeriesRule', Base.$, [IDataSeriesAdapterRule_$type]); return SimpleFinancialPriceSeriesRule; })();