igniteui-react-core
Version:
Ignite UI React Core.
219 lines (218 loc) • 7.75 kB
JavaScript
/*
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 SimplePieSeriesRule = /*@__PURE__*/ (() => {
class SimplePieSeriesRule 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 = SimplePieSeriesRule.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) {
return c;
}
let d = b.getAllStringProperties();
let e = b.getAllDateTimeProperties();
let f = b.getAllDistinctMonotonicNumericProperties(this.distinctCheckThreshold);
let g = new HashSet$1(String_$type, 0);
for (let h = 0; h < d.length; h++) {
let i = d[h];
g.add_1(i);
}
for (let j = 0; j < e.length; j++) {
let k = e[j];
g.add_1(k);
}
for (let l = 0; l < f.length; l++) {
let m = f[l];
g.add_1(m);
}
d = b.getAllExcludedStringProperties();
e = b.getAllExcludedDateTimeProperties();
f = b.getAllExcludedDistinctMonotonicNumericProperties(this.distinctCheckThreshold);
for (let n = 0; n < d.length; n++) {
let o = d[n];
g.add_1(o);
}
for (let p = 0; p < e.length; p++) {
let q = e[p];
g.add_1(q);
}
for (let r = 0; r < f.length; r++) {
let s = f[r];
g.add_1(s);
}
let t = new Array(g.count);
let u = 0;
for (let v of fromEnum(g)) {
t[u] = v;
u++;
}
return t;
}
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.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
};
}
static e(a, b) {
let c = 1;
return ((() => { let d = SimplePieSeriesRule.f(a.analyzer, b, c); c = d.p2; return d.ret; })());
}
evaluate(a) {
let b = 1;
let c = SimplePieSeriesRule.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 *= 1.1;
}
}
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);
j.suggestedSeries = 34;
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);
}
}
a(a, b) {
return b.analyzer.numericColumnHasDiverseValues(a);
}
g(a, b) {
}
}
SimplePieSeriesRule.$t = /*@__PURE__*/ markType(SimplePieSeriesRule, 'SimplePieSeriesRule', Base.$, [IDataSeriesAdapterRule_$type]);
return SimplePieSeriesRule;
})();