UNPKG

igniteui-react-core

Version:
260 lines (259 loc) 8.78 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, __values } from "tslib"; import { Base, EnumUtil, String_$type, fromEnum, markType } from "./type"; import { IDataSeriesAdapterRule_$type } from "./IDataSeriesAdapterRule"; import { HashSet$1 } from "./HashSet$1"; import { DataSeriesIntent_$type } from "./DataSeriesIntent"; import { DataSeries } from "./DataSeries"; import { DataSeriesMemberPathHint } from "./DataSeriesMemberPathHint"; import { truncate } from "./number"; /** * @hidden */ var SimplePieSeriesRule = /** @class */ /*@__PURE__*/ (function (_super) { __extends(SimplePieSeriesRule, _super); function SimplePieSeriesRule() { var _this = _super.call(this) || this; _this._priority = 0; _this._useColumnThreshold = 0; _this._distinctCheckThreshold = 0; _this.b = 1; _this.priority = 10; _this.distinctCheckThreshold = 50000; _this.useColumnThreshold = 30; return _this; } Object.defineProperty(SimplePieSeriesRule.prototype, "priority", { get: function () { return this._priority; }, set: function (a) { this._priority = a; }, enumerable: false, configurable: true }); Object.defineProperty(SimplePieSeriesRule.prototype, "useColumnThreshold", { get: function () { return this._useColumnThreshold; }, set: function (a) { this._useColumnThreshold = a; }, enumerable: false, configurable: true }); Object.defineProperty(SimplePieSeriesRule.prototype, "distinctCheckThreshold", { get: function () { return this._distinctCheckThreshold; }, set: function (a) { this._distinctCheckThreshold = a; }, enumerable: false, configurable: true }); SimplePieSeriesRule.prototype.getPrimaryAxisLabelsString = function (a) { var _this = this; var b = 1; var c = ((function () { var d = SimplePieSeriesRule.f(a.analyzer, _this.distinctCheckThreshold, b); b = d.p2; return d.ret; })()); this.b = b; return c; }; SimplePieSeriesRule.prototype.getAdditionalValuePropertyStrings = function (a) { return null; }; SimplePieSeriesRule.prototype.getPrimaryAxisLabelsStrings = function (a) { var e_1, _a; var b = a.analyzer; var c = b.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (16))); if (c.length > 0) { for (var d = 0; d < c.length; d++) { a.am(a.getCurrentPath(), c[d], 0); } return c; } var e = b.getAllStringProperties(); var f = b.getAllDateTimeProperties(); var g = b.getAllDistinctMonotonicNumericProperties(this.distinctCheckThreshold); var h = new HashSet$1(String_$type, 0); for (var i = 0; i < e.length; i++) { var j = e[i]; h.add_1(j); a.am(a.getCurrentPath(), j, 0); } for (var k = 0; k < f.length; k++) { var l = f[k]; h.add_1(l); a.am(a.getCurrentPath(), l, 1); } for (var m = 0; m < g.length; m++) { var n = g[m]; h.add_1(n); a.am(a.getCurrentPath(), n, 2); } e = b.getAllExcludedStringProperties(); f = b.getAllExcludedDateTimeProperties(); g = b.getAllExcludedDistinctMonotonicNumericProperties(this.distinctCheckThreshold); for (var o = 0; o < e.length; o++) { var p = e[o]; h.add_1(p); a.am(a.getCurrentPath(), p, 0); } for (var q = 0; q < f.length; q++) { var r = f[q]; h.add_1(r); a.am(a.getCurrentPath(), r, 1); } for (var s = 0; s < g.length; s++) { var t = g[s]; h.add_1(t); a.am(a.getCurrentPath(), t, 2); } var u = new Array(h.count); var v = 0; try { for (var _b = __values(fromEnum(h)), _c = _b.next(); !_c.done; _c = _b.next()) { var w = _c.value; u[v] = w; v++; } } 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; } } return u; }; SimplePieSeriesRule.f = function (a, b, c) { var d = a.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (16))); if (d.length > 0) { return { ret: d[0], p2: c }; } var e = a.getFirstDistinctStringProperty(b); c = 1; if (e != null) { c = 1; return { ret: e, p2: c }; } e = a.getFirstDistinctMonotonicNumericPropertyWithEvenSpacing(b); if (e != null) { c = 0.8; return { ret: e, p2: c }; } e = a.getFirstDistinctMonotonicNumericProperty(b); if (e != null) { c = 0.7; return { ret: e, p2: c }; } e = a.getFirstDistinctDateTimeProperty(b); if (e != null) { c = 0.6; return { ret: e, p2: c }; } c = 0.6; e = a.getFirstStringProperty(); return { ret: e, p2: c }; }; SimplePieSeriesRule.e = function (a, b) { var c = 1; return ((function () { var d = SimplePieSeriesRule.f(a.analyzer, b, c); c = d.p2; return d.ret; })()); }; SimplePieSeriesRule.prototype.evaluate = function (a) { var b = 1; var c = SimplePieSeriesRule.e(a, this.distinctCheckThreshold); if (a.adjustPrioritiesBasedOnFitness) { b *= this.b; } var d = null; var e = a.analyzer.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (0))); if (e.length > 0) { d = e; } if (d == null) { d = a.analyzer.getAllNumericProperties(); } if (d == null || d.length == 0) { return; } var f = a.getCurrentDataSource().actualCount; if (a.adjustPrioritiesBasedOnFitness && d.length > 0 && d.length < 2 && f > 1 && f < 12) { if (this.a(d[0], a)) { b *= 1.1; } } for (var g = 0; g < d.length; g++) { if (d[g] == c && d.length > 1) { continue; } var h = new Array(1); h[0] = d[g]; var i = a.analyzer.getTitleString(null, h); var j = new DataSeries(); var k = new DataSeriesMemberPathHint(); k.intent = 0; k.path = d[g]; var l = new DataSeriesMemberPathHint(); l.intent = 16; l.path = c; j.addMemberPathHint(k); j.addMemberPathHint(l); j.suggestedSeries = 35; this.g(j, a); j.suggestedPrimaryAxis = 6; j.suggestedSecondaryAxis = 7; j.name = d[g]; if (i != null) { j.title = i; } else { j.title = d[g]; j.title = a.analyzer.expandCamelCasedWords(j.title); } if (a.adjustPrioritiesBasedOnFitness) { j.priority = truncate(Math.round(this.priority * b)); } a.addDataSeries(j, this); } }; SimplePieSeriesRule.prototype.a = function (a, b) { return b.analyzer.numericColumnHasDiverseValues(a); }; SimplePieSeriesRule.prototype.g = function (a, b) { }; SimplePieSeriesRule.$t = markType(SimplePieSeriesRule, 'SimplePieSeriesRule', Base.$, [IDataSeriesAdapterRule_$type]); return SimplePieSeriesRule; }(Base)); export { SimplePieSeriesRule };