UNPKG

igniteui-react-core

Version:
276 lines (275 loc) 9.73 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, 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 */ export let SimpleCategorySeriesRule = /*@__PURE__*/ (() => { class SimpleCategorySeriesRule extends Base { constructor() { super(); this._priority = 0; this._useColumnThreshold = 0; this._distinctCheckThreshold = 0; this.b = 1; this.priority = 10; this.distinctCheckThreshold = 50000; this.useColumnThreshold = 30; } get priority() { return this._priority; } set priority(a) { this._priority = a; } get useColumnThreshold() { return this._useColumnThreshold; } set useColumnThreshold(a) { this._useColumnThreshold = a; } get distinctCheckThreshold() { return this._distinctCheckThreshold; } set distinctCheckThreshold(a) { this._distinctCheckThreshold = a; } getPrimaryAxisLabelsString(a) { let b = 1; let c = ((() => { let d = SimpleCategorySeriesRule.f(a.analyzer, this.distinctCheckThreshold, b); b = d.p2; return d.ret; })()); this.b = b; return c; } getAdditionalValuePropertyStrings(a) { return null; } getPrimaryAxisLabelsStrings(a) { let b = a.analyzer; let c = b.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (16))); if (c.length > 0) { for (let d = 0; d < c.length; d++) { a.am(a.getCurrentPath(), c[d], 0); } return c; } let e = b.getAllStringProperties(); let f = b.getAllDateTimeProperties(); let g = b.getAllDistinctMonotonicNumericProperties(this.distinctCheckThreshold); let h = new HashSet$1(String_$type, 0); let i = a.getCurrentPath(); for (let j = 0; j < e.length; j++) { let k = e[j]; h.add_1(k); a.am(a.getCurrentPath(), k, 0); } for (let l = 0; l < f.length; l++) { let m = f[l]; h.add_1(m); a.am(a.getCurrentPath(), m, 1); } for (let n = 0; n < g.length; n++) { let o = g[n]; h.add_1(o); a.am(a.getCurrentPath(), o, 2); } e = b.getAllExcludedStringProperties(); f = b.getAllExcludedDateTimeProperties(); g = b.getAllExcludedDistinctMonotonicNumericProperties(this.distinctCheckThreshold); for (let p = 0; p < e.length; p++) { let q = e[p]; h.add_1(q); a.am(a.getCurrentPath(), q, 0); } for (let r = 0; r < f.length; r++) { let s = f[r]; h.add_1(s); a.am(a.getCurrentPath(), s, 1); } for (let t = 0; t < g.length; t++) { let u = g[t]; h.add_1(u); a.am(a.getCurrentPath(), u, 2); } let v = new Array(h.count); let w = 0; for (let x of fromEnum(h)) { v[w] = x; w++; } return v; } static f(a, b, c) { let d = a.getAllPropertiesWithIntent(EnumUtil.getName(DataSeriesIntent_$type, (16))); if (d.length > 0) { return { ret: d[0], p2: c }; } let e = a.getFirstDistinctStringProperty(b); c = 1; if (e != null) { c = 1; return { ret: e, p2: c }; } e = a.getFirstDistinctDateTimeProperty(b); if (e != null) { c = 1; return { ret: e, p2: c }; } e = a.getFirstDistinctMonotonicNumericPropertyWithEvenSpacing(b); if (e != null) { c = 1; return { ret: e, p2: c }; } e = a.getFirstDistinctMonotonicNumericProperty(b); if (e != null) { c = 0.9; return { ret: e, p2: c }; } c = 0.7; e = a.getFirstStringProperty(); return { ret: e, p2: c }; } static e(a, b) { let c = 1; return ((() => { let d = SimpleCategorySeriesRule.f(a.analyzer, b, c); c = d.p2; return d.ret; })()); } evaluate(a) { let b = 1; let c = SimpleCategorySeriesRule.e(a, this.distinctCheckThreshold); if (a.adjustPrioritiesBasedOnFitness) { b *= this.b; } let d = null; let 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; } let f = a.getCurrentDataSource().actualCount; if (a.adjustPrioritiesBasedOnFitness && d.length > 0 && d.length < 2 && f > 1 && f < 12) { if (this.a(d[0], a)) { b *= 0.9; } } if (a.adjustPrioritiesBasedOnFitness && f == 1) { b *= 0.8; } for (let g = 0; g < d.length; g++) { if (d[g] == c && d.length > 1) { continue; } let h = new Array(1); h[0] = d[g]; let i = a.analyzer.getTitleString(null, h); let j = new DataSeries(); let k = new DataSeriesMemberPathHint(); k.intent = 0; k.path = d[g]; let l = new DataSeriesMemberPathHint(); l.intent = 16; l.path = c; j.addMemberPathHint(k); j.addMemberPathHint(l); if (f > this.useColumnThreshold) { j.suggestedSeries = 0; } else { j.suggestedSeries = 1; } this.g(j, a); j.suggestedPrimaryAxis = 0; j.suggestedSecondaryAxis = 1; 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); } } a(a, b) { return b.analyzer.numericColumnHasDiverseValues(a); } g(a, b) { if (!b.hasValidType(a)) { a.suggestedSeries = 0; if (b.hasValidType(a)) { return; } a.suggestedSeries = 1; if (b.hasValidType(a)) { return; } a.suggestedSeries = 2; if (b.hasValidType(a)) { return; } a.suggestedSeries = 6; if (b.hasValidType(a)) { return; } a.suggestedSeries = 7; if (b.hasValidType(a)) { return; } a.suggestedSeries = 4; if (b.hasValidType(a)) { return; } a.suggestedSeries = 5; if (b.hasValidType(a)) { return; } a.suggestedSeries = 10; if (b.hasValidType(a)) { return; } a.suggestedSeries = 8; if (b.hasValidType(a)) { return; } a.suggestedSeries = 0; } } } SimpleCategorySeriesRule.$t = /*@__PURE__*/ markType(SimpleCategorySeriesRule, 'SimpleCategorySeriesRule', Base.$, [IDataSeriesAdapterRule_$type]); return SimpleCategorySeriesRule; })();