UNPKG

igniteui-react-core

Version:
292 lines (291 loc) 11.5 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 { __extends, __read, __spreadArray, __values } from "tslib"; 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 */ var SimpleFinancialPriceSeriesRule = /** @class */ /*@__PURE__*/ (function (_super) { __extends(SimpleFinancialPriceSeriesRule, _super); function SimpleFinancialPriceSeriesRule() { var _this = _super.call(this) || this; _this._priority = 0; _this._distinctCheckThreshold = 0; _this.priority = 10; _this.distinctCheckThreshold = 50000; return _this; } Object.defineProperty(SimpleFinancialPriceSeriesRule.prototype, "priority", { get: function () { return this._priority; }, set: function (a) { this._priority = a; }, enumerable: false, configurable: true }); Object.defineProperty(SimpleFinancialPriceSeriesRule.prototype, "distinctCheckThreshold", { get: function () { return this._distinctCheckThreshold; }, set: function (a) { this._distinctCheckThreshold = a; }, enumerable: false, configurable: true }); SimpleFinancialPriceSeriesRule.prototype.f = function (a, b) { var e_1, _a; try { for (var _b = __values(fromEnum(b)), _c = _b.next(); !_c.done; _c = _b.next()) { var c = _c.value; if (a.contains(c)) { a.remove(c); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } }; SimpleFinancialPriceSeriesRule.e = function (a, b) { var c = a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (17))); if (c.length > 0) { return c[0]; } return ((function (d) { return d != null ? d : a.analyzer.getFirstDateTimeProperty(); })(a.analyzer.getFirstDistinctDateTimeProperty(b))); }; SimpleFinancialPriceSeriesRule.prototype.getPrimaryAxisLabelsString = function (a) { return SimpleFinancialPriceSeriesRule.d(a, this.distinctCheckThreshold); }; SimpleFinancialPriceSeriesRule.d = function (a, b) { var c = a.analyzer; var d = c.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (17))); if (d.length > 0) { a.am(a.getCurrentPath(), d[0], 0); return d[0]; } d = c.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (16))); if (d.length > 0) { a.am(a.getCurrentPath(), d[0], 0); return d[0]; } var e = c.getFirstDistinctDateTimeProperty(b); if (e != null) { a.am(a.getCurrentPath(), e, 1); return e; } e = c.getFirstDistinctStringProperty(b); if (e != null) { a.am(a.getCurrentPath(), e, 0); return e; } e = c.getFirstDistinctMonotonicNumericProperty(b); if (e != null) { a.am(a.getCurrentPath(), e, 2); return e; } e = c.getFirstStringProperty(); if (e != null) { a.am(a.getCurrentPath(), e, 0); } return e; }; SimpleFinancialPriceSeriesRule.b = function (a, b) { return SimpleFinancialPriceSeriesRule.d(a, b); }; SimpleFinancialPriceSeriesRule.prototype.evaluate = function (a) { var e_2, _a; var b = 0.5; var c = SimpleFinancialPriceSeriesRule.e(a, this.distinctCheckThreshold); var d = SimpleFinancialPriceSeriesRule.b(a, this.distinctCheckThreshold); var e = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (11)))); var f = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (12)))); var g = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (13)))); var h = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (14)))); var i = new List$1(String_$type, 1, a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (15)))); var j = Math.min(e.count, Math.min(f.count, Math.min(g.count, h.count))); if (j > 0) { b = 1.2; } var k = a.getCurrentDataSource().actualCount; if (a.adjustPrioritiesBasedOnFitness && k == 1) { b *= 0.8; } if (j == 0) { var l = new List$1(String_$type, 1, a.analyzer.getAllNumericProperties()); try { for (var _b = __values(fromEnum(l)), _c = _b.next(); !_c.done; _c = _b.next()) { var m = _c.value; 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; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } this.f(l, e); this.f(l, f); this.f(l, g); this.f(l, h); this.f(l, i); var 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)); var o = [e, f, g, h, i]; var p = 0; while (l.count > 0) { o[p++ % o.length].add(l._inner[0]); l.removeAt(0); } } var q = this.c(a.getCurrentDataSource()); var _loop_1 = function (r) { a.pushParentTitle(j == 1 ? q : q + (r + 1)); var s = e.count > r ? e._inner[r] : null; var t = f.count > r ? f._inner[r] : null; var u = g.count > r ? g._inner[r] : null; var v = h.count > r ? h._inner[r] : null; var w = ((function () { var $ret = new DataSeries(); $ret.name = stringJoin.apply(void 0, __spreadArray(["_"], __read([s, t, u, v]), false)); $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_1.priority * b)); } w.addMemberPathHint(((function () { var $ret = new DataSeriesMemberPathHint(); $ret.intent = 11; $ret.path = s; return $ret; })())); w.addMemberPathHint(((function () { var $ret = new DataSeriesMemberPathHint(); $ret.intent = 12; $ret.path = t; return $ret; })())); w.addMemberPathHint(((function () { var $ret = new DataSeriesMemberPathHint(); $ret.intent = 13; $ret.path = u; return $ret; })())); w.addMemberPathHint(((function () { var $ret = new DataSeriesMemberPathHint(); $ret.intent = 14; $ret.path = v; return $ret; })())); if (i.count > r) { w.addMemberPathHint(((function () { var $ret = new DataSeriesMemberPathHint(); $ret.intent = 15; $ret.path = i._inner[r]; return $ret; })())); } if (c != null) { w.addMemberPathHint(((function () { var $ret = new DataSeriesMemberPathHint(); $ret.intent = 17; $ret.path = c; return $ret; })())); } w.addMemberPathHint(((function () { var $ret = new DataSeriesMemberPathHint(); $ret.intent = 16; $ret.path = d; return $ret; })())); a.addDataSeries(w, this_1); a.popParentTitle(); }; var this_1 = this; for (var r = 0; r < j; r++) { _loop_1(r); } }; SimpleFinancialPriceSeriesRule.prototype.c = function (a) { var b = a == null ? null : a.dataSource; if (b == null) { return null; } var c = (typeof b.title === 'function'); return c ? (b.title()) : (b.title) ? (b.title) : null; }; SimpleFinancialPriceSeriesRule.prototype.getAdditionalValuePropertyStrings = function (a) { return null; }; SimpleFinancialPriceSeriesRule.prototype.getPrimaryAxisLabelsStrings = function (a) { var b = this.getPrimaryAxisLabelsString(a); if (b == null) { return null; } return [b]; }; SimpleFinancialPriceSeriesRule.$t = markType(SimpleFinancialPriceSeriesRule, 'SimpleFinancialPriceSeriesRule', Base.$, [IDataSeriesAdapterRule_$type]); return SimpleFinancialPriceSeriesRule; }(Base)); export { SimpleFinancialPriceSeriesRule };