igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
720 lines (719 loc) • 24.7 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 { FastItemDateTimeColumn } from "igniteui-angular-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { ISortingAxis_$type } from "./ISortingAxis";
import { IDateTimeAxis_$type } from "./IDateTimeAxis";
import { DependencyProperty } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { typeCast, Number_$type, Date_$type, fromEnum, runOn, delegateRemove, delegateCombine, markType, markDep, TypeRegistrar } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-angular-core";
import { NumericScaler } from "./NumericScaler";
import { SeriesViewer } from "./SeriesViewer";
import { SortedListView$1 } from "./SortedListView$1";
import { ArrayExtension } from "igniteui-angular-core";
import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel";
import { PropertyMetadata } from "igniteui-angular-core";
import { truncate, isNaN_ } from "igniteui-angular-core";
import { dateMinValue, dateSubtract, dateAdd, dateMaxValue, dateFromTicks } from "igniteui-angular-core";
/**
* @hidden
*/
var TimeAxisBase = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TimeAxisBase, _super);
function TimeAxisBase() {
var _this = _super.call(this) || this;
_this.ml = null;
_this.mu = null;
_this.mp = false;
_this.mx = dateMaxValue();
_this.mw = dateMinValue();
FastItemDateTimeColumn.o();
return _this;
}
TimeAxisBase.prototype.ag = function () {
return [this.actualMinimumValue.getTime(), this.actualMaximumValue.getTime()];
};
TimeAxisBase.prototype.el = function (a, b) {
if (!b.c.isEmpty) {
var c = this.m2(a, NumericScaler.ac, b.c, Rect.empty);
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.m2(a, b.e, b.d, b.c);
};
TimeAxisBase.prototype.fz = function (a, b) {
var c = this.gu(b);
if (c == TimeAxisBase.$$p[0]) {
return this.f0(a, b, this.dateTimeMemberPath);
}
return _super.prototype.fz.call(this, a, b);
};
TimeAxisBase.prototype.m2 = function (a, b, c, d) {
var e;
if (+(this.actualMaximumValue) == +(this.actualMinimumValue)) {
e = -1;
}
else {
e = (a - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime());
}
var f = 0;
if (this.categoryMode == 2) {
f = this.getGroupCenter(0, b, c, d);
}
if (this.ch) {
e = 1 - e;
f = -f;
}
return c.left + c.width * (e - b.left) / b.width - f;
};
TimeAxisBase.prototype.m3 = function (a, b, c) {
var d;
if (+(this.actualMaximumValue) == +(this.actualMinimumValue)) {
d = -1;
}
else {
d = (a - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime());
}
var e = 0;
if (this.ch) {
d = 1 - d;
e = -e;
}
return c.left + c.width * (d - b.left) / b.width - e;
};
TimeAxisBase.prototype.eo = function (a, b) {
if (!b.c.isEmpty) {
var c = b.d.left;
var d = b.d.width;
if (this.categoryMode != 0) {
var e = this.getCategorySize(b.e, b.d, b.c);
c += e / 2;
d -= e;
}
var f = b.e.left + b.e.width * (a - c) / b.d.width;
f = (f * b.d.width) + b.d.left;
f = this.getUnscaledValue3(f, NumericScaler.ac, b.c, this.categoryMode);
return f;
}
return this.getUnscaledValue3(a, b.e, b.d, this.categoryMode);
};
TimeAxisBase.prototype.getUnscaledValue3 = function (a, b, c, d) {
var e = b.left + b.width * (a - c.left) / c.width;
if (this.ch) {
e = 1 - e;
}
return truncate(Math.floor(this.actualMinimumValue.getTime() + e * (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime())));
};
TimeAxisBase.prototype.i$h = function () {
this.ni();
};
TimeAxisBase.prototype.ni = function () {
var a = this.bi != null ? this.bi.v4 : Rect.empty;
var b = !a.isEmpty ? this.kh : Rect.empty;
var c = (new Date());
var d = (new Date());
var e = false;
if (!a.isEmpty && !b.isEmpty && this.mm != null) {
var f = typeCast(FastItemDateTimeColumn.$, this.mm);
if (f != null) {
if (this.mv == null) {
this.nj();
}
}
else {
this.mv = null;
}
if (this.mm.count > 0) {
e = true;
var g = this.mv == null ? 0 : this.mv._inner[0];
var h = this.mv == null ? this.mm.count - 1 : this.mv._inner[this.mm.count - 1];
c = this.mm.item(g);
d = this.mm.item(h);
this.mq = false;
if (this.categoryMode == 2) {
var i = this.ng(c, d);
if (+c != +(dateMinValue())) {
c = dateSubtract(+c, +i);
}
d = dateAdd(+d, +i);
}
}
}
if (this.mt()) {
e = true;
c = this.minimumValue;
}
if (this.ms()) {
e = true;
d = this.maximumValue;
}
var j = +(this.actualMinimumValue) != +c || +(this.actualMaximumValue) != +d;
if (e && j) {
var k = this.actualMinimumValue;
var l = this.actualMaximumValue;
this.actualMinimumValue = c;
this.actualMaximumValue = d;
this.nn();
}
};
TimeAxisBase.prototype.nn = function () {
};
Object.defineProperty(TimeAxisBase.prototype, "mm", {
get: function () {
return this.ml;
},
set: function (a) {
if (this.ml != a) {
var b = this.ml;
this.ml = a;
this.h5("DateTimeColumn", b, this.ml);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeAxisBase.prototype, "mv", {
get: function () {
return this.mu;
},
set: function (a) {
this.mu = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeAxisBase.prototype, "i$b", {
get: function () {
if (this.mv == null) {
var a = typeCast(FastItemDateTimeColumn.$, this.mm);
if (a != null) {
this.nj();
}
else {
this.mv = null;
}
}
return this.mv;
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.nj = function () {
if (this.mr) {
this.mv = new List$1(Number_$type, 0);
var a = this.mv;
var b = this.mm.count;
for (var c = 0; c < b; c++) {
a.add(c);
}
}
else {
var d = typeCast(FastItemDateTimeColumn.$, this.mm);
this.mv = d.h();
}
};
TimeAxisBase.prototype.i$e = function (a, b, c, d) {
return this.m5(a, b, c, d);
};
TimeAxisBase.prototype.m5 = function (a, b, c, d) {
if (b.isEmpty) {
return -1;
}
var e = d;
var f = new ScalerParams(0, a, b, this.ch, c);
var g, h;
if (this.ch) {
h = this.eo(e.left, f);
g = this.eo(e.right, f);
}
else {
g = this.eo(e.left, f);
h = this.eo(e.right, f);
}
var i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(g)));
return this.m4(dateFromTicks(i));
};
TimeAxisBase.prototype.m4 = function (a) {
if (this.mm == null || this.mv.count != this.mm.count) {
return -1;
}
var b = new SortedListView$1(Date_$type, this.mm, this.mv);
var c = this.m6(a, b);
if (c >= 0 && c < this.mv.count) {
var d = this.mm.item(this.mv._inner[c]);
if (d > a) {
c--;
if (c < 0) {
c = 0;
}
}
return c;
}
return this.mv.count - 1;
};
TimeAxisBase.prototype.i$g = function (a, b, c, d) {
return this.m8(a, b, c, d);
};
TimeAxisBase.prototype.m8 = function (a, b, c, d) {
if (b.isEmpty) {
return -1;
}
var e = d;
var f = new ScalerParams(0, a, b, this.ch, c);
var g, h;
if (this.ch) {
h = this.eo(e.left, f);
g = this.eo(e.right, f);
}
else {
g = this.eo(e.left, f);
h = this.eo(e.right, f);
}
var i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(h)));
return this.m7(dateFromTicks(i));
};
TimeAxisBase.prototype.m7 = function (a) {
if (this.mm == null || this.mv.count != this.mm.count) {
return -1;
}
var b = new SortedListView$1(Date_$type, this.mm, this.mv);
var c = this.m6(a, b);
if (c >= this.mv.count) {
c = this.mv.count - 1;
}
if (c >= 0 && c < this.mv.count) {
var d = this.mm.item(this.mv._inner[c]);
if (d < a) {
c++;
if (c > this.mv.count - 1) {
c = this.mv.count - 1;
}
}
return c;
}
return 0;
};
TimeAxisBase.prototype.i$d = function (a) {
if (this.mm == null) {
return NaN;
}
var b = this.ml.item(a);
var c = b.getTime();
var d = c;
return d;
};
TimeAxisBase.prototype.i$c = function (a) {
var b = this;
if (b.i$b == null) {
return -1;
}
var c = new SortedListView$1(Date_$type, this.mm, b.i$b);
var ticks_ = a;
var d = (new Date(ticks_));
var e = this.m6(d, c);
if (e >= 0 && e < b.i$b.count && e - 1 >= 0 && e - 1 < b.i$b.count) {
var diff1_ = d.getTime() - c.item(e - 1).getTime();
var diff2_ = c.item(e).getTime() - d.getTime();
var f = e - 1;
var g = e;
if (f < 0 && g >= 0) {
return g;
}
if (g > b.i$b.count - 1 && f < b.i$b.count) {
return f;
}
if (f < 0 && g < 0) {
return -1;
}
if (f > b.i$b.count - 1 && g > b.i$b.count - 1) {
return -1;
}
var h = diff1_ / (diff1_ + diff2_);
if (isNaN_(h)) {
h = 0;
}
return f + h;
}
if (e >= 0 && e < b.i$b.count) {
return e;
}
var i = this.kc();
if (e == b.i$b.count && this.bi != null && this.el(a, new ScalerParams(0, this.bi.v4, this.kh, this.ch, i)) < (this.kh.right + 2)) {
return e - 1;
}
if (e == -1 && this.bi != null && Math.abs(this.el(a, new ScalerParams(0, this.bi.v4, this.kh, this.ch, i)) - this.kh.left) < 2) {
return 0;
}
return -1;
};
TimeAxisBase.prototype.m6 = function (a, b) {
var c = this;
if (this.mm == null || c.i$b == null) {
return -1;
}
var d = -1;
var e = ArrayExtension.binarySearch$11(Date_$type, b, function (f) {
if (a < f) {
return -1;
}
if (a > f) {
return 1;
}
return 0;
});
if (e >= 0) {
d = e;
}
else {
d = ~e;
}
while (d >= 0 && d < b.count && d - 1 >= 0 && +(b.item(d)) == +(b.item(d - 1))) {
d--;
}
return d;
};
TimeAxisBase.prototype.i$f = function (a) {
var b = this;
if (b.i$b == null || this.mm == null || b.i$b.count != this.mm.count) {
return -1;
}
var c = new SortedListView$1(Date_$type, this.mm, b.i$b);
var ticks_ = a;
var d = (new Date(ticks_));
var e = this.m6(d, c);
var f = this.kc();
if (e >= 0 && e < b.i$b.count && e - 1 >= 0 && e - 1 < b.i$b.count) {
var g = +d - +(c.item(e - 1));
var h = +(c.item(e)) - +d;
if (g < h) {
e = e - 1;
}
}
if (e >= 0 && e < b.i$b.count) {
return b.i$b._inner[e];
}
if (e == b.i$b.count && this.bi != null && this.el(a, new ScalerParams(0, this.bi.v4, this.kh, this.ch, f)) < (this.kh.right + 2)) {
return e - 1;
}
if (e == -1 && this.bi != null && Math.abs(this.el(a, new ScalerParams(0, this.bi.v4, this.kh, this.ch, f)) - this.kh.left) < 2) {
return 0;
}
return -1;
};
TimeAxisBase.prototype.i$i = function () {
this.mv = null;
this.ia();
};
TimeAxisBase.prototype.get_mq = function () {
return this.mp;
};
TimeAxisBase.prototype.set_mq = function (a) {
this.mp = a;
};
Object.defineProperty(TimeAxisBase.prototype, "mq", {
get: function () {
return this.get_mq();
},
set: function (a) {
this.set_mq(a);
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.h1 = function (a) {
_super.prototype.h1.call(this, a);
this.dateTimeMemberPath = a;
};
TimeAxisBase.prototype.h4 = function (a) {
_super.prototype.h4.call(this, a);
this.minimumValue = a;
};
TimeAxisBase.prototype.h3 = function (a) {
_super.prototype.h4.call(this, a);
this.maximumValue = a;
};
TimeAxisBase.prototype.c3 = function () {
if (this.cq && this.c4) {
this.bc = this.bb();
}
var a = this.actualMinimumValue.getTime();
var b = this.actualMaximumValue.getTime();
this.ni();
var c = !this.mt() ? this.actualMinimumValue.getTime() : this.minimumValue.getTime();
var d = !this.ms() ? this.actualMaximumValue.getTime() : this.maximumValue.getTime();
var e = new AxisRangeChangedEventArgs(0, a, c, b, d);
this.h6(e);
return true;
};
TimeAxisBase.prototype.mt = function () {
if (+(this.minimumValue) == +(dateMinValue())) {
return false;
}
return (this.minimumValue != null);
};
TimeAxisBase.prototype.ms = function () {
if (+(this.maximumValue) == +(dateMaxValue())) {
return false;
}
return (this.maximumValue != null);
};
Object.defineProperty(TimeAxisBase.prototype, "actualMinimumValue", {
get: function () {
return this.mx;
},
set: function (a) {
var b = +(this.mx) != +a;
if (b) {
var c = this.mx;
this.mx = a;
this.h5("ActualMinimumValue", c, a);
}
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.f4 = function () {
return this.actualMinimumValue;
};
Object.defineProperty(TimeAxisBase.prototype, "actualMaximumValue", {
get: function () {
return this.mw;
},
set: function (a) {
var b = +(this.mw) != +a;
if (b) {
var c = this.mw;
this.mw = a;
this.h5("ActualMaximumValue", c, a);
}
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.f3 = function () {
return this.maximumValue;
};
TimeAxisBase.prototype.nk = function (a) {
var e_1, _a;
this.ic(a);
if (this.kv == null) {
return;
}
try {
for (var _b = __values(fromEnum(this.db())), _c = _b.next(); !_c.done; _c = _b.next()) {
var b = _c.value;
b.rq(a);
}
}
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;
}
}
};
TimeAxisBase.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.mm);
this.mm = null;
e.event = delegateRemove(e.event, runOn(this, this.nh));
}
var f = typeCast(IFastItemsSource_$type, d);
if (f != null) {
this.mv = null;
this.mm = this.mn(this.dateTimeMemberPath);
f.event = delegateCombine(f.event, runOn(this, this.nh));
}
this.nk(false);
break;
case TimeAxisBase.$$p[0]:
if (this.kv != null) {
this.kv.deregisterColumn(this.mm);
this.mm = this.mn(this.dateTimeMemberPath);
this.mv = null;
}
break;
case TimeAxisBase.$$p[3]:
this.c1();
this.nk(false);
break;
case TimeAxisBase.$$p[2]:
this.c1();
this.nk(false);
break;
case "DateTimeColumn":
this.ni();
break;
}
};
TimeAxisBase.prototype.nh = function (a, b) {
this.mv = null;
};
TimeAxisBase.prototype.mn = function (a) {
return TimeAxisBase.mo(a, this);
};
TimeAxisBase.mo = function (a, b) {
if (a == null) {
return b.kv.registerColumnDateTime(null, null, false);
}
var c = null;
var d = SeriesViewer.cu(a, b.coercionMethods);
c = d.a;
return b.kv.registerColumnDateTime(a, c, b.expectFunctions);
};
TimeAxisBase.prototype.av = function () {
if (this.c6) {
return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel'));
}
else {
return new HorizontalAxisLabelPanel();
}
};
TimeAxisBase.prototype.get_a2 = function () {
return 0;
};
Object.defineProperty(TimeAxisBase.prototype, "a2", {
get: function () {
return this.get_a2();
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.ic = function (a) {
_super.prototype.ic.call(this, a);
var b = this.a5.a4();
var c = this.a5.a7();
var d = this.a5.a5();
var e = this.a5.a6();
var f = this.a5.e();
var g = this.a5.f();
var h = this.a5.g();
this.ip();
this.hk(b);
this.hk(c);
this.hk(d);
this.hk(e);
this.dd.clear();
this.de.clear();
this.k2.clear();
this.aw.ad = this;
var i = this.bi != null ? this.bi.v4 : Rect.empty;
var j = !i.isEmpty ? this.kh : Rect.empty;
this.aw.c5 = i;
this.aw.c4 = j;
if (i.isEmpty || j.isEmpty) {
this.br.count = 0;
this.bq.count = 0;
this.bp.count = 0;
}
if (this.br.count == 0 && this.a5.l()) {
this.aw.ab.clear();
}
if (this.az != null) {
this.az.registerAxis(this);
}
this.ni();
};
TimeAxisBase.prototype.get_ce = function () {
return true;
};
TimeAxisBase.prototype.startCursor = function () {
};
TimeAxisBase.prototype.resetCursor = function () {
};
TimeAxisBase.prototype.StartTimeCursor = function () {
this.startCursor();
};
TimeAxisBase.prototype.ResetTimeCursor = function () {
this.resetCursor();
};
TimeAxisBase.prototype.getCategorySize = function (a, b, c) {
if (this.lj == 0) {
return 0;
}
var d = this.kf(b, c);
return d.width / (this.lj * a.width);
};
TimeAxisBase.prototype.getGroupCenter = function (a, b, c, d) {
return this.getCategorySize(b, c, d) * 0.5;
};
TimeAxisBase.prototype.k8 = function (a, b, c) {
var d = this.lf(a, b, c);
var e = 1 - 0.5 * d;
var f = this.getCategorySize(a, b, c) * e;
return f;
};
TimeAxisBase.prototype.get_cn = function () {
return true;
};
TimeAxisBase.prototype.ng = function (a, b) {
return (0);
};
TimeAxisBase.prototype.preferredCategoryMode = function (a) {
return this.cc ? 0 : 1;
};
Object.defineProperty(TimeAxisBase.prototype, "isVertical", {
get: function () {
return this.cp;
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.j$d = function (a, b) {
return this.eo.apply(this, arguments);
};
TimeAxisBase.prototype.j$c = function (a, b) {
return this.el.apply(this, arguments);
};
TimeAxisBase.prototype.j$e = function (a, b, c, d, e) {
this.hp.apply(this, arguments);
};
TimeAxisBase.prototype.j$f = function (a, b, c, d) {
this.hq.apply(this, arguments);
};
TimeAxisBase.prototype.j$g = function (a, b, c, d) {
this.hr.apply(this, arguments);
};
Object.defineProperty(TimeAxisBase.prototype, "j$b", {
get: function () {
return this.ch;
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.j$a = function () {
return this.ag.apply(this, arguments);
};
Object.defineProperty(TimeAxisBase.prototype, "i$a", {
get: function () {
return this.ce;
},
enumerable: false,
configurable: true
});
TimeAxisBase.$t = markType(TimeAxisBase, 'TimeAxisBase', CategoryAxisBase.$, [ISortingAxis_$type, IDateTimeAxis_$type]);
TimeAxisBase.$$p = markDep(DependencyProperty, PropertyMetadata, TimeAxisBase, 'h5', ['DateTimeMemberPath::no', [2, null], 'IsDataPreSorted:mr:np', [0, false], 'MaximumValue::nq', [3, null], 'MinimumValue::nr', [3, null]]);
return TimeAxisBase;
}(CategoryAxisBase));
export { TimeAxisBase };