igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
607 lines (606 loc) • 21 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 } from "tslib";
import { FastItemDateTimeColumn } from "igniteui-react-core";
import { CategoryXAxis } from "./CategoryXAxis";
import { ITimeRangeSelectorAxis_$type } from "./ITimeRangeSelectorAxis";
import { IOrdinalAxis_$type } from "./IOrdinalAxis";
import { TimeAxisLabellingMode_$type } from "./TimeAxisLabellingMode";
import { TimeAxisLabelFormatCollection } from "./TimeAxisLabelFormatCollection";
import { Rect } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { NumericScaler } from "./NumericScaler";
import { EventArgs, runOn, delegateCombine, typeCast, enumGetBox, Date_$type, markType } from "igniteui-react-core";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { TimeAxisBase } from "./TimeAxisBase";
import { TimeXAxis } from "./TimeXAxis";
import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs";
import { truncate } from "igniteui-react-core";
import { dateMaxValue, dateMinValue, dateAdd, dateSubtract } from "igniteui-react-core";
import { timeSpanFromMilliseconds, timeSpanTotalMilliseconds } from "igniteui-react-core";
/**
* @hidden
*/
var OrdinalTimeXAxis = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(OrdinalTimeXAxis, _super);
function OrdinalTimeXAxis() {
var _this = _super.call(this) || this;
_this.sr = dateMaxValue();
_this.sq = dateMinValue();
_this.sx = dateMaxValue();
_this.sw = dateMinValue();
_this.st = dateMaxValue();
_this.ss = dateMinValue();
_this.s7 = null;
_this.s6 = null;
_this.sm = 0;
_this.so = null;
_this.sk = null;
_this.tg = 0;
_this.sv = dateMinValue();
_this.su = dateMaxValue();
_this.visibleRangeChanged = null;
FastItemDateTimeColumn.o();
_this.sk = new TimeAxisLabelFormatCollection();
var a = _this.sl;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.ti));
_this.ru = 0;
return _this;
}
OrdinalTimeXAxis.prototype.f8 = function (a, b, c) {
return this.f6(a, new ScalerParams(0, b, c, this.dn, this.o1()));
};
OrdinalTimeXAxis.prototype.f7 = function (a, b, c) {
return this.f6(a, b);
};
OrdinalTimeXAxis.prototype.f6 = function (a, b) {
if (!b.c.isEmpty) {
var c = this.s4(a, NumericScaler.ac, b.c);
c = (c - b.d.left) / b.d.width;
c = b.d.left + b.d.width * (c - b.e.left) / b.e.width;
return c;
}
return this.s4(a, b.e, b.d);
};
OrdinalTimeXAxis.prototype.s4 = function (a, b, c) {
var d = this.rt;
var e = this.ru;
var f = this.rt - this.ru;
var g = f >= 1 ? (a - e) / (d - e) : f == 0 ? 0.5 : NaN;
if (this.dp) {
g = 1 - g;
}
return c.left + c.width * (g - b.left) / b.width;
};
OrdinalTimeXAxis.prototype.k0 = function (a, b, c, d, e) {
var f;
var g = e.e;
var h = e.d;
var i = e.c;
var j = e.a;
var k = !i.isEmpty;
var l = i.left;
var m = i.width;
var n = g.left;
var o = g.width;
var p = h.left;
var q = h.width;
var r = 0;
var s = 1;
var t = this.rt;
var u = this.ru;
var v = this.rt - this.ru;
var w = this.rc(a);
var x = w != null;
for (var y = 0; y < b.count; y++) {
var z = b.item(y);
for (var aa = c; aa < d; aa++) {
f = x ? w[aa] : a.item(aa);
if (k) {
var ab = v >= 1 ? (f[z] - u) / (t - u) : v == 0 ? 0.5 : NaN;
if (j) {
ab = 1 - ab;
}
ab = l + m * (ab - r) / s;
var ac = (ab - p) / q;
ac = p + q * (ac - n) / o;
f[z] = ac;
}
else {
var ad = v >= 1 ? (f[z] - u) / (t - u) : v == 0 ? 0.5 : NaN;
if (j) {
ad = 1 - ad;
}
ad = p + q * (ad - n) / o;
f[z] = ad;
}
}
}
};
OrdinalTimeXAxis.prototype.k1 = function (a, b, c, d) {
for (var e = b; e < c; e++) {
a.item(e, this.f6(a.item(e), d));
}
};
OrdinalTimeXAxis.prototype.gb = function (a, b, c) {
return this.f9(a, new ScalerParams(0, b, this.o6, this.dn, this.o1()));
};
OrdinalTimeXAxis.prototype.getUnscaledValue3 = function (a, b, c, d) {
return this.f9(a, new ScalerParams(0, b, this.o6, this.dn, this.o1()));
};
OrdinalTimeXAxis.prototype.f9 = function (a, b) {
if (!b.c.isEmpty) {
var c = b.e.left + b.e.width * (a - b.d.left) / b.d.width;
c = (c * b.d.width) + b.d.left;
c = this.s5(c, NumericScaler.ac, b.c);
return c;
}
return this.s5(a, b.e, b.d);
};
OrdinalTimeXAxis.prototype.s5 = function (a, b, c) {
var d = b.left + (a - c.left) * b.width / c.width;
if (this.dp) {
d = 1 - d;
}
return this.ru + d * (this.rt - this.ru);
};
OrdinalTimeXAxis.prototype.ga = function (a, b, c) {
return this.f9(a, b);
};
OrdinalTimeXAxis.prototype.k2 = function (a, b, c, d) {
for (var e = b; e < c; e++) {
a.item(e, this.f9(a.item(e), d));
}
};
OrdinalTimeXAxis.prototype.al = function () {
return new OrdinalTimeXAxis();
};
OrdinalTimeXAxis.prototype.la = function (a, b, c, d) {
_super.prototype.la.call(this, a, b, c, d);
switch (b) {
case "FastItemsSource":
var e = typeCast(IFastItemsSource_$type, c);
if (e != null) {
e.deregisterColumn(this.sp);
this.sp = null;
}
if (this.pm != null) {
this.sp = TimeAxisBase.rf(this.dateTimeMemberPath, this);
}
break;
case "DateTimeMemberPath":
if (this.pm != null) {
this.pm.deregisterColumn(this.sp);
this.sp = TimeAxisBase.rf(this.dateTimeMemberPath, this);
}
break;
case "DateTimeColumn":
this.ed();
this.tg = this.tf();
break;
case "MinimumValue":
case "MaximumValue":
this.ed();
this.lx();
break;
case "LabellingMode":
this.lx();
break;
}
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "actualMinimumValue", {
get: function () {
return this.sr;
},
set: function (a) {
this.sr = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "actualMaximumValue", {
get: function () {
return this.sq;
},
set: function (a) {
this.sq = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "visibleMinimum", {
get: function () {
return this.sx;
},
set: function (a) {
this.sx = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "visibleMaximum", {
get: function () {
return this.sw;
},
set: function (a) {
this.sw = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "s1", {
get: function () {
return this.st;
},
set: function (a) {
this.st = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "s0", {
get: function () {
return this.ss;
},
set: function (a) {
this.ss = a;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.tj = function () {
if (this.sp == null || this.sp.count == 0 || this.sp.count < this.ru - 1) {
this.actualMinimumValue = dateMinValue();
this.actualMaximumValue = dateMaxValue();
return;
}
var a = Math.max(0, Math.min(this.ru, this.sp.count - 1));
var b = Math.max(0, Math.min(this.rt, this.sp.count - 1));
var c = +(this.actualMinimumValue) != +(this.sp.item(a)) || +(this.actualMaximumValue) != +(this.sp.item(b));
if (c) {
var d = this.actualMinimumValue;
var e = this.actualMaximumValue;
this.actualMinimumValue = this.sp.item(a);
this.actualMaximumValue = this.sp.item(b);
this.tk();
}
};
OrdinalTimeXAxis.prototype.tk = function () {
if (this.sp == null || this.sp.count == 0 || this.b7 == null) {
var a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue);
this.visibleMinimum = this.actualMinimumValue;
this.visibleMaximum = this.actualMaximumValue;
this.s1 = this.visibleMinimum;
this.s0 = this.visibleMaximum;
if (a && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
return;
}
var b = this.o0();
var c = new ScalerParams(1, this.b7.za, this.b7.y9, this.dn);
c.c = this.o1();
var d = this.f9(b.left, c);
var e = this.f9(b.right, c);
var f = truncate(Math.floor(d));
var g = truncate(Math.ceil(e));
var h = this.dn ? this.actualMaximumValue : this.actualMinimumValue;
var i = this.dn ? this.actualMinimumValue : this.actualMaximumValue;
var j = f >= 0 && f < this.sp.count ? this.sp.item(f) : h;
var k = g >= 0 && g < this.sp.count ? this.sp.item(g) : i;
var l = j;
var m = k;
if (d > f) {
var n = f + 1;
var o = n >= 0 && n < this.sp.count ? this.sp.item(n) : k;
var p = dateAdd(+j, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+o - +j)) * (d - f))));
l = p;
}
if (e < g) {
var q = g - 1;
var r = q >= 0 && q < this.sp.count ? this.sp.item(q) : j;
var s = dateSubtract(+k, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+k - +r)) * (g - e))));
m = s;
}
this.s1 = l;
this.s0 = m;
var t = +(this.visibleMinimum) != +j || +(this.visibleMaximum) != +k;
this.visibleMinimum = j;
this.visibleMaximum = k;
if (t && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
};
OrdinalTimeXAxis.prototype.lz = function (a) {
var b = TimeXAxis.tl(this.actualMinimumValue, false, this.actualMinimumValue, this.sn, this.te, this.sl, this.g9);
if (b != this.s7 && this.eg) {
this.l3();
}
this.s7 = b;
_super.prototype.lz.call(this, a);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "dateTimeMemberPath", {
get: function () {
return this.s6;
},
set: function (a) {
var b = this.dateTimeMemberPath;
if (a != b) {
this.s6 = a;
this.ls("DateTimeMemberPath", b, this.dateTimeMemberPath);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "sn", {
get: function () {
return this.sm;
},
set: function (a) {
var b = this.sn;
if (a != b) {
this.sm = a;
this.ls("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.sn));
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.get_dr = function () {
return true;
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "sp", {
get: function () {
return this.so;
},
set: function (a) {
if (this.so != a) {
var b = this.so;
this.so = a;
this.ls("DateTimeColumn", b, this.so);
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.me = function (a, b) {
_super.prototype.me.call(this, a, b);
this.tk();
};
OrdinalTimeXAxis.prototype.getWindowRectForSelection = function (a, b) {
if (this.sp == null) {
return Rect.empty;
}
var c = a > b;
var d = c ? b : a;
var e = c ? a : b;
var f = -1;
while (++f < this.sp.count && this.sp.item(f) < d) {
}
var g = this.sp.count;
while (--g >= 0 && this.sp.item(g) > e) {
}
var h = new ScalerParams(0, new Rect(0, 0, 0, 1, 1), new Rect(0, 0, 0, 1, 1), this.dn, this.b7.yv);
var i = this.f6(f, h);
var j = this.f6(g + 1, h);
return new Rect(0, i, NaN, Math.max(0, j - i), NaN);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "sl", {
get: function () {
return this.sk;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.ti = function (a, b) {
this.ly(false);
};
OrdinalTimeXAxis.prototype.lc = function (a) {
_super.prototype.lc.call(this, a);
this.dateTimeMemberPath = a;
};
OrdinalTimeXAxis.prototype.hw = function (a) {
if (this.az != null) {
return this.az(a);
}
if (this.ai != null) {
return this.ai.i(a);
}
if (!(typeCast(Date_$type, a) !== null)) {
return _super.prototype.hw.call(this, a);
}
var b = dateMinValue();
var c = false;
if (this.rv != null) {
if (typeCast(Date_$type, this.rv) !== null) {
b = this.rv;
c = true;
}
}
var d = TimeXAxis.tg(a, c, b, this.sn, this.te, this.sl, this.g9);
return d == null ? _super.prototype.hw.call(this, a) : d;
};
OrdinalTimeXAxis.prototype.i8 = function (a) {
var b = 0;
if (this.categoryMode == 0) {
b = truncate(Math.round(a));
}
else {
b = truncate(Math.floor(a));
}
if (b < 0 || b > this.qb - 1) {
return _super.prototype.i8.call(this, a);
}
var c = this.sp.item(b);
var d = this.hw(c);
if (d == null) {
return null;
}
return d.toString();
};
OrdinalTimeXAxis.prototype.getDateTime = function (a) {
var b = truncate(Math.round(a));
if (b < 0) {
b = 0;
}
if (b > this.qb - 1) {
b = this.qb - 1;
}
if (this.sp == null) {
return dateMinValue();
}
var c = this.sp.item(b);
return c;
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "th", {
get: function () {
return +(this.visibleMaximum) - +(this.visibleMinimum);
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "te", {
get: function () {
return +(this.s0) - +(this.s1);
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.re = function () {
return this.sp;
};
OrdinalTimeXAxis.prototype.md = function (a, b) {
_super.prototype.md.call(this, a, b);
this.tk();
};
OrdinalTimeXAxis.prototype.rn = function (a, b) {
var c = this.categoryMode == 0 ? 0 : 0.5;
return _super.prototype.rn.call(this, a + c, b);
};
OrdinalTimeXAxis.prototype.rm = function (a, b, c, d) {
return b;
};
OrdinalTimeXAxis.prototype.tf = function () {
var _this = this;
if (this.sp == null || this.sp.count < 2) {
return (0);
}
return TimeXAxis.tr(function (a) { return _this.sp.item(a); }, this.sp.count);
};
OrdinalTimeXAxis.prototype.itemLabelFormat = function () {
return TimeXAxis.tn(this.tg);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "minimumValue", {
get: function () {
return this.sv;
},
set: function (a) {
var b = this.minimumValue;
if (+a != +b) {
this.sv = a;
this.la(this, "MinimumValue", b, this.minimumValue);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "maximumValue", {
get: function () {
return this.su;
},
set: function (a) {
var b = this.maximumValue;
if (+a != +b) {
this.su = a;
this.la(this, "MaximumValue", b, this.maximumValue);
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.ef = function () {
if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) {
return _super.prototype.ef.call(this);
}
if (this.d0 && this.eg) {
this.b1 = this.b0();
}
if (this.pm == null || this.sp == null) {
return false;
}
var a = this.ru;
if (+(this.minimumValue) != +(dateMinValue())) {
var b = -1;
while (b++ <= this.sp.count) {
if (this.sp.item(b) >= this.minimumValue) {
break;
}
}
a = b;
}
var c = this.categoryMode == 0 ? this.pm.count - 1 : this.pm.count;
if (+(this.maximumValue) != +(dateMaxValue())) {
var d = this.pm.count;
while (d-- > 0) {
if (this.sp.item(d) <= this.maximumValue) {
break;
}
}
c = d;
}
if (a != this.ru || c != this.rt) {
var e = new AxisRangeChangedEventArgs(0, this.ru, a, this.rt, c);
this.ru = a;
this.rt = c;
this.lt(e);
this.tj();
this.qp();
return true;
}
return false;
};
OrdinalTimeXAxis.prototype.qy = function (a) {
_super.prototype.qy.call(this, a);
this.ee(true);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "isVertical", {
get: function () {
return this.dy;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.j$d = function (a, b) {
return this.f9.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$c = function (a, b) {
return this.f6.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$e = function (a, b, c, d, e) {
this.k0.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$f = function (a, b, c, d) {
this.k1.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$g = function (a, b, c, d) {
this.k2.apply(this, arguments);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "j$b", {
get: function () {
return this.dn;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.j$a = function () {
return this.ag.apply(this, arguments);
};
OrdinalTimeXAxis.$t = markType(OrdinalTimeXAxis, 'OrdinalTimeXAxis', CategoryXAxis.$, [ITimeRangeSelectorAxis_$type, IOrdinalAxis_$type]);
return OrdinalTimeXAxis;
}(CategoryXAxis));
export { OrdinalTimeXAxis };