igniteui-react-core
Version:
Ignite UI React Core.
578 lines (577 loc) • 22.3 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 { __extends, __values } from "tslib";
import { PriorityDataRule } from "./PriorityDataRule";
import { ShapeDataInfo } from "./ShapeDataInfo";
import { DataSeries } from "./DataSeries";
import { List$1 } from "./List$1";
import { IEnumerable_$type, typeCast, String_$type, fromEnum, typeGetValue, Point_$type, markType } from "./type";
import { ShapeChartUtils } from "./ShapeChartUtils";
import { truncate, isNaN_ } from "./number";
import { stringReplace } from "./string";
/**
* @hidden
*/
var ScatterDataRule = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ScatterDataRule, _super);
function ScatterDataRule() {
var _this = _super.call(this) || this;
_this._supportGeographicSeries = false;
_this._geographicShapeCheckThreshold = 0;
_this._geographicPointCheckThreshold = 0;
_this._monotonicCheckAmount = 0;
_this._smallDataSourceThreshold = 0;
_this._hugeDataSourceThreshold = 0;
_this.priority = 10;
_this.monotonicCheckAmount = 1000;
_this.geographicShapeCheckThreshold = 20;
_this.geographicPointCheckThreshold = 100;
_this.smallDataSourceThreshold = 1000;
_this.hugeDataSourceThreshold = 10000;
_this.supportGeographicSeries = false;
return _this;
}
Object.defineProperty(ScatterDataRule.prototype, "supportGeographicSeries", {
get: function () {
return this._supportGeographicSeries;
},
set: function (a) {
this._supportGeographicSeries = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ScatterDataRule.prototype, "geographicShapeCheckThreshold", {
get: function () {
return this._geographicShapeCheckThreshold;
},
set: function (a) {
this._geographicShapeCheckThreshold = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ScatterDataRule.prototype, "geographicPointCheckThreshold", {
get: function () {
return this._geographicPointCheckThreshold;
},
set: function (a) {
this._geographicPointCheckThreshold = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ScatterDataRule.prototype, "monotonicCheckAmount", {
get: function () {
return this._monotonicCheckAmount;
},
set: function (a) {
this._monotonicCheckAmount = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ScatterDataRule.prototype, "smallDataSourceThreshold", {
get: function () {
return this._smallDataSourceThreshold;
},
set: function (a) {
this._smallDataSourceThreshold = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ScatterDataRule.prototype, "hugeDataSourceThreshold", {
get: function () {
return this._hugeDataSourceThreshold;
},
set: function (a) {
this._hugeDataSourceThreshold = a;
},
enumerable: false,
configurable: true
});
ScatterDataRule.prototype.evaluate = function (a) {
var b = this.b(a);
if (b != null && b.k != 0) {
this.n(a, b);
}
};
ScatterDataRule.prototype.m = function (a, b) {
var c = new Array(1);
c[0] = b;
var d = a.analyzer.getTitleString(null, c);
if (d == null) {
d = b;
}
return d;
};
ScatterDataRule.prototype.l = function (a, b, c) {
var d = new Array(2);
d[0] = b;
d[1] = c;
var e = a.analyzer.getTitleStringWithSeparator(null, d, " vs ");
if (e != null) {
return e;
}
var f = this.m(a, b);
var g = this.m(a, c);
return f + " vs " + g;
};
ScatterDataRule.prototype.n = function (a, b) {
var c = new DataSeries();
if (b.u) {
c.priority = truncate(Math.round(b.q * b.o));
}
if (b.i.hasPath()) {
c.addMemberPathHint(b.i);
}
if (b.j.hasPath()) {
c.addMemberPathHint(b.j);
}
if (b.h.hasPath()) {
c.addMemberPathHint(b.h);
}
if (b.f.hasPath()) {
c.addMemberPathHint(b.f);
}
if (b.c.hasPath()) {
c.addMemberPathHint(b.c);
}
if (b.e.hasPath()) {
c.addMemberPathHint(b.e);
}
if (b.k == 0) {
c.suggestedSeries = 24;
}
else {
if (b.x <= this.smallDataSourceThreshold) {
if (b.f.hasPath()) {
c.suggestedSeries = 17;
if (b.v) {
c.suggestedSeries = 44;
}
c.title = this.m(a, b.f.path);
}
else if (b.c.hasPath()) {
c.suggestedSeries = 14;
if (b.v) {
c.suggestedSeries = 41;
}
c.title = this.m(a, b.c.path);
}
else if (b.h.hasPath()) {
c.suggestedSeries = 15;
if (b.v) {
c.suggestedSeries = 42;
}
c.title = this.m(a, b.h.path);
}
else {
if (b.p <= this.monotonicCheckAmount) {
if (b.b.isMonotonic(b.l, b.i.path, this.monotonicCheckAmount) || b.b.isMonotonic(b.l, b.j.path, this.monotonicCheckAmount)) {
c.suggestedSeries = 12;
}
else {
c.suggestedSeries = 11;
if (b.v) {
c.suggestedSeries = 39;
}
}
}
else {
c.suggestedSeries = 11;
if (b.v) {
c.suggestedSeries = 39;
}
}
c.title = this.l(a, b.i.path, b.j.path);
}
}
else if (b.x <= this.hugeDataSourceThreshold) {
if (b.c.hasPath()) {
c.suggestedSeries = 14;
if (b.v) {
c.suggestedSeries = 41;
}
c.title = this.m(a, b.c.path);
}
else if (b.h.hasPath()) {
c.suggestedSeries = 15;
if (b.v) {
c.suggestedSeries = 42;
}
c.title = this.m(a, b.h.path);
}
else {
c.suggestedSeries = 16;
if (b.v) {
c.suggestedSeries = 43;
}
c.title = this.l(a, b.i.path, b.j.path);
}
}
else {
c.suggestedSeries = 16;
if (b.v) {
c.suggestedSeries = 43;
}
c.title = this.l(a, b.i.path, b.j.path);
}
}
c.suggestedPrimaryAxis = 1;
c.suggestedSecondaryAxis = 1;
c.title = a.analyzer.expandCamelCasedWords(c.title);
a.addDataSeries(c, this);
};
ScatterDataRule.prototype.getAdditionalValuePropertyStrings = function (a) {
var e_1, _a;
var b = new ShapeDataInfo(a);
var c = this.a(a.analyzer.getAllStringProperties());
var d = this.a(a.analyzer.getAllNumericProperties());
for (var e = 0; e < b.p; e++) {
var f = b.l.getItemAtIndex(e);
if (e == 0) {
var g = b.b.getAllPropertiesWithName("Fields");
if (g.length == 0) {
g = b.b.getAllPropertiesWithName("fields");
}
if (g.length > 0) {
var h = typeCast(IEnumerable_$type, b.l.getItemValue(f, g[0]));
if (h != null) {
var i = f.fieldsNames;
var j = f.fieldsTypes;
if (j != null && i != null) {
b.o = 1.2;
d = new List$1(String_$type, 0);
c = new List$1(String_$type, 0);
for (var k = 0; k < j.count; k++) {
if (j._inner[k] == "string") {
c.add(g[0] + "[" + i._inner[k] + "]");
}
else {
d.add(g[0] + "[" + i._inner[k] + "]");
}
}
}
}
}
}
if (!b.g.hasPath()) {
break;
}
else {
var l = false;
var m = b.l.getItemValue(f, b.g.path);
if (m != null && a.analyzer.isCollection(m)) {
var n = a.getSubProvider(m, b.g.path);
if (n.actualCount == 0) {
continue;
}
for (var o = 0; o < n.actualCount; o++) {
var p = n.getItemAtIndex(o);
if (p == null || !a.analyzer.isCollection(p)) {
continue;
}
var q = a.getSubProvider(p, "[" + o + "]");
var r = q.actualCount;
if (r == 0) {
continue;
}
if (e == 0 && o == 0 && (!b.i.hasPath() || !b.j.hasPath())) {
l = true;
var s = this.a(a.analyzer.getAllNumericProperties());
try {
for (var _b = (e_1 = void 0, __values(fromEnum(s))), _c = _b.next(); !_c.done; _c = _b.next()) {
var t = _c.value;
d.add(b.g.path + "[0][0]." + t);
}
}
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;
}
}
}
a.popSubProvider();
}
a.popSubProvider();
if (l) {
break;
}
}
else {
break;
}
}
}
for (var u = 0; u < d.count; u++) {
a.am(a.getCurrentPath(), d._inner[u], 2);
}
return d.toArray();
};
ScatterDataRule.prototype.b = function (a) {
var b = new ShapeDataInfo(a);
b.q = this.priority;
b.o = 1;
b.u = a.adjustPrioritiesBasedOnFitness;
if (b.p == 0) {
if (a.adjustPrioritiesBasedOnFitness) {
b.q = 0;
}
return null;
}
if (a.adjustPrioritiesBasedOnFitness && b.p == 1) {
b.o *= 0.8;
}
var c = true;
var d = new List$1(String_$type, 0);
var e = a.getCurrentDataSource();
for (var f = 0; f < b.p; f++) {
var g = b.l.getItemAtIndex(f);
if (f == 0) {
var h = this.a(a.analyzer.getAllStringProperties());
var i = this.a(a.analyzer.getAllNumericProperties());
this.p(a, e, b, i, null);
b.s(i, null);
b.t(h, null);
var j = b.b.getAllPropertiesWithName("ShapeType");
if (j.length == 0) {
j = b.b.getAllPropertiesWithName("shapeType");
}
if (j.length > 0) {
b.o = 1.2;
var k = b.l.getItemValue(g, "shapeType");
if (typeof k === 'number') {
b.k = ShapeChartUtils.a(typeGetValue(k));
}
if (typeof k === 'number') {
b.k = ShapeChartUtils.a(truncate(Math.round(k)));
}
}
var l = b.b.getAllPropertiesWithName("Fields");
if (l.length == 0) {
l = b.b.getAllPropertiesWithName("fields");
}
if (l.length > 0) {
var m = typeCast(IEnumerable_$type, b.l.getItemValue(g, l[0]));
if (m != null) {
var n = g.fieldsNames;
var o = g.fieldsTypes;
if (o != null && n != null) {
b.o = 1.2;
i = new List$1(String_$type, 0);
h = new List$1(String_$type, 0);
for (var p = 0; p < o.count; p++) {
var q = l[0] + "[" + n._inner[p] + "]";
if (!a.analyzer.shouldIncludeProperty(q, null)) {
continue;
}
if (o._inner[p] == "string") {
h.add(n._inner[p]);
}
else {
i.add(n._inner[p]);
d.add("fieldValues[" + n._inner[p] + "]");
}
}
this.p(a, e, b, i, "fieldValues[NAME]");
b.s(i, "fieldValues[NAME]");
b.t(h, "fieldValues[NAME]");
}
}
}
var r = this.a(a.analyzer.getAllObjectProperties());
b.r(r, null);
}
if (!b.g.hasPath()) {
b.x = b.p;
if (b.k == 0) {
if (b.i.hasPath() && b.j.hasPath()) {
if (this.supportGeographicSeries) {
if (f < this.geographicPointCheckThreshold) {
var s = b.l.getItemValue(g, b.i.path);
var t = b.l.getItemValue(g, b.j.path);
if (!this.e(a.analyzer.coerceToDouble(s), a.analyzer.coerceToDouble(t))) {
c = false;
}
}
}
b.k = 3;
}
}
else {
b.k = 0;
}
break;
}
else {
var u = b.l.getItemValue(g, b.g.path);
var v = this.a(a.analyzer.getAllNumericProperties());
if (u != null && a.analyzer.isCollection(u)) {
b.o = 1.2;
b.y = Math.max(b.l.actualCount, b.y);
b.z += b.l.actualCount;
var w = a.getSubProvider(u, b.g.path);
if (w.actualCount == 0) {
continue;
}
for (var x = 0; x < w.actualCount; x++) {
var y = w.getItemAtIndex(x);
if (y == null || !a.analyzer.isCollection(y)) {
continue;
}
b.w = Math.max(w.actualCount, b.w);
b.x += w.actualCount;
var z = a.getSubProvider(y, "[" + x + "]");
var aa = z.actualCount;
if (aa == 0) {
continue;
}
if (f == 0 && x == 0 && (!b.i.hasPath() || !b.j.hasPath())) {
var ab = this.a(a.analyzer.getAllNumericProperties());
for (var ac = ab.count - 1; ac >= 0; ac--) {
var ad = ab._inner[ac];
var ae = b.g.path + "[0][0]." + ad;
if (!a.analyzer.shouldIncludeProperty(ae, null)) {
ab.removeAt(ac);
}
}
if (ab.count > 0) {
var af = b.g.path + "[0][0].NAME";
b.s(ab, af);
}
}
if (this.supportGeographicSeries && f < this.geographicShapeCheckThreshold && x == 0) {
for (var ag = 0; ag < Math.min(z.actualCount, this.geographicPointCheckThreshold); ag++) {
var ah = this.q(z.getItemAtIndex(ag));
if (!this.d(ah)) {
c = false;
}
}
}
if (b.k == 0) {
if (z.actualCount == 1) {
b.k = 3;
}
else {
var ai = this.q(z.getItemAtIndex(0));
var aj = this.q(z.getItemAtIndex(aa - 1));
if (ai.x == aj.x && ai.y == aj.y) {
b.k = 2;
if (!b.c.hasPath() || this.c(a, e, b, b.c.path)) {
this.o(a, e, b);
}
}
else {
b.k = 1;
}
}
}
a.popSubProvider();
}
a.popSubProvider();
if (b.k == 0) {
if (b.x == b.p || b.y == 1) {
b.k = 3;
}
if (b.h.hasPath()) {
b.k = 1;
}
}
}
}
}
b.v = c && this.supportGeographicSeries;
return b;
};
ScatterDataRule.prototype.c = function (a, b, c, d) {
if (a.analyzer.isMonotonic(b, d, this.monotonicCheckAmount)) {
return true;
}
if (a.analyzer.isEvenlySpaced(b, d, this.monotonicCheckAmount)) {
return true;
}
if (a.analyzer.numericColumnHasNoRange(b, d, this.monotonicCheckAmount)) {
return true;
}
return false;
};
ScatterDataRule.prototype.o = function (a, b, c) {
if (c.n.count > 0) {
c.c.update1(c.n._inner[0], null);
c.c.logarithmicSuggested = a.analyzer.shouldUseLogarithmicScale(b, c.n._inner[0]);
}
};
ScatterDataRule.prototype.p = function (a, b, c, d, e) {
var e_2, _a;
try {
for (var _b = __values(fromEnum(d)), _c = _b.next(); !_c.done; _c = _b.next()) {
var f = _c.value;
var g = f;
if (e != null) {
g = stringReplace(e, "NAME", f);
}
if (!this.c(a, b, c, g)) {
c.n.add(g);
}
}
}
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;
}
}
};
ScatterDataRule.prototype.e = function (a, b) {
if (isNaN_(a) || isNaN_(b)) {
return true;
}
if (a >= -180 && a <= 180 && b >= -90 && b <= 90) {
return true;
}
return false;
};
ScatterDataRule.prototype.d = function (a) {
return this.e(a.x, a.y);
};
ScatterDataRule.prototype.q = function (a) {
if (a == null) {
return { $type: Point_$type, x: NaN, y: NaN };
}
if (typeCast(Point_$type, a) !== null) {
return a;
}
var p_ = a;
if (((p_.__x && p_.__y))) {
return a;
}
if (((p_.x && p_.y))) {
return { $type: Point_$type, x: (p_.x), y: (p_.y) };
}
return { $type: Point_$type, x: NaN, y: NaN };
};
ScatterDataRule.$t = markType(ScatterDataRule, 'ScatterDataRule', PriorityDataRule.$);
return ScatterDataRule;
}(PriorityDataRule));
export { ScatterDataRule };