igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
602 lines (601 loc) • 21.4 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-angular-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-angular-core";
import { ScalerParams } from "./ScalerParams";
import { NumericScaler } from "./NumericScaler";
import { EventArgs, runOn, delegateCombine, typeCast, enumGetBox, Date_$type, markType } from "igniteui-angular-core";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { TimeAxisBase } from "./TimeAxisBase";
import { TimeXAxis } from "./TimeXAxis";
import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs";
import { truncate } from "igniteui-angular-core";
import { dateMaxValue, dateMinValue, dateAdd, dateSubtract } from "igniteui-angular-core";
import { timeSpanFromMilliseconds, timeSpanTotalMilliseconds } from "igniteui-angular-core";
/**
* @hidden
*/
var OrdinalTimeXAxis = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(OrdinalTimeXAxis, _super);
function OrdinalTimeXAxis() {
var _this = _super.call(this) || this;
_this.nu = dateMaxValue();
_this.nt = dateMinValue();
_this.n0 = dateMaxValue();
_this.nz = dateMinValue();
_this.nw = dateMaxValue();
_this.nv = dateMinValue();
_this.oa = null;
_this.n9 = null;
_this.np = 0;
_this.nr = null;
_this.nn = null;
_this.oj = 0;
_this.ny = dateMinValue();
_this.nx = dateMaxValue();
_this.visibleRangeChanged = null;
FastItemDateTimeColumn.o();
_this.nn = new TimeAxisLabelFormatCollection();
var a = _this.no;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.ol));
_this.m1 = 0;
return _this;
}
OrdinalTimeXAxis.prototype.en = function (a, b, c) {
return this.el(a, new ScalerParams(0, b, c, this.ch, this.kc()));
};
OrdinalTimeXAxis.prototype.em = function (a, b, c) {
return this.el(a, b);
};
OrdinalTimeXAxis.prototype.el = function (a, b) {
if (!b.c.isEmpty) {
var c = this.n7(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.n7(a, b.e, b.d);
};
OrdinalTimeXAxis.prototype.n7 = function (a, b, c) {
var d = this.m0;
var e = this.m1;
var f = this.m0 - this.m1;
var g = f >= 1 ? (a - e) / (d - e) : f == 0 ? 0.5 : NaN;
if (this.ci) {
g = 1 - g;
}
return c.left + c.width * (g - b.left) / b.width;
};
OrdinalTimeXAxis.prototype.hp = 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.m0;
var u = this.m1;
var v = this.m0 - this.m1;
var w = this.ml(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.hq = function (a, b, c, d) {
for (var e = b; e < c; e++) {
a.item(e, this.el(a.item(e), d));
}
};
OrdinalTimeXAxis.prototype.eq = function (a, b, c) {
return this.eo(a, new ScalerParams(0, b, this.kh, this.ch, this.kc()));
};
OrdinalTimeXAxis.prototype.getUnscaledValue3 = function (a, b, c, d) {
return this.eo(a, new ScalerParams(0, b, this.kh, this.ch, this.kc()));
};
OrdinalTimeXAxis.prototype.eo = 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.n8(c, NumericScaler.ac, b.c);
return c;
}
return this.n8(a, b.e, b.d);
};
OrdinalTimeXAxis.prototype.n8 = function (a, b, c) {
var d = b.left + (a - c.left) * b.width / c.width;
if (this.ci) {
d = 1 - d;
}
return this.m1 + d * (this.m0 - this.m1);
};
OrdinalTimeXAxis.prototype.ep = function (a, b, c) {
return this.eo(a, b);
};
OrdinalTimeXAxis.prototype.hr = function (a, b, c, d) {
for (var e = b; e < c; e++) {
a.item(e, this.eo(a.item(e), d));
}
};
OrdinalTimeXAxis.prototype.hz = function (a, b, c, d) {
_super.prototype.hz.call(this, a, b, c, d);
switch (b) {
case "FastItemsSource":
var e = typeCast(IFastItemsSource_$type, c);
if (e != null) {
e.deregisterColumn(this.ns);
this.ns = null;
}
if (this.kv != null) {
this.ns = TimeAxisBase.mo(this.dateTimeMemberPath, this);
}
break;
case "DateTimeMemberPath":
if (this.kv != null) {
this.kv.deregisterColumn(this.ns);
this.ns = TimeAxisBase.mo(this.dateTimeMemberPath, this);
}
break;
case "DateTimeColumn":
this.c1();
this.oj = this.oi();
break;
case "MinimumValue":
case "MaximumValue":
this.c1();
this.ia();
break;
case "LabellingMode":
this.ia();
break;
}
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "actualMinimumValue", {
get: function () {
return this.nu;
},
set: function (a) {
this.nu = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "actualMaximumValue", {
get: function () {
return this.nt;
},
set: function (a) {
this.nt = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "visibleMinimum", {
get: function () {
return this.n0;
},
set: function (a) {
this.n0 = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "visibleMaximum", {
get: function () {
return this.nz;
},
set: function (a) {
this.nz = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "n4", {
get: function () {
return this.nw;
},
set: function (a) {
this.nw = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "n3", {
get: function () {
return this.nv;
},
set: function (a) {
this.nv = a;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.om = function () {
if (this.ns == null || this.ns.count == 0 || this.ns.count < this.m1 - 1) {
this.actualMinimumValue = dateMinValue();
this.actualMaximumValue = dateMaxValue();
return;
}
var a = Math.max(0, Math.min(this.m1, this.ns.count - 1));
var b = Math.max(0, Math.min(this.m0, this.ns.count - 1));
var c = +(this.actualMinimumValue) != +(this.ns.item(a)) || +(this.actualMaximumValue) != +(this.ns.item(b));
if (c) {
var d = this.actualMinimumValue;
var e = this.actualMaximumValue;
this.actualMinimumValue = this.ns.item(a);
this.actualMaximumValue = this.ns.item(b);
this.on();
}
};
OrdinalTimeXAxis.prototype.on = function () {
if (this.ns == null || this.ns.count == 0 || this.bi == null) {
var a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue);
this.visibleMinimum = this.actualMinimumValue;
this.visibleMaximum = this.actualMaximumValue;
this.n4 = this.visibleMinimum;
this.n3 = this.visibleMaximum;
if (a && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
return;
}
var b = this.kb();
var c = new ScalerParams(1, this.bi.wl, this.bi.wk, this.ch);
c.c = this.kc();
var d = this.eo(b.left, c);
var e = this.eo(b.right, c);
var f = truncate(Math.floor(d));
var g = truncate(Math.ceil(e));
var h = f >= 0 && f < this.ns.count ? this.ns.item(f) : this.actualMinimumValue;
var i = g >= 0 && g < this.ns.count ? this.ns.item(g) : this.actualMaximumValue;
var j = h;
var k = i;
if (d > f) {
var l = f + 1;
var m = l >= 0 && l < this.ns.count ? this.ns.item(l) : i;
var n = dateAdd(+h, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+m - +h)) * (d - f))));
j = n;
}
if (e < g) {
var o = g - 1;
var p = o >= 0 && o < this.ns.count ? this.ns.item(o) : h;
var q = dateSubtract(+i, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+i - +p)) * (g - e))));
k = q;
}
this.n4 = j;
this.n3 = k;
var r = +(this.visibleMinimum) != +h || +(this.visibleMaximum) != +i;
this.visibleMinimum = h;
this.visibleMaximum = i;
if (r && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
};
OrdinalTimeXAxis.prototype.ic = function (a) {
var b = TimeXAxis.ot(this.actualMinimumValue, false, this.actualMinimumValue, this.nq, this.oh, this.no, this.fm);
if (b != this.oa && this.c4) {
this.ih();
}
this.oa = b;
_super.prototype.ic.call(this, a);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "dateTimeMemberPath", {
get: function () {
return this.n9;
},
set: function (a) {
var b = this.dateTimeMemberPath;
if (a != b) {
this.n9 = a;
this.h5("DateTimeMemberPath", b, this.dateTimeMemberPath);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "nq", {
get: function () {
return this.np;
},
set: function (a) {
var b = this.nq;
if (a != b) {
this.np = a;
this.h5("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.nq));
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.get_ck = function () {
return true;
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "ns", {
get: function () {
return this.nr;
},
set: function (a) {
if (this.nr != a) {
var b = this.nr;
this.nr = a;
this.h5("DateTimeColumn", b, this.nr);
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.it = function (a, b) {
_super.prototype.it.call(this, a, b);
this.on();
};
OrdinalTimeXAxis.prototype.getWindowRectForSelection = function (a, b) {
if (this.ns == null) {
return Rect.empty;
}
var c = a > b;
var d = c ? b : a;
var e = c ? a : b;
var f = -1;
while (++f < this.ns.count && this.ns.item(f) < d) {
}
var g = this.ns.count;
while (--g >= 0 && this.ns.item(g) > e) {
}
var h = new ScalerParams(0, new Rect(0, 0, 0, 1, 1), new Rect(0, 0, 0, 1, 1), this.ch, this.bi.v8);
var i = this.el(f, h);
var j = this.el(g + 1, h);
return new Rect(0, i, NaN, Math.max(0, j - i), NaN);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "no", {
get: function () {
return this.nn;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.ol = function (a, b) {
this.ib(false);
};
OrdinalTimeXAxis.prototype.h1 = function (a) {
_super.prototype.h1.call(this, a);
this.dateTimeMemberPath = a;
};
OrdinalTimeXAxis.prototype.f1 = function (a) {
if (this.au != null) {
return this.au(a);
}
if (this.ai != null) {
return this.ai.i(a);
}
if (!(typeCast(Date_$type, a) !== null)) {
return _super.prototype.f1.call(this, a);
}
var b = dateMinValue();
var c = false;
if (this.m2 != null) {
if (typeCast(Date_$type, this.m2) !== null) {
b = this.m2;
c = true;
}
}
var d = TimeXAxis.oo(a, c, b, this.nq, this.oh, this.no, this.fm);
return d == null ? _super.prototype.f1.call(this, a) : d;
};
OrdinalTimeXAxis.prototype.gf = 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.lk - 1) {
return _super.prototype.gf.call(this, a);
}
var c = this.ns.item(b);
var d = this.f1(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.lk - 1) {
b = this.lk - 1;
}
if (this.ns == null) {
return dateMinValue();
}
var c = this.ns.item(b);
return c;
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "ok", {
get: function () {
return +(this.visibleMaximum) - +(this.visibleMinimum);
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "oh", {
get: function () {
return +(this.n3) - +(this.n4);
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.mn = function () {
return this.ns;
};
OrdinalTimeXAxis.prototype.is = function (a, b) {
_super.prototype.is.call(this, a, b);
this.on();
};
OrdinalTimeXAxis.prototype.mu = function (a, b) {
var c = this.categoryMode == 0 ? 0 : 0.5;
return _super.prototype.mu.call(this, a + c, b);
};
OrdinalTimeXAxis.prototype.mt = function (a, b, c, d) {
return b;
};
OrdinalTimeXAxis.prototype.oi = function () {
var _this = this;
if (this.ns == null || this.ns.count < 2) {
return (0);
}
return TimeXAxis.oz(function (a) { return _this.ns.item(a); }, this.ns.count);
};
OrdinalTimeXAxis.prototype.itemLabelFormat = function () {
return TimeXAxis.ov(this.oj);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "minimumValue", {
get: function () {
return this.ny;
},
set: function (a) {
var b = this.minimumValue;
if (+a != +b) {
this.ny = a;
this.hz(this, "MinimumValue", b, this.minimumValue);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(OrdinalTimeXAxis.prototype, "maximumValue", {
get: function () {
return this.nx;
},
set: function (a) {
var b = this.maximumValue;
if (+a != +b) {
this.nx = a;
this.hz(this, "MaximumValue", b, this.maximumValue);
}
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.c3 = function () {
if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) {
return _super.prototype.c3.call(this);
}
if (this.cq && this.c4) {
this.bc = this.bb();
}
if (this.kv == null || this.ns == null) {
return false;
}
var a = this.m1;
if (+(this.minimumValue) != +(dateMinValue())) {
var b = -1;
while (b++ <= this.ns.count) {
if (this.ns.item(b) >= this.minimumValue) {
break;
}
}
a = b;
}
var c = this.categoryMode == 0 ? this.kv.count - 1 : this.kv.count;
if (+(this.maximumValue) != +(dateMaxValue())) {
var d = this.kv.count;
while (d-- > 0) {
if (this.ns.item(d) <= this.maximumValue) {
break;
}
}
c = d;
}
if (a != this.m1 || c != this.m0) {
var e = new AxisRangeChangedEventArgs(0, this.m1, a, this.m0, c);
this.m1 = a;
this.m0 = c;
this.h6(e);
this.om();
this.ly();
return true;
}
return false;
};
OrdinalTimeXAxis.prototype.l7 = function (a) {
_super.prototype.l7.call(this, a);
this.c2(true);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "isVertical", {
get: function () {
return this.cp;
},
enumerable: false,
configurable: true
});
OrdinalTimeXAxis.prototype.j$d = function (a, b) {
return this.eo.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$c = function (a, b) {
return this.el.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$e = function (a, b, c, d, e) {
this.hp.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$f = function (a, b, c, d) {
this.hq.apply(this, arguments);
};
OrdinalTimeXAxis.prototype.j$g = function (a, b, c, d) {
this.hr.apply(this, arguments);
};
Object.defineProperty(OrdinalTimeXAxis.prototype, "j$b", {
get: function () {
return this.ch;
},
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 };