igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
1,386 lines (1,385 loc) • 46.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 { TimeAxisBase } from "./TimeAxisBase";
import { ITimeRangeSelectorAxis_$type } from "./ITimeRangeSelectorAxis";
import { List$1 } from "igniteui-angular-core";
import { TimeAxisBreak } from "./TimeAxisBreak";
import { TimeAxisBreakCollection } from "./TimeAxisBreakCollection";
import { TimeAxisLabellingMode_$type } from "./TimeAxisLabellingMode";
import { TimeAxisLabelFormatCollection } from "./TimeAxisLabelFormatCollection";
import { OrderedDictionary$2 } from "./OrderedDictionary$2";
import { TimeAxisInterval } from "./TimeAxisInterval";
import { TimeAxisIntervalCollection } from "./TimeAxisIntervalCollection";
import { EventArgs, runOn, delegateCombine, Number_$type, fromEnum, enumGetBox, fromEn, typeCast, Date_$type, markType } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-angular-core";
import { NumericScaler } from "./NumericScaler";
import { KeyValuePair$2 } from "igniteui-angular-core";
import { NumericYAxis } from "./NumericYAxis";
import { LabelPosition } from "./LabelPosition";
import { Extensions } from "igniteui-angular-core";
import { SortedListView$1 } from "./SortedListView$1";
import { Dictionary$2 } from "igniteui-angular-core";
import { truncate, intDivide, isNaN_ } from "igniteui-angular-core";
import { dateFromTicks, dateMaxValue, dateSubtract, dateMinValue, dateGetMonth, dateAddMonths, dateFromValues, dateGetTimeOfDay, dateAddDays, dateAddHours } from "igniteui-angular-core";
import { timeSpanTicks, timeSpanInit3, timeSpanInit1, timeSpanFromMilliseconds, timeSpanFromSeconds, timeSpanFromMinutes, timeSpanFromHours, timeSpanFromDays, timeSpanFromTicks, timeSpanTotalMilliseconds } from "igniteui-angular-core";
import { dateToStringFormat } from "igniteui-angular-core";
/**
* @hidden
*/
var TimeXAxis = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TimeXAxis, _super);
function TimeXAxis() {
var _this = _super.call(this) || this;
_this.ol = 0;
_this.nv = null;
_this.n4 = 0;
_this.n2 = null;
_this._omission = 0;
_this.nt = null;
_this.n0 = null;
_this.op = null;
_this.o2 = 0;
_this.od = dateMaxValue();
_this.ob = dateMaxValue();
_this.oa = dateMaxValue();
_this.oc = dateMinValue();
_this.nx = null;
_this.o0 = 0;
_this.visibleRangeChanged = null;
_this.ab = TimeXAxis.$;
_this.omission = (0);
_this.ol = -2147483648;
_this.nv = new TimeAxisBreakCollection();
var a = _this.breaks;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.o5));
_this.n0 = new TimeAxisIntervalCollection();
var b = _this.intervals;
b.collectionChanged = delegateCombine(b.collectionChanged, runOn(_this, _this.o6));
_this.n2 = new TimeAxisLabelFormatCollection();
var c = _this.labelFormats;
c.collectionChanged = delegateCombine(c.collectionChanged, runOn(_this, _this.o7));
_this.o2 = (0);
return _this;
}
TimeXAxis.prototype.get_cl = function () {
return this.breaks != null && this.breaks.count > 0;
};
TimeXAxis.prototype.el = function (a, b) {
if (!b.c.isEmpty) {
var c = this.oj(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.oj(a, b.e, b.d, b.c);
};
TimeXAxis.prototype.oj = function (a, b, c, d) {
var e = new KeyValuePair$2(TimeAxisBreak.$, Number_$type);
var f = this.ol != -2147483648 ? this.ol : 0;
var g = this.nt != null ? this.nt.count : 0;
while (f < g) {
var h = this.nt.item1(f);
if (h.d.getTime() <= a && h.c.getTime() >= a) {
return NaN;
}
if (h.c.getTime() <= a) {
e = new KeyValuePair$2(TimeAxisBreak.$, Number_$type, 1, h, this.nt.item(h));
f++;
}
else {
break;
}
}
if (f > 0) {
f -= 1;
}
if (this.ol != -2147483648) {
this.ol = f;
}
var i;
var j;
if (e.key != null) {
i = e.value;
j = e.key.c;
}
else {
i = 0;
j = this.actualMinimumValue;
}
var fromPrecedingBreak_ = +(dateFromTicks(truncate(a))) - +j;
var k = (fromPrecedingBreak_ / ((this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime()) - this.omission));
var l = i + k;
l -= b.left;
l /= b.width;
var m = c.left;
var n = c.right;
var o = c.width;
if (this.categoryMode != 0) {
var p = this.getCategorySize(b, c, d);
m += p / 2;
n -= p / 2;
o -= p;
}
if (this.ch) {
return n - o * l;
}
return m + o * l;
};
TimeXAxis.prototype.hq = function (a, b, c, d) {
this.ol = 0;
for (var e = b; e < c; e++) {
a.item(e, this.el(a.item(e), d));
}
this.ol = -2147483648;
};
TimeXAxis.prototype.startCursor = function () {
this.ol = 0;
};
TimeXAxis.prototype.resetCursor = function () {
this.ol = -2147483648;
};
TimeXAxis.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.getUnscaledValue3(c, NumericScaler.ac, b.c, this.categoryMode);
return c;
}
return this.ok(a, b.e, b.d, b.c);
};
TimeXAxis.prototype.ok = function (a, b, c, d) {
var e_1, _a;
var e = c.left;
var f = c.width;
if (this.categoryMode != 0) {
var g = this.getCategorySize(b, c, d);
e += g / 2;
f -= g;
}
var h = b.left + b.width * (a - e) / f;
if (this.ch) {
h = 1 - h;
}
var i = new KeyValuePair$2(TimeAxisBreak.$, Number_$type);
if (this.nt != null) {
try {
for (var _b = __values(fromEnum(this.nt)), _c = _b.next(); !_c.done; _c = _b.next()) {
var j = _c.value;
if (j.value >= h && j.value <= h) {
return j.key.d.getTime();
}
if (j.value < h && j.value > i.value) {
i = j;
}
}
}
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;
}
}
}
var precedingBreakEnd_;
var k;
if (i.key != null) {
k = i.value;
precedingBreakEnd_ = i.key.c;
}
else {
k = 0;
precedingBreakEnd_ = this.actualMinimumValue;
}
var portionFromPrecedingBreak_ = h - k;
var actualRange_ = +(this.actualMaximumValue) - +(this.actualMinimumValue) - this.omission;
return (precedingBreakEnd_.getTime() + portionFromPrecedingBreak_ * actualRange_);
};
Object.defineProperty(TimeXAxis.prototype, "breaks", {
get: function () {
return this.nv;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "n5", {
get: function () {
return this.n4;
},
set: function (a) {
var b = this.n5;
if (a != b) {
this.n4 = a;
this.h5("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.n5));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "labelFormats", {
get: function () {
return this.n2;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.hz = function (a, b, c, d) {
_super.prototype.hz.call(this, a, b, c, d);
switch (b) {
case "ActualMaximumValue":
this.o4();
break;
case "DateTimeColumn":
this.o0 = this.oy();
break;
case "LabellingMode":
this.ib(false);
break;
}
};
TimeXAxis.prototype.it = function (a, b) {
_super.prototype.it.call(this, a, b);
this.o3();
this.nn();
};
TimeXAxis.prototype.is = function (a, b) {
_super.prototype.is.call(this, a, b);
this.o3();
this.nn();
};
TimeXAxis.prototype.c3 = function () {
var a = _super.prototype.c3.call(this);
this.o3();
return a;
};
Object.defineProperty(TimeXAxis.prototype, "omission", {
get: function () {
return this._omission;
},
set: function (a) {
this._omission = a;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.o4 = function () {
var e_2, _a;
var a = this.n8(this.breaks);
var b = (0);
try {
for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
b += (+(c.c) - +(c.d));
}
}
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;
}
}
this.omission = b;
};
TimeXAxis.prototype.n8 = function (a) {
var e_3, _a;
var b = new List$1(TimeAxisBreak.$, 0);
if (a == null || +(this.actualMaximumValue) == +(dateMaxValue())) {
return b;
}
var _loop_1 = function (c) {
if (c.c >= this_1.actualMinimumValue && c.d <= this_1.actualMaximumValue) {
b.add(c);
}
if (c.i != (0)) {
var d = +(c.c) - +(c.d);
var e_4 = this_1.oe(c.d, c.i);
var _loop_2 = function () {
var f = this_1.oe(e_4, d);
var g = ((function () {
var $ret = new TimeAxisBreak();
$ret.d = e_4;
$ret.c = f;
return $ret;
})());
if (g.c >= this_1.actualMinimumValue && g.d <= this_1.actualMaximumValue) {
b.add(g);
}
if (dateSubtract(+(dateMaxValue()), +(c.i)) < g.d) {
return "break";
}
e_4 = this_1.oe(g.d, c.i);
};
while (e_4 <= this_1.actualMaximumValue) {
var state_1 = _loop_2();
if (state_1 === "break")
break;
}
}
};
var this_1 = this;
try {
for (var _b = __values(fromEn(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
_loop_1(c);
}
}
catch (e_3_1) {
e_3 = { error: e_3_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_3)
throw e_3.error;
}
}
return b;
};
TimeXAxis.prototype.oe = function (a, b) {
var c = dateFromTicks(a.getTime());
c.setMilliseconds(c.getMilliseconds() + b);
return c;
};
TimeXAxis.prototype.o3 = function () {
var e_5, _a;
this.nt = new OrderedDictionary$2(TimeAxisBreak.$, Number_$type);
if (+(this.actualMaximumValue) == +(dateMaxValue()) || this.breaks == null || this.breaks.count == 0 || this.bi == null) {
return;
}
var a = new List$1(TimeAxisBreak.$, 1, this.n8(this.breaks));
a.aa(function (b, c) { return b.d < c.d ? -1 : b.d > c.d ? 1 : 0; });
var b = this.bi.v4;
var c = new ScalerParams(0, this.bi.v4, this.bi.wk, this.ch, this.bi.v8);
var d = +(this.actualMaximumValue) - +(this.actualMinimumValue) - this.omission;
var e = 0;
try {
for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
var f = _c.value;
var g = timeSpanTicks((+(f.d) - +(this.actualMinimumValue))) / timeSpanTicks(d);
var h = timeSpanTicks((+(f.c) - +(this.actualMinimumValue))) / timeSpanTicks(d);
if (h < 0 || g - e > 1) {
continue;
}
this.nt.addItem(f, g - e);
e += (h - g);
}
}
catch (e_5_1) {
e_5 = { error: e_5_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_5)
throw e_5.error;
}
}
};
TimeXAxis.prototype.gf = function (a) {
if (isNaN_(a)) {
return null;
}
var ticks_ = truncate(a);
var b = (new Date(ticks_));
var c = this.f1(b);
if (c == null) {
return null;
}
return c.toString();
};
TimeXAxis.prototype.f1 = function (a) {
if (!(typeCast(Date_$type, a) !== null)) {
return _super.prototype.f1.call(this, a);
}
var b = dateMinValue();
var c = false;
if (this.op != null) {
if (typeCast(Date_$type, this.op) !== null) {
b = this.op;
c = true;
}
}
var d = TimeXAxis.oo(a, c, b, this.n5, this.o2, this.labelFormats, this.fm);
return d == null ? _super.prototype.f1.call(this, a) : d;
};
TimeXAxis.oo = function (a, b, c, d, e, f, g) {
var h = TimeXAxis.ot(a, b, c, d, e, f, g);
return dateToStringFormat(a, h, g);
};
TimeXAxis.ot = function (a, b, c, d, e, f, g) {
var e_6, _a;
var h = 0;
if (b) {
h = TimeXAxis.n6(a, c);
}
var i = null;
var j;
if (f == null || f.count == 0) {
j = TimeXAxis.os(e, h, d);
}
else {
var k = Number.MAX_VALUE;
var l = null;
try {
for (var _b = __values(fromEnum(f)), _c = _b.next(); !_c.done; _c = _b.next()) {
var m = _c.value;
if (m.o < k) {
k = m.o;
l = m;
}
if (m.o > e) {
continue;
}
if (i == null || m.o > i.o) {
i = m;
}
}
}
catch (e_6_1) {
e_6 = { error: e_6_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_6)
throw e_6.error;
}
}
if (i == null) {
i = l;
}
if (i == null) {
return null;
}
switch (h) {
case 3:
if (i.h != null) {
j = i.h;
}
else if (i.j != null) {
j = i.j;
}
else if (i.l != null) {
j = i.l;
}
else {
j = i.e;
}
break;
case 2:
if (i.j != null) {
j = i.j;
}
else if (i.l != null) {
j = i.l;
}
else {
j = i.e;
}
break;
case 1:
if (i.l != null) {
j = i.l;
}
else {
j = i.e;
}
break;
default:
j = i.e;
break;
}
}
return j;
};
TimeXAxis.n6 = function (a, b) {
if (a.getFullYear() == b.getFullYear() && dateGetMonth(a) == dateGetMonth(b) && a.getDate() == b.getDate()) {
return 3;
}
else if (a.getFullYear() == b.getFullYear() && dateGetMonth(a) == dateGetMonth(b)) {
return 2;
}
else if (a.getFullYear() == b.getFullYear()) {
return 1;
}
return 0;
};
TimeXAxis.prototype.get_mq = function () {
return _super.prototype.get_mq.call(this) || (this.intervals != null && this.intervals.count > 0);
};
TimeXAxis.prototype.set_mq = function (a) {
_super.prototype.set_mq.call(this, a);
};
Object.defineProperty(TimeXAxis.prototype, "intervals", {
get: function () {
return this.n0;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.or = function (a, b) {
return TimeXAxis.os(this.o2, a, b);
};
TimeXAxis.os = function (a, b, c) {
if (c != 2) {
b = 0;
}
a = Math.abs(a);
if (a > timeSpanInit3(1825, 0, 0, 0)) {
return "yyyy";
}
if (a > timeSpanInit3(365, 0, 0, 0)) {
switch (b) {
case 3:
case 2:
case 1: return "MMM";
}
return "MMM yyyy";
}
;
if (a > timeSpanInit3(4, 0, 0, 0)) {
switch (b) {
case 3:
case 2: return "dd";
}
return "MMM dd";
}
;
if (a > timeSpanInit3(1, 0, 0, 0)) {
switch (b) {
case 3: return "hh:mmtt";
case 2: return "dd hh:mmtt";
}
return "MMM dd hh:mmtt";
}
;
if (a > timeSpanInit1(0, 10, 0)) {
return "hh:mm";
}
return "hh:mm:ss";
};
TimeXAxis.nu = function () {
if (TimeXAxis.ns == null) {
TimeXAxis.ns = ((function () {
var $ret = new OrderedDictionary$2(Number_$type, TimeAxisInterval.$);
$ret.addItem((0), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 0;
$ret.f = 1;
return $ret;
})()));
$ret.addItem(timeSpanFromMilliseconds(1), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 1;
$ret.f = 1;
return $ret;
})()));
$ret.addItem(timeSpanFromSeconds(1), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 2;
$ret.f = 1;
return $ret;
})()));
$ret.addItem(timeSpanFromSeconds(30), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 2;
$ret.f = 30;
return $ret;
})()));
$ret.addItem(timeSpanFromMinutes(2), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 3;
$ret.f = 2;
return $ret;
})()));
$ret.addItem(timeSpanFromMinutes(5), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 3;
$ret.f = 5;
return $ret;
})()));
$ret.addItem(timeSpanFromHours(1), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 4;
$ret.f = 1;
return $ret;
})()));
$ret.addItem(timeSpanFromDays(1), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 5;
$ret.f = 1;
return $ret;
})()));
$ret.addItem(timeSpanFromDays(2), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 5;
$ret.f = 2;
return $ret;
})()));
$ret.addItem(timeSpanFromDays(5), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 5;
$ret.f = 5;
return $ret;
})()));
$ret.addItem(timeSpanFromDays(10), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 5;
$ret.f = 10;
return $ret;
})()));
$ret.addItem(timeSpanFromDays(30), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 7;
$ret.f = 1;
return $ret;
})()));
$ret.addItem(timeSpanFromDays(60), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 7;
$ret.f = 3;
return $ret;
})()));
$ret.addItem(timeSpanFromDays(365), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 8;
$ret.f = 1;
return $ret;
})()));
$ret.addItem(timeSpanFromDays(365 * 10), ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 8;
$ret.f = 10;
return $ret;
})()));
return $ret;
})());
}
return TimeXAxis.ns;
};
TimeXAxis.prototype.ny = function () {
var e_7, _a;
if (this.c4 && (this.az == null || this.az.angle == 0)) {
var a = this.ez();
var b = this.kh.width;
var c = truncate(Math.floor(b / a));
var d = Number.MAX_VALUE;
var e = c == 0 ? d : timeSpanFromTicks((intDivide(timeSpanTicks(this.o2), c)));
var f = null;
try {
for (var _b = __values(fromEnum(TimeXAxis.nu())), _c = _b.next(); !_c.done; _c = _b.next()) {
var g = _c.value;
f = g.value;
if (g.key > e) {
break;
}
}
}
catch (e_7_1) {
e_7 = { error: e_7_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_7)
throw e_7.error;
}
}
var h = this.nx;
if (h != f) {
this.ih();
}
this.nx = f;
return f;
}
var i = this.o2;
if (i == (0)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 8;
$ret.f = 1;
return $ret;
})());
}
if (i >= timeSpanFromDays(365 * 100)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 8;
$ret.f = 10;
return $ret;
})());
}
if (i >= timeSpanFromDays(365 * 5)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 8;
$ret.f = 1;
return $ret;
})());
}
if (i >= timeSpanFromDays(365 * 2)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 7;
$ret.f = 3;
return $ret;
})());
}
if (i >= timeSpanFromDays(150)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 7;
$ret.f = 1;
return $ret;
})());
}
if (i >= timeSpanFromDays(60)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 5;
$ret.f = 10;
return $ret;
})());
}
if (i >= timeSpanFromDays(30)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 5;
$ret.f = 5;
return $ret;
})());
}
if (i >= timeSpanFromDays(20)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 5;
$ret.f = 2;
return $ret;
})());
}
if (i >= timeSpanFromDays(4)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 5;
$ret.f = 1;
return $ret;
})());
}
if (i >= timeSpanFromDays(1)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 4;
$ret.f = 12;
return $ret;
})());
}
if (i >= timeSpanFromHours(6)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 4;
$ret.f = 1;
return $ret;
})());
}
if (i >= timeSpanFromMinutes(30)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 3;
$ret.f = 5;
return $ret;
})());
}
if (i >= timeSpanFromMinutes(10)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 3;
$ret.f = 2;
return $ret;
})());
}
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 2;
$ret.f = 30;
return $ret;
})());
};
TimeXAxis.prototype.nz = function () {
var e_8, _a;
if (this.intervals == null || this.intervals.count == 0) {
return this.ny();
}
if (this.o2 == (0)) {
return ((function () {
var $ret = new TimeAxisInterval();
$ret.b = 8;
$ret.f = 1;
return $ret;
})());
}
var a = null;
try {
for (var _b = __values(fromEnum(this.intervals)), _c = _b.next(); !_c.done; _c = _b.next()) {
var b = _c.value;
if (b.k > this.o2) {
continue;
}
if (a == null || b.k > a.k) {
a = b;
}
}
}
catch (e_8_1) {
e_8 = { error: e_8_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_8)
throw e_8.error;
}
}
return a == null ? this.ny() : a;
};
TimeXAxis.prototype.ic = function (a) {
_super.prototype.ic.call(this, a);
var b = this.bi != null ? this.bi.v4 : Rect.empty;
var c = !b.isEmpty ? this.kh : Rect.empty;
var d = this.kc();
var e = this.kb();
var f = new ScalerParams(0, b, c, this.ch, d);
if (this.mm == null && !this.ms() && !this.mt()) {
return;
}
if (!b.isEmpty && !c.isEmpty) {
var g = c.bottom;
var h = g - c.top;
if (this.aj != null) {
var i = typeCast(NumericYAxis.$, this.aj);
if (i != null) {
var j = this.ii(g, h, b, c, d, c.top, c.bottom);
g = j.p0;
h = j.p1;
}
}
if (isNaN_(g)) {
g = 0;
}
this.ht(this.a5.a4(), g, c, this.a5.e(), true);
this.aw.bg = h;
var k = truncate(Math.ceil(e.right));
var l = truncate(Math.floor(e.left));
var m = this.a5.a7();
var n = this.a5.f();
var o = this.a5.a5();
this.nn();
var p = new List$1(Date_$type, 1, this.n7());
var q = new List$1(Number_$type, 0);
for (var r = 0; r < p.count; r++) {
q.add(p._inner[r].getTime());
}
this.hq(q, 0, q.count, f);
this.op = null;
for (var s = 0; s < p.count; s++) {
var t = p._inner[s];
var u = q._inner[s];
var v = truncate(Math.round(u));
if (v <= k) {
if (s % 2 == 0) {
var w = s < q.count - 1 ? q._inner[s + 1] : e.right;
this.ir(m, u, w, c);
}
this.iq(o, u, c, n, false);
this.k2.add(u);
}
if (v >= l && v <= k) {
var x = this.f1(t);
this.op = t;
if (x != null) {
this.dd.add1(x);
this.de.add(new LabelPosition(u));
}
}
}
this.op = null;
}
if ((this.az == null || this.az.visibility == 0) && this.aj != null) {
if (this.az != null && (this.az.location == 4 || this.az.location == 5)) {
this.bi.n3();
}
}
this.aw.a9 = this.dd;
this.aw.ba = this.de;
this.aw.cl();
this.l9();
};
TimeXAxis.prototype.n7 = function () {
var a = this.bi != null ? this.bi.v4 : Rect.empty;
var b = !a.isEmpty ? this.kh : Rect.empty;
var c = this.kc();
var d = this.kb();
var e = new ScalerParams(0, a, b, this.ch, c);
var f = this.nz();
var g = this.og;
if (!this.mt() && f != null) {
if (f.b == 7 && g.getDate() != 1) {
g = dateAddMonths(g, 1);
g = dateFromValues(g.getFullYear(), dateGetMonth(g), 1, 0, 0, 0, 0);
}
else if (f.b == 5 && dateGetTimeOfDay(g) != (0)) {
g = dateAddDays(g, 1);
g = dateFromValues(g.getFullYear(), dateGetMonth(g), g.getDate(), 0, 0, 0, 0);
}
else if (f.b == 4 && g.getMinutes() != 0) {
g = dateAddHours(g, 1);
g = dateFromValues(g.getFullYear(), dateGetMonth(g), g.getDate(), g.getHours(), 0, 0, 0);
}
}
var h = new List$1(Date_$type, 0);
var i = 0;
var j = 10000;
if (f.f == 0) {
return h;
}
while (g <= this.visibleMaximum && i++ < j) {
var k = this.n9(g);
var l = g;
if (k.key != null) {
l = f.d(k.key.c);
}
h.add(l);
while (g <= l) {
g = f.c(g);
}
}
return h;
};
TimeXAxis.prototype.n9 = function (a) {
var e_9, _a;
if (this.nt == null) {
return new KeyValuePair$2(TimeAxisBreak.$, Number_$type);
}
try {
for (var _b = __values(fromEnum(this.nt)), _c = _b.next(); !_c.done; _c = _b.next()) {
var b = _c.value;
if (b.key.d <= a && b.key.c >= a) {
return b;
}
}
}
catch (e_9_1) {
e_9 = { error: e_9_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_9)
throw e_9.error;
}
}
return new KeyValuePair$2(TimeAxisBreak.$, Number_$type);
};
Object.defineProperty(TimeXAxis.prototype, "visibleMinimum", {
get: function () {
return this.od;
},
set: function (a) {
this.od = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "og", {
get: function () {
return this.ob;
},
set: function (a) {
this.ob = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "of", {
get: function () {
return this.oa;
},
set: function (a) {
this.oa = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "visibleMaximum", {
get: function () {
return this.oc;
},
set: function (a) {
this.oc = a;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.nn = function () {
_super.prototype.nn.call(this);
if (this.bi == null || !Extensions.b(this.bi.wk)) {
return;
}
var a = new ScalerParams(0, this.bi.v4, this.bi.wk, this.ch, this.bi.v8);
var b = this.kb();
var c = b.left;
var d = b.right;
var e = b.left;
var f = b.right;
if (this.categoryMode != 0) {
var g = this.getCategorySize(a.e, a.d, a.c);
e += g / 2;
f -= g / 2;
}
var h = truncate(this.eo(c, a));
var i = truncate(this.eo(d, a));
var j = truncate(this.eo(e, a));
var k = truncate(this.eo(f, a));
if (j < 0 || k < 0) {
this.o2 = (0);
return;
}
h = Math.min(dateMaxValue().getTime(), h);
i = Math.min(dateMaxValue().getTime(), i);
h = Math.max(dateMinValue().getTime(), h);
i = Math.max(dateMinValue().getTime(), i);
j = Math.min(dateMaxValue().getTime(), j);
k = Math.min(dateMaxValue().getTime(), k);
var l = dateFromTicks(Math.min(h, i));
var m = dateFromTicks(Math.max(h, i));
var n = dateFromTicks(Math.min(j, k));
var o = dateFromTicks(Math.max(j, k));
var p = +(this.visibleMinimum) != +n || +(this.visibleMaximum) != +o;
this.visibleMinimum = n;
this.visibleMaximum = o;
this.og = l;
this.of = m;
if (p && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
this.o2 = +(this.visibleMaximum) - +(this.visibleMinimum);
};
TimeXAxis.prototype.la = function (a, b, c, d, e) {
return 0;
};
TimeXAxis.prototype.i$f = function (a) {
var b = this;
if (b.i$b == null || b.i$b.count == 0) {
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);
e = Math.max(0, Math.min(b.i$b.count - 1, e));
var f = c.item(e);
var g;
var h;
if (f < d) {
g = e;
h = g + 1;
}
else {
h = e;
g = e - 1;
}
g = this.on(g, c);
h = this.om(h, c);
if (g < 0) {
return h;
}
if (h >= b.i$b.count) {
return g;
}
var i = c.item(g);
var j = c.item(h);
var k = new ScalerParams(0, this.bi.wl, this.kh, this.ch, this.bi.v8);
this.startCursor();
var l = this.el(i.getTime(), k);
var m = this.el(a, k);
var n = this.el(j.getTime(), k);
this.resetCursor();
if (i < this.og && j <= this.of) {
return this.mv._inner[h];
}
if (j > this.of && i >= this.og) {
return this.mv._inner[g];
}
if (Math.abs(l - m) < Math.abs(n - m)) {
return this.mv._inner[g];
}
else {
return this.mv._inner[h];
}
};
TimeXAxis.prototype.om = function (a, b) {
if (a < 0 || a >= b.count - 1) {
return a;
}
var c = b.item(a);
var d = 0;
while (d < this.nt.count) {
var e = this.nt.item1(d);
if (c >= e.d && c <= e.c) {
break;
}
d++;
}
if (d >= this.nt.count) {
return a;
}
var f = a;
while (f < b.count) {
if (f < 0 || f >= b.count - 1) {
return a;
}
c = b.item(f);
var g = this.nt.item1(d);
if (c >= g.d && c <= g.c) {
f++;
continue;
}
d++;
if (d > this.nt.count - 1) {
break;
}
g = this.nt.item1(d);
if (c >= g.d && c <= g.c) {
f++;
continue;
}
break;
}
if (f < 0 || f > b.count - 1) {
return a;
}
return f;
};
TimeXAxis.prototype.on = function (a, b) {
if (a < 0 || a >= b.count - 1) {
return a;
}
var c = b.item(a);
var d = 0;
while (d < this.nt.count) {
var e = this.nt.item1(d);
if (c >= e.d && c <= e.c) {
break;
}
d++;
}
if (d >= this.nt.count) {
return a;
}
var f = a;
while (f >= 0) {
if (f < 0 || f >= b.count - 1) {
return a;
}
c = b.item(f);
var g = this.nt.item1(d);
if (c >= g.d && c <= g.c) {
f--;
continue;
}
d--;
if (d < 0) {
break;
}
g = this.nt.item1(d);
if (c >= g.d && c <= g.c) {
f--;
continue;
}
break;
}
if (f < 0 || f > b.count - 1) {
return a;
}
return f;
};
TimeXAxis.prototype.o5 = function (a, b) {
var e_10, _a;
this.o4();
this.o3();
if (this.aw != null) {
this.aw.al = this.breaks.count > 0;
}
this.ib(false);
try {
for (var _b = __values(fromEnum(this.db())), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
c.rq(false);
}
}
catch (e_10_1) {
e_10 = { error: e_10_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_10)
throw e_10.error;
}
}
};
TimeXAxis.prototype.o7 = function (a, b) {
this.ib(false);
};
TimeXAxis.prototype.o6 = function (a, b) {
this.ib(false);
};
TimeXAxis.prototype.get_cc = function () {
return false;
};
TimeXAxis.prototype.getWindowRectForSelection = function (a, b) {
var c = +(this.actualMaximumValue) - +(this.actualMinimumValue);
var d = timeSpanTotalMilliseconds((+a - +(this.actualMinimumValue))) / timeSpanTotalMilliseconds(c);
var e = 1 - (timeSpanTotalMilliseconds((+(this.actualMaximumValue) - +b)) / timeSpanTotalMilliseconds(c));
e = Math.min(1, e);
return new Rect(0, d, NaN, Math.max(0, e - d), NaN);
};
TimeXAxis.prototype.getCategorySize = function (a, b, c) {
if (this.o2 != (0)) {
var d = timeSpanFromTicks(truncate((timeSpanTicks(this.o2) * (a.width / (this.bi != null ? this.bi.v4.width : 1)))));
var e = timeSpanTicks(d) / timeSpanTicks(this.o0);
var f = b.width / 4;
return Math.min(f, b.width / (e + 1));
}
return _super.prototype.getCategorySize.call(this, a, b, c);
};
TimeXAxis.oz = function (a, b) {
var c = Math.min(5, b);
var d = a(0);
var e = new Dictionary$2(Number_$type, Number_$type, 0);
var f = 0;
var g = (0);
for (var h = 0; h < c; h++) {
var i = a(h);
var j = +i - +d;
if (!e.containsKey(j)) {
e.addItem(j, 0);
}
e.item(j, e.item(j) + 1);
if (e.item(j) > f) {
f = e.item(j);
g = j;
}
d = i;
}
return g;
};
TimeXAxis.prototype.oy = function () {
var _this = this;
if (this.mm == null || this.mm.count < 2 || this.mv == null) {
return (0);
}
return TimeXAxis.oz(function (a) { return _this.mm.item(_this.mv._inner[a]); }, this.mm.count);
};
TimeXAxis.prototype.nj = function () {
_super.prototype.nj.call(this);
this.o0 = this.oy();
};
TimeXAxis.ov = function (a) {
if (a >= timeSpanFromDays(1)) {
return "D";
}
return "g";
};
TimeXAxis.prototype.itemLabelFormat = function () {
return TimeXAxis.ov(this.o0);
};
TimeXAxis.prototype.m5 = function (a, b, c, d) {
return this.m4(this.visibleMinimum);
};
TimeXAxis.prototype.m8 = function (a, b, c, d) {
return this.m7(this.visibleMaximum);
};
Object.defineProperty(TimeXAxis.prototype, "isVertical", {
get: function () {
return this.cp;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.j$d = function (a, b) {
return this.eo.apply(this, arguments);
};
TimeXAxis.prototype.j$c = function (a, b) {
return this.el.apply(this, arguments);
};
TimeXAxis.prototype.j$e = function (a, b, c, d, e) {
this.hp.apply(this, arguments);
};
TimeXAxis.prototype.j$f = function (a, b, c, d) {
this.hq.apply(this, arguments);
};
TimeXAxis.prototype.j$g = function (a, b, c, d) {
this.hr.apply(this, arguments);
};
Object.defineProperty(TimeXAxis.prototype, "j$b", {
get: function () {
return this.ch;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.j$a = function () {
return this.ag.apply(this, arguments);
};
Object.defineProperty(TimeXAxis.prototype, "i$a", {
get: function () {
return this.ce;
},
enumerable: false,
configurable: true
});
TimeXAxis.$t = markType(TimeXAxis, 'TimeXAxis', TimeAxisBase.$, [ITimeRangeSelectorAxis_$type]);
TimeXAxis.ns = null;
return TimeXAxis;
}(TimeAxisBase));
export { TimeXAxis };