igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
1,427 lines (1,426 loc) • 46.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, __values } from "tslib";
import { TimeAxisBase } from "./TimeAxisBase";
import { ITimeRangeSelectorAxis_$type } from "./ITimeRangeSelectorAxis";
import { List$1 } from "igniteui-react-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, typeCast, Number_$type, fromEnum, enumGetBox, fromEn, Date_$type, markType } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-react-core";
import { NumericScaler } from "./NumericScaler";
import { KeyValuePair$2 } from "igniteui-react-core";
import { LabelFormatOverrideEventArgs } from "./LabelFormatOverrideEventArgs";
import { NumericYAxis } from "./NumericYAxis";
import { LabelPosition } from "./LabelPosition";
import { Extensions } from "igniteui-react-core";
import { SortedListView$1 } from "./SortedListView$1";
import { Dictionary$2 } from "igniteui-react-core";
import { truncate, intDivide, isNaN_ } from "igniteui-react-core";
import { dateFromTicks, dateMaxValue, dateSubtract, dateMinValue, dateGetMonth, dateAddMonths, dateFromValues, dateGetTimeOfDay, dateAddDays, dateAddHours } from "igniteui-react-core";
import { timeSpanTicks, timeSpanInit3, timeSpanInit1, timeSpanFromMilliseconds, timeSpanFromSeconds, timeSpanFromMinutes, timeSpanFromHours, timeSpanFromDays, timeSpanFromTicks, timeSpanTotalMilliseconds } from "igniteui-react-core";
import { dateToStringFormat } from "igniteui-react-core";
/**
* @hidden
*/
var TimeXAxis = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TimeXAxis, _super);
function TimeXAxis() {
var _this = _super.call(this) || this;
_this.tf = 0;
_this.so = null;
_this.sy = 0;
_this.sw = null;
_this._omission = 0;
_this.sm = null;
_this.st = null;
_this.tj = null;
_this.tw = 0;
_this.s7 = dateMaxValue();
_this.s5 = dateMaxValue();
_this.s4 = dateMaxValue();
_this.s6 = dateMinValue();
_this.sq = null;
_this.tu = 0;
_this.visibleRangeChanged = null;
_this.ab = TimeXAxis.$;
_this.omission = (0);
_this.tf = -2147483648;
_this.so = new TimeAxisBreakCollection();
var a = _this.breaks;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.tz));
_this.st = new TimeAxisIntervalCollection();
var b = _this.intervals;
b.collectionChanged = delegateCombine(b.collectionChanged, runOn(_this, _this.t0));
_this.sw = new TimeAxisLabelFormatCollection();
var c = _this.labelFormats;
c.collectionChanged = delegateCombine(c.collectionChanged, runOn(_this, _this.t1));
_this.tw = (0);
return _this;
}
TimeXAxis.prototype.al = function () {
return new TimeXAxis();
};
TimeXAxis.prototype.ko = function (a) {
_super.prototype.ko.call(this, a);
this.kr(a, "LabellingMode");
};
TimeXAxis.prototype.kr = function (a, b) {
_super.prototype.kr.call(this, a, b);
var c = typeCast(TimeXAxis.$, a);
if (c == null) {
return;
}
if (b == "LabellingMode") {
c.sz = this.sz;
}
};
TimeXAxis.prototype.get_ds = function () {
return this.breaks != null && this.breaks.count > 0;
};
TimeXAxis.prototype.f7 = function (a, b) {
if (!b.c.isEmpty) {
var c = this.td(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.td(a, b.e, b.d, b.c);
};
TimeXAxis.prototype.td = function (a, b, c, d) {
var e = new KeyValuePair$2(TimeAxisBreak.$, Number_$type, 1, null, 0);
var f = this.tf != -2147483648 ? this.tf : 0;
var g = this.sm != null ? this.sm.count : 0;
while (f < g) {
var h = this.sm.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.sm.item(h));
f++;
}
else {
break;
}
}
if (f > 0) {
f -= 1;
}
if (this.tf != -2147483648) {
this.tf = 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.dn) {
return n - o * l;
}
return m + o * l;
};
TimeXAxis.prototype.k3 = function (a, b, c, d) {
this.tf = 0;
for (var e = b; e < c; e++) {
a.item(e, this.f7(a.item(e), d));
}
this.tf = -2147483648;
};
TimeXAxis.prototype.startCursor = function () {
this.tf = 0;
};
TimeXAxis.prototype.resetCursor = function () {
this.tf = -2147483648;
};
TimeXAxis.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.getUnscaledValue3(c, NumericScaler.ac, b.c, this.categoryMode);
return c;
}
return this.te(a, b.e, b.d, b.c);
};
TimeXAxis.prototype.te = 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.dn) {
h = 1 - h;
}
var i = new KeyValuePair$2(TimeAxisBreak.$, Number_$type, 1, null, 0);
if (this.sm != null) {
try {
for (var _b = __values(fromEnum(this.sm)), _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.so;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "sz", {
get: function () {
return this.sy;
},
set: function (a) {
var b = this.sz;
if (a != b) {
this.sy = a;
this.lu("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.sz));
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "labelFormats", {
get: function () {
return this.sw;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.lc = function (a, b, c, d) {
_super.prototype.lc.call(this, a, b, c, d);
switch (b) {
case "ActualMaximumValue":
this.ty();
break;
case "DateTimeColumn":
this.tu = this.ts();
break;
case "LabellingMode":
this.l0(false);
break;
}
};
TimeXAxis.prototype.mg = function (a, b) {
_super.prototype.mg.call(this, a, b);
this.tx();
this.sg();
};
TimeXAxis.prototype.mf = function (a, b) {
_super.prototype.mf.call(this, a, b);
this.tx();
this.sg();
};
TimeXAxis.prototype.eg = function () {
var a = _super.prototype.eg.call(this);
this.tx();
return a;
};
Object.defineProperty(TimeXAxis.prototype, "omission", {
get: function () {
return this._omission;
},
set: function (a) {
this._omission = a;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.ty = function () {
var e_2, _a;
var a = this.s2(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.s2 = 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.s8(c.d, c.i);
var _loop_2 = function () {
var f = this_1.s8(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.s8(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.s8 = function (a, b) {
var c = dateFromTicks(a.getTime());
c.setMilliseconds(c.getMilliseconds() + b);
return c;
};
TimeXAxis.prototype.tx = function () {
var e_5, _a;
this.sm = new OrderedDictionary$2(TimeAxisBreak.$, Number_$type);
if (+(this.actualMaximumValue) == +(dateMaxValue()) || this.breaks == null || this.breaks.count == 0 || this.b7 == null) {
return;
}
var a = new List$1(TimeAxisBreak.$, 1, this.s2(this.breaks));
a.aa(function (b, c) { return b.d < c.d ? -1 : b.d > c.d ? 1 : 0; });
var b = this.b7.ys;
var c = new ScalerParams(0, this.b7.ys, this.b7.za, this.dn, this.b7.yw);
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.sm.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.ja = function (a) {
if (isNaN_(a)) {
return null;
}
var ticks_ = truncate(a);
var b = (new Date(ticks_));
var c = this.hy(b);
if (c == null) {
return null;
}
return c.toString();
};
TimeXAxis.prototype.hy = function (a) {
if (!(typeCast(Date_$type, a) !== null)) {
return _super.prototype.hy.call(this, a);
}
var b = dateMinValue();
var c = false;
if (this.tj != null) {
if (typeCast(Date_$type, this.tj) !== null) {
b = this.tj;
c = true;
}
}
var d = TimeXAxis.ti(a, c, b, this.sz, this.tw, this.labelFormats, this.hb);
return d == null ? _super.prototype.hy.call(this, a) : d;
};
TimeXAxis.ti = function (a, b, c, d, e, f, g) {
var h = TimeXAxis.sv(e, f, g);
if (h != null) {
var i = ((function () {
var $ret = new LabelFormatOverrideEventArgs();
$ret.dateTime = a;
$ret.format = h;
return $ret;
})());
var j = h.b(h, i);
if (j != null) {
return j;
}
}
var k = TimeXAxis.tn(a, b, c, d, e, f, g);
return dateToStringFormat(a, k, g);
};
TimeXAxis.sv = function (a, b, c) {
var e_6, _a;
var d = null;
var e = Number.MAX_VALUE;
var f = null;
try {
for (var _b = __values(fromEnum(b)), _c = _b.next(); !_c.done; _c = _b.next()) {
var g = _c.value;
if (g.q < e) {
e = g.q;
f = g;
}
if (g.q > a) {
continue;
}
if (d == null || g.q > d.q) {
d = g;
}
}
}
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 (d == null) {
d = f;
}
if (d == null) {
return null;
}
return d;
};
TimeXAxis.tn = function (a, b, c, d, e, f, g) {
var h = 0;
if (b) {
h = TimeXAxis.s0(a, c);
}
var i;
if (f == null || f.count == 0) {
i = TimeXAxis.tm(e, h, d);
}
else {
var j = TimeXAxis.sv(e, f, g);
if (j == null) {
return null;
}
switch (h) {
case 3:
if (j.j != null) {
i = j.j;
}
else if (j.l != null) {
i = j.l;
}
else if (j.n != null) {
i = j.n;
}
else {
i = j.g;
}
break;
case 2:
if (j.l != null) {
i = j.l;
}
else if (j.n != null) {
i = j.n;
}
else {
i = j.g;
}
break;
case 1:
if (j.n != null) {
i = j.n;
}
else {
i = j.g;
}
break;
default:
i = j.g;
break;
}
}
return i;
};
TimeXAxis.s0 = 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_rj = function () {
return _super.prototype.get_rj.call(this) || (this.intervals != null && this.intervals.count > 0);
};
TimeXAxis.prototype.set_rj = function (a) {
_super.prototype.set_rj.call(this, a);
};
Object.defineProperty(TimeXAxis.prototype, "intervals", {
get: function () {
return this.st;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.tl = function (a, b) {
return TimeXAxis.tm(this.tw, a, b);
};
TimeXAxis.tm = 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.sn = function () {
if (TimeXAxis.sl == null) {
TimeXAxis.sl = ((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.sl;
};
TimeXAxis.prototype.sr = function () {
var e_7, _a;
if (this.eh && (this.a4 == null || this.a4.angle == 0)) {
var a = this.gn();
var b = this.o8.width;
var c = truncate(Math.floor(b / a));
var d = Number.MAX_VALUE;
var e = c == 0 ? d : timeSpanFromTicks((intDivide(timeSpanTicks(this.tw), c)));
var f = null;
try {
for (var _b = __values(fromEnum(TimeXAxis.sn())), _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.sq;
if (h != f) {
this.l5();
}
this.sq = f;
return f;
}
var i = this.tw;
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.ss = function () {
var e_8, _a;
if (this.intervals == null || this.intervals.count == 0) {
return this.sr();
}
if (this.tw == (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.tw) {
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.sr() : a;
};
TimeXAxis.prototype.l1 = function (a) {
_super.prototype.l1.call(this, a);
var b = this.b7 != null ? this.b7.ys : Rect.empty;
var c = !b.isEmpty ? this.o8 : Rect.empty;
var d = this.o3();
var e = this.o2();
var f = new ScalerParams(0, b, c, this.dn, d);
if (this.rf == null && !this.rl() && !this.rm()) {
return;
}
if (!b.isEmpty && !c.isEmpty) {
var g = c.bottom;
var h = g - c.top;
if (this.an != null) {
var i = typeCast(NumericYAxis.$, this.an);
if (i != null) {
var j = this.l6(g, h, b, c, d, c.top, c.bottom);
g = j.p0;
h = j.p1;
}
}
if (isNaN_(g)) {
g = 0;
}
this.k6(this.bp.bb(), g, c, this.bp.g(), true);
this.a1.bn = h;
var k = truncate(Math.ceil(e.right));
var l = truncate(Math.floor(e.left));
var m = this.bp.be();
var n = this.bp.h();
var o = this.bp.bc();
this.sg();
var p = new List$1(Date_$type, 1, this.s1());
var q = new List$1(Number_$type, 0);
for (var r = 0; r < p.count; r++) {
q.add(p._inner[r].getTime());
}
this.k3(q, 0, q.count, f);
this.tj = 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.me(m, u, w, c);
}
this.md(o, u, c, n, false);
this.pv.add(u);
}
if (v >= l && v <= k) {
var x = this.hy(t);
this.tj = t;
if (x != null) {
this.er.add1(x);
this.es.add(new LabelPosition(0, u));
}
}
}
this.tj = null;
}
if ((this.a4 == null || this.a4.visibility == 0) && this.an != null) {
if (this.a4 != null && (this.a4.location == 4 || this.a4.location == 5)) {
this.b7.ps();
}
}
this.a1.bg = this.er;
this.a1.bh = this.es;
this.a1.cr();
this.q2();
};
TimeXAxis.prototype.s1 = function () {
var a = this.b7 != null ? this.b7.ys : Rect.empty;
var b = !a.isEmpty ? this.o8 : Rect.empty;
var c = this.o3();
var d = this.o2();
var e = new ScalerParams(0, a, b, this.dn, c);
var f = this.ss();
var g = this.ta;
if (!this.rm() && 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.s3(g);
var l = g;
if (k.key != null) {
l = f.d(k.key.c);
}
h.add(l);
while (g <= l) {
g = f.c(g);
if (+g == +(dateMaxValue())) {
break;
}
}
}
return h;
};
TimeXAxis.prototype.s3 = function (a) {
var e_9, _a;
if (this.sm == null) {
return new KeyValuePair$2(TimeAxisBreak.$, Number_$type);
}
try {
for (var _b = __values(fromEnum(this.sm)), _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.s7;
},
set: function (a) {
this.s7 = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "ta", {
get: function () {
return this.s5;
},
set: function (a) {
this.s5 = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "s9", {
get: function () {
return this.s4;
},
set: function (a) {
this.s4 = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeXAxis.prototype, "visibleMaximum", {
get: function () {
return this.s6;
},
set: function (a) {
this.s6 = a;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.sg = function () {
_super.prototype.sg.call(this);
if (this.b7 == null || !Extensions.b(this.b7.za)) {
return;
}
var a = new ScalerParams(0, this.b7.ys, this.b7.za, this.dn, this.b7.yw);
var b = this.o2();
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.ga(c, a));
var i = truncate(this.ga(d, a));
var j = truncate(this.ga(e, a));
var k = truncate(this.ga(f, a));
if (j < 0 || k < 0) {
this.tw = (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.ta = l;
this.s9 = m;
if (p && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
this.tw = +(this.visibleMaximum) - +(this.visibleMinimum);
};
TimeXAxis.prototype.p3 = 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.rf, b.i$b);
var ticks_ = a;
var d = (new Date(ticks_));
var e = this.rz(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.th(g, c);
h = this.tg(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.b7.zb, this.o8, this.dn, this.b7.yw);
this.startCursor();
var l = this.f7(i.getTime(), k);
var m = this.f7(a, k);
var n = this.f7(j.getTime(), k);
this.resetCursor();
if (i < this.ta && j <= this.s9) {
return this.ro._inner[h];
}
if (j > this.s9 && i >= this.ta) {
return this.ro._inner[g];
}
if (Math.abs(l - m) < Math.abs(n - m)) {
return this.ro._inner[g];
}
else {
return this.ro._inner[h];
}
};
TimeXAxis.prototype.tg = function (a, b) {
if (a < 0 || a >= b.count - 1) {
return a;
}
var c = b.item(a);
var d = 0;
while (d < this.sm.count) {
var e = this.sm.item1(d);
if (c >= e.d && c <= e.c) {
break;
}
d++;
}
if (d >= this.sm.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.sm.item1(d);
if (c >= g.d && c <= g.c) {
f++;
continue;
}
d++;
if (d > this.sm.count - 1) {
break;
}
g = this.sm.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.th = function (a, b) {
if (a < 0 || a >= b.count - 1) {
return a;
}
var c = b.item(a);
var d = 0;
while (d < this.sm.count) {
var e = this.sm.item1(d);
if (c >= e.d && c <= e.c) {
break;
}
d++;
}
if (d >= this.sm.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.sm.item1(d);
if (c >= g.d && c <= g.c) {
f--;
continue;
}
d--;
if (d < 0) {
break;
}
g = this.sm.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.tz = function (a, b) {
var e_10, _a;
this.ty();
this.tx();
if (this.a1 != null) {
this.a1.an = this.breaks.count > 0;
}
this.l0(false);
try {
for (var _b = __values(fromEnum(this.ep())), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
c.r9(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.t1 = function (a, b) {
this.l0(false);
};
TimeXAxis.prototype.t0 = function (a, b) {
this.l0(false);
};
TimeXAxis.prototype.get_dg = 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.tw != (0)) {
var d = timeSpanFromTicks(truncate((timeSpanTicks(this.tw) * (a.width / (this.b7 != null ? this.b7.ys.width : 1)))));
var e = timeSpanTicks(d) / timeSpanTicks(this.tu);
var f = b.width / 4;
return Math.min(f, b.width / (e + 1));
}
return _super.prototype.getCategorySize.call(this, a, b, c);
};
TimeXAxis.tt = 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.ts = function () {
var _this = this;
if (this.rf == null || this.rf.count < 2 || this.ro == null) {
return (0);
}
return TimeXAxis.tt(function (a) { return _this.rf.item(_this.ro._inner[a]); }, this.rf.count);
};
TimeXAxis.prototype.sc = function () {
_super.prototype.sc.call(this);
this.tu = this.ts();
};
TimeXAxis.tp = function (a) {
if (a >= timeSpanFromDays(1)) {
return "D";
}
return "g";
};
TimeXAxis.prototype.itemLabelFormat = function () {
return TimeXAxis.tp(this.tu);
};
TimeXAxis.prototype.ry = function (a, b, c, d) {
return this.rx(this.visibleMinimum);
};
TimeXAxis.prototype.r1 = function (a, b, c, d) {
return this.r0(this.visibleMaximum);
};
Object.defineProperty(TimeXAxis.prototype, "isVertical", {
get: function () {
return this.dz;
},
enumerable: false,
configurable: true
});
TimeXAxis.prototype.j$d = function (a, b) {
return this.ga.apply(this, arguments);
};
TimeXAxis.prototype.j$c = function (a, b) {
return this.f7.apply(this, arguments);
};
TimeXAxis.prototype.j$e = function (a, b, c, d, e) {
this.k2.apply(this, arguments);
};
TimeXAxis.prototype.j$f = function (a, b, c, d) {
this.k3.apply(this, arguments);
};
TimeXAxis.prototype.j$g = function (a, b, c, d) {
this.k4.apply(this, arguments);
};
Object.defineProperty(TimeXAxis.prototype, "j$b", {
get: function () {
return this.dn;
},
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.dj;
},
enumerable: false,
configurable: true
});
TimeXAxis.$t = markType(TimeXAxis, 'TimeXAxis', TimeAxisBase.$, [ITimeRangeSelectorAxis_$type]);
TimeXAxis.sl = null;
return TimeXAxis;
}(TimeAxisBase));
export { TimeXAxis };