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.st = dateMaxValue();
_this.ss = dateMinValue();
_this.sz = dateMaxValue();
_this.sy = dateMinValue();
_this.sv = dateMaxValue();
_this.su = dateMinValue();
_this.s9 = null;
_this.s8 = null;
_this.so = 0;
_this.sq = null;
_this.sm = null;
_this.ti = 0;
_this.sx = dateMinValue();
_this.sw = dateMaxValue();
_this.visibleRangeChanged = null;
FastItemDateTimeColumn.o();
_this.sm = new TimeAxisLabelFormatCollection();
var a = _this.sn;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.tk));
_this.rw = 0;
return _this;
}
OrdinalTimeXAxis.prototype.f9 = function (a, b, c) {
return this.f7(a, new ScalerParams(0, b, c, this.dn, this.o3()));
};
OrdinalTimeXAxis.prototype.f8 = function (a, b, c) {
return this.f7(a, b);
};
OrdinalTimeXAxis.prototype.f7 = function (a, b) {
if (!b.c.isEmpty) {
var c = this.s6(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.s6(a, b.e, b.d);
};
OrdinalTimeXAxis.prototype.s6 = function (a, b, c) {
var d = this.rv;
var e = this.rw;
var f = this.rv - this.rw;
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.k2 = 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.rv;
var u = this.rw;
var v = this.rv - this.rw;
var w = this.re(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.k3 = function (a, b, c, d) {
for (var e = b; e < c; e++) {
a.item(e, this.f7(a.item(e), d));
}
};
OrdinalTimeXAxis.prototype.gc = function (a, b, c) {
return this.ga(a, new ScalerParams(0, b, this.o8, this.dn, this.o3()));
};
OrdinalTimeXAxis.prototype.getUnscaledValue3 = function (a, b, c, d) {
return this.ga(a, new ScalerParams(0, b, this.o8, this.dn, this.o3()));
};
OrdinalTimeXAxis.prototype.ga = 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.s7(c, NumericScaler.ac, b.c);
return c;
}
return this.s7(a, b.e, b.d);
};
OrdinalTimeXAxis.prototype.s7 = function (a, b, c) {
var d = b.left + (a - c.left) * b.width / c.width;
if (this.dp) {
d = 1 - d;
}
return this.rw + d * (this.rv - this.rw);
};
OrdinalTimeXAxis.prototype.gb = function (a, b, c) {
return this.ga(a, b);
};
OrdinalTimeXAxis.prototype.k4 = function (a, b, c, d) {
for (var e = b; e < c; e++) {
a.item(e, this.ga(a.item(e), d));
}
};
OrdinalTimeXAxis.prototype.al = function () {
return new OrdinalTimeXAxis();
};
OrdinalTimeXAxis.prototype.lc = function (a, b, c, d) {
_super.prototype.lc.call(this, a, b, c, d);
switch (b) {
case "FastItemsSource":
var e = typeCast(IFastItemsSource_$type, c);
if (e != null) {
e.deregisterColumn(this.sr);
this.sr = null;
}
if (this.po != null) {
this.sr = TimeAxisBase.rh(this.dateTimeMemberPath, this);
}
break;
case "DateTimeMemberPath":
if (this.po != null) {
this.po.deregisterColumn(this.sr);
this.sr = TimeAxisBase.rh(this.dateTimeMemberPath, this);
}
break;
case "DateTimeColumn":
this.ee();
this.ti = this.th();
break;
case "MinimumValue":
case "MaximumValue":
this.ee();
this.lz();
break;
case "LabellingMode":
this.lz();
break;
}
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "actualMinimumValue", {
get: function () {
return this.st;
},
set: function (a) {
this.st = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "actualMaximumValue", {
get: function () {
return this.ss;
},
set: function (a) {
this.ss = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "visibleMinimum", {
get: function () {
return this.sz;
},
set: function (a) {
this.sz = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "visibleMaximum", {
get: function () {
return this.sy;
},
set: function (a) {
this.sy = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "s3", {
get: function () {
return this.sv;
},
set: function (a) {
this.sv = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "s2", {
get: function () {
return this.su;
},
set: function (a) {
this.su = a;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.tl = function () {
if (this.sr == null || this.sr.count == 0 || this.sr.count < this.rw - 1) {
this.actualMinimumValue = dateMinValue();
this.actualMaximumValue = dateMaxValue();
return;
}
var a = Math.max(0, Math.min(this.rw, this.sr.count - 1));
var b = Math.max(0, Math.min(this.rv, this.sr.count - 1));
var c = +(this.actualMinimumValue) != +(this.sr.item(a)) || +(this.actualMaximumValue) != +(this.sr.item(b));
if (c) {
var d = this.actualMinimumValue;
var e = this.actualMaximumValue;
this.actualMinimumValue = this.sr.item(a);
this.actualMaximumValue = this.sr.item(b);
this.tm();
}
};
OrdinalTimeXAxis.prototype.tm = function () {
if (this.sr == null || this.sr.count == 0 || this.b7 == null) {
var a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue);
this.visibleMinimum = this.actualMinimumValue;
this.visibleMaximum = this.actualMaximumValue;
this.s3 = this.visibleMinimum;
this.s2 = this.visibleMaximum;
if (a && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
return;
}
var b = this.o2();
var c = new ScalerParams(1, this.b7.zb, this.b7.za, this.dn);
c.c = this.o3();
var d = this.ga(b.left, c);
var e = this.ga(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.sr.count ? this.sr.item(f) : h;
var k = g >= 0 && g < this.sr.count ? this.sr.item(g) : i;
var l = j;
var m = k;
if (d > f) {
var n = f + 1;
var o = n >= 0 && n < this.sr.count ? this.sr.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.sr.count ? this.sr.item(q) : j;
var s = dateSubtract(+k, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+k - +r)) * (g - e))));
m = s;
}
this.s3 = l;
this.s2 = 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.l1 = function (a) {
var b = TimeXAxis.tn(this.actualMinimumValue, false, this.actualMinimumValue, this.sp, this.tg, this.sn, this.hb);
if (b != this.s9 && this.eh) {
this.l5();
}
this.s9 = b;
_super.prototype.l1.call(this, a);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "dateTimeMemberPath", {
get: function () {
return this.s8;
},
set: function (a) {
var b = this.dateTimeMemberPath;
if (a != b) {
this.s8 = a;
this.lu("DateTimeMemberPath", b, this.dateTimeMemberPath);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "sp", {
get: function () {
return this.so;
},
set: function (a) {
var b = this.sp;
if (a != b) {
this.so = a;
this.lu("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.sp));
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.get_dr = function () {
return true;
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "sr", {
get: function () {
return this.sq;
},
set: function (a) {
if (this.sq != a) {
var b = this.sq;
this.sq = a;
this.lu("DateTimeColumn", b, this.sq);
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.mg = function (a, b) {
_super.prototype.mg.call(this, a, b);
this.tm();
};
OrdinalTimeXAxis.prototype.getWindowRectForSelection = function (a, b) {
if (this.sr == null) {
return Rect.empty;
}
var c = a > b;
var d = c ? b : a;
var e = c ? a : b;
var f = -1;
while (++f < this.sr.count && this.sr.item(f) < d) {
}
var g = this.sr.count;
while (--g >= 0 && this.sr.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.yw);
var i = this.f7(f, h);
var j = this.f7(g + 1, h);
return new Rect(0, i, NaN, Math.max(0, j - i), NaN);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "sn", {
get: function () {
return this.sm;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.tk = function (a, b) {
this.l0(false);
};
OrdinalTimeXAxis.prototype.le = function (a) {
_super.prototype.le.call(this, a);
this.dateTimeMemberPath = a;
};
OrdinalTimeXAxis.prototype.hy = 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.hy.call(this, a);
}
var b = dateMinValue();
var c = false;
if (this.rx != null) {
if (typeCast(Date_$type, this.rx) !== null) {
b = this.rx;
c = true;
}
}
var d = TimeXAxis.ti(a, c, b, this.sp, this.tg, this.sn, this.hb);
return d == null ? _super.prototype.hy.call(this, a) : d;
};
OrdinalTimeXAxis.prototype.ja = 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.qd - 1) {
return _super.prototype.ja.call(this, a);
}
var c = this.sr.item(b);
var d = this.hy(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.qd - 1) {
b = this.qd - 1;
}
if (this.sr == null) {
return dateMinValue();
}
var c = this.sr.item(b);
return c;
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "tj", {
get: function () {
return +(this.visibleMaximum) - +(this.visibleMinimum);
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "tg", {
get: function () {
return +(this.s2) - +(this.s3);
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.rg = function () {
return this.sr;
};
OrdinalTimeXAxis.prototype.mf = function (a, b) {
_super.prototype.mf.call(this, a, b);
this.tm();
};
OrdinalTimeXAxis.prototype.rp = function (a, b) {
var c = this.categoryMode == 0 ? 0 : 0.5;
return _super.prototype.rp.call(this, a + c, b);
};
OrdinalTimeXAxis.prototype.ro = function (a, b, c, d) {
return b;
};
OrdinalTimeXAxis.prototype.th = function () {
var _this = this;
if (this.sr == null || this.sr.count < 2) {
return (0);
}
return TimeXAxis.tt(function (a) { return _this.sr.item(a); }, this.sr.count);
};
OrdinalTimeXAxis.prototype.itemLabelFormat = function () {
return TimeXAxis.tp(this.ti);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "minimumValue", {
get: function () {
return this.sx;
},
set: function (a) {
var b = this.minimumValue;
if (+a != +b) {
this.sx = a;
this.lc(this, "MinimumValue", b, this.minimumValue);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "maximumValue", {
get: function () {
return this.sw;
},
set: function (a) {
var b = this.maximumValue;
if (+a != +b) {
this.sw = a;
this.lc(this, "MaximumValue", b, this.maximumValue);
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.eg = function () {
if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) {
return _super.prototype.eg.call(this);
}
if (this.d1 && this.eh) {
this.b1 = this.b0();
}
if (this.po == null || this.sr == null) {
return false;
}
var a = this.rw;
if (+(this.minimumValue) != +(dateMinValue())) {
var b = -1;
while (b++ <= this.sr.count) {
if (this.sr.item(b) >= this.minimumValue) {
break;
}
}
a = b;
}
var c = this.categoryMode == 0 ? this.po.count - 1 : this.po.count;
if (+(this.maximumValue) != +(dateMaxValue())) {
var d = this.po.count;
while (d-- > 0) {
if (this.sr.item(d) <= this.maximumValue) {
break;
}
}
c = d;
}
if (a != this.rw || c != this.rv) {
var e = new AxisRangeChangedEventArgs(0, this.rw, a, this.rv, c);
this.rw = a;
this.rv = c;
this.lv(e);
this.tl();
this.qr();
return true;
}
return false;
};
OrdinalTimeXAxis.prototype.q0 = function (a) {
_super.prototype.q0.call(this, a);
this.ef(true);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "isVertical", {
get: function () {
return this.dz;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.j$d = function (a, b) {
return this.ga.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$c = function (a, b) {
return this.f7.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$e = function (a, b, c, d, e) {
this.k2.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$f = function (a, b, c, d) {
this.k3.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$g = function (a, b, c, d) {
this.k4.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 };