igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
736 lines (735 loc) • 24.5 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-react-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { ISortingAxis_$type } from "./ISortingAxis";
import { IDateTimeAxis_$type } from "./IDateTimeAxis";
import { DependencyProperty } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { typeCast, Number_$type, Date_$type, fromEnum, runOn, delegateRemove, delegateCombine, markType, markDep, TypeRegistrar } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-react-core";
import { NumericScaler } from "./NumericScaler";
import { SeriesViewer } from "./SeriesViewer";
import { SortedListView$1 } from "./SortedListView$1";
import { ArrayExtension } from "igniteui-react-core";
import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_ } from "igniteui-react-core";
import { dateMinValue, dateSubtract, dateAdd, dateMaxValue, dateFromTicks } from "igniteui-react-core";
/**
* @hidden
*/
var TimeAxisBase = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TimeAxisBase, _super);
function TimeAxisBase() {
var _this = _super.call(this) || this;
_this.rc = null;
_this.rl = null;
_this.rg = false;
_this.ro = dateMaxValue();
_this.rn = dateMinValue();
FastItemDateTimeColumn.o();
return _this;
}
TimeAxisBase.prototype.i7 = function () {
return TimeAxisBase.$$p[0];
};
TimeAxisBase.prototype.i6 = function (a) {
var b = this.jn(a);
if (b == TimeAxisBase.$$p[0]) {
return this.dateTimeMemberPath;
}
return _super.prototype.i6.call(this, a);
};
TimeAxisBase.prototype.ag = function () {
return [this.actualMinimumValue.getTime(), this.actualMaximumValue.getTime()];
};
TimeAxisBase.prototype.f6 = function (a, b) {
if (!b.c.isEmpty) {
var c = this.rt(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.rt(a, b.e, b.d, b.c);
};
TimeAxisBase.prototype.hu = function (a, b) {
var c = this.jn(b);
if (c == TimeAxisBase.$$p[0]) {
return this.hv(a, b, this.dateTimeMemberPath);
}
return _super.prototype.hu.call(this, a, b);
};
TimeAxisBase.prototype.rt = 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.dn) {
e = 1 - e;
f = -f;
}
return c.left + c.width * (e - b.left) / b.width - f;
};
TimeAxisBase.prototype.ru = 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.dn) {
d = 1 - d;
e = -e;
}
return c.left + c.width * (d - b.left) / b.width - e;
};
TimeAxisBase.prototype.f9 = 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.dn) {
e = 1 - e;
}
return truncate(Math.floor(this.actualMinimumValue.getTime() + e * (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime())));
};
TimeAxisBase.prototype.i$h = function () {
this.r9();
};
TimeAxisBase.prototype.r9 = function () {
var a = this.b7 != null ? this.b7.yr : Rect.empty;
var b = !a.isEmpty ? this.o6 : Rect.empty;
var c = (new Date());
var d = (new Date());
var e = false;
if (!a.isEmpty && !b.isEmpty && this.rd != null) {
var f = typeCast(FastItemDateTimeColumn.$, this.rd);
if (f != null) {
if (this.rm == null) {
this.sa();
}
}
else {
this.rm = null;
}
if (this.rd.count > 0) {
e = true;
var g = this.rm == null ? 0 : this.rm._inner[0];
var h = this.rm == null ? this.rd.count - 1 : this.rm._inner[this.rd.count - 1];
c = this.rd.item(g);
d = this.rd.item(h);
this.rh = false;
if (this.categoryMode == 2) {
var i = this.r7(c, d);
if (+c != +(dateMinValue())) {
c = dateSubtract(+c, +i);
}
d = dateAdd(+d, +i);
}
}
}
if (this.rk()) {
e = true;
c = this.minimumValue;
}
if (this.rj()) {
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.se();
}
};
TimeAxisBase.prototype.se = function () {
};
Object.defineProperty(TimeAxisBase.prototype, "rd", {
get: function () {
return this.rc;
},
set: function (a) {
if (this.rc != a) {
var b = this.rc;
this.rc = a;
this.ls("DateTimeColumn", b, this.rc);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeAxisBase.prototype, "rm", {
get: function () {
return this.rl;
},
set: function (a) {
this.rl = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TimeAxisBase.prototype, "i$b", {
get: function () {
if (this.rm == null) {
var a = typeCast(FastItemDateTimeColumn.$, this.rd);
if (a != null) {
this.sa();
}
else {
this.rm = null;
}
}
return this.rm;
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.sa = function () {
if (this.ri) {
this.rm = new List$1(Number_$type, 0);
var a = this.rm;
var b = this.rd.count;
for (var c = 0; c < b; c++) {
a.add(c);
}
}
else {
var d = typeCast(FastItemDateTimeColumn.$, this.rd);
this.rm = d.h();
}
};
TimeAxisBase.prototype.i$e = function (a, b, c, d) {
return this.rw(a, b, c, d);
};
TimeAxisBase.prototype.rw = function (a, b, c, d) {
if (b.isEmpty) {
return -1;
}
var e = d;
var f = new ScalerParams(0, a, b, this.dn, c);
var g, h;
if (this.dn) {
h = this.f9(e.left, f);
g = this.f9(e.right, f);
}
else {
g = this.f9(e.left, f);
h = this.f9(e.right, f);
}
var i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(g)));
return this.rv(dateFromTicks(i));
};
TimeAxisBase.prototype.rv = function (a) {
if (this.rd == null || this.rm.count != this.rd.count) {
return -1;
}
var b = new SortedListView$1(Date_$type, this.rd, this.rm);
var c = this.rx(a, b);
if (c >= 0 && c < this.rm.count) {
var d = this.rd.item(this.rm._inner[c]);
if (d > a) {
c--;
if (c < 0) {
c = 0;
}
}
return c;
}
return this.rm.count - 1;
};
TimeAxisBase.prototype.i$g = function (a, b, c, d) {
return this.rz(a, b, c, d);
};
TimeAxisBase.prototype.rz = function (a, b, c, d) {
if (b.isEmpty) {
return -1;
}
var e = d;
var f = new ScalerParams(0, a, b, this.dn, c);
var g, h;
if (this.dn) {
h = this.f9(e.left, f);
g = this.f9(e.right, f);
}
else {
g = this.f9(e.left, f);
h = this.f9(e.right, f);
}
var i = Math.max(dateMinValue().getTime(), Math.min(dateMaxValue().getTime(), truncate(h)));
return this.ry(dateFromTicks(i));
};
TimeAxisBase.prototype.ry = function (a) {
if (this.rd == null || this.rm.count != this.rd.count) {
return -1;
}
var b = new SortedListView$1(Date_$type, this.rd, this.rm);
var c = this.rx(a, b);
if (c >= this.rm.count) {
c = this.rm.count - 1;
}
if (c >= 0 && c < this.rm.count) {
var d = this.rd.item(this.rm._inner[c]);
if (d < a) {
c++;
if (c > this.rm.count - 1) {
c = this.rm.count - 1;
}
}
return c;
}
return 0;
};
TimeAxisBase.prototype.i$d = function (a) {
if (this.rd == null) {
return NaN;
}
var b = this.rc.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.rd, b.i$b);
var ticks_ = a;
var d = (new Date(ticks_));
var e = this.rx(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.o1();
if (e == b.i$b.count && this.b7 != null && this.f6(a, new ScalerParams(0, this.b7.yr, this.o6, this.dn, i)) < (this.o6.right + 2)) {
return e - 1;
}
if (e == -1 && this.b7 != null && Math.abs(this.f6(a, new ScalerParams(0, this.b7.yr, this.o6, this.dn, i)) - this.o6.left) < 2) {
return 0;
}
return -1;
};
TimeAxisBase.prototype.rx = function (a, b) {
var c = this;
if (this.rd == 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.rd == null || b.i$b.count != this.rd.count) {
return -1;
}
var c = new SortedListView$1(Date_$type, this.rd, b.i$b);
var ticks_ = a;
var d = (new Date(ticks_));
var e = this.rx(d, c);
var f = this.o1();
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.b7 != null && this.f6(a, new ScalerParams(0, this.b7.yr, this.o6, this.dn, f)) < (this.o6.right + 2)) {
return e - 1;
}
if (e == -1 && this.b7 != null && Math.abs(this.f6(a, new ScalerParams(0, this.b7.yr, this.o6, this.dn, f)) - this.o6.left) < 2) {
return 0;
}
return -1;
};
TimeAxisBase.prototype.i$i = function () {
this.rm = null;
this.lx();
};
TimeAxisBase.prototype.get_rh = function () {
return this.rg;
};
TimeAxisBase.prototype.set_rh = function (a) {
this.rg = a;
};
Object.defineProperty(TimeAxisBase.prototype, "rh", {
get: function () {
return this.get_rh();
},
set: function (a) {
this.set_rh(a);
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.lc = function (a) {
_super.prototype.lc.call(this, a);
this.dateTimeMemberPath = a;
};
TimeAxisBase.prototype.lf = function (a) {
_super.prototype.lf.call(this, a);
this.minimumValue = a;
};
TimeAxisBase.prototype.le = function (a) {
_super.prototype.lf.call(this, a);
this.maximumValue = a;
};
TimeAxisBase.prototype.ef = function () {
if (this.d0 && this.eg) {
this.b1 = this.b0();
}
var a = this.actualMinimumValue.getTime();
var b = this.actualMaximumValue.getTime();
this.r9();
var c = !this.rk() ? this.actualMinimumValue.getTime() : this.minimumValue.getTime();
var d = !this.rj() ? this.actualMaximumValue.getTime() : this.maximumValue.getTime();
var e = new AxisRangeChangedEventArgs(0, a, c, b, d);
this.lt(e);
return true;
};
TimeAxisBase.prototype.rk = function () {
if (+(this.minimumValue) == +(dateMinValue())) {
return false;
}
return (this.minimumValue != null);
};
TimeAxisBase.prototype.rj = function () {
if (+(this.maximumValue) == +(dateMaxValue())) {
return false;
}
return (this.maximumValue != null);
};
Object.defineProperty(TimeAxisBase.prototype, "actualMinimumValue", {
get: function () {
return this.ro;
},
set: function (a) {
var b = +(this.ro) != +a;
if (b) {
var c = this.ro;
this.ro = a;
this.ls("ActualMinimumValue", c, a);
}
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.hz = function () {
return this.actualMinimumValue;
};
Object.defineProperty(TimeAxisBase.prototype, "actualMaximumValue", {
get: function () {
return this.rn;
},
set: function (a) {
var b = +(this.rn) != +a;
if (b) {
var c = this.rn;
this.rn = a;
this.ls("ActualMaximumValue", c, a);
}
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.hy = function () {
return this.maximumValue;
};
TimeAxisBase.prototype.sb = function (a) {
var e_1, _a;
this.lz(a);
if (this.pm == null) {
return;
}
try {
for (var _b = __values(fromEnum(this.eo())), _c = _b.next(); !_c.done; _c = _b.next()) {
var b = _c.value;
b.r8(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.la = function (a, b, c, d) {
_super.prototype.la.call(this, a, b, c, d);
switch (b) {
case "FastItemsSource":
var e = typeCast(IFastItemsSource_$type, c);
if (e != null) {
e.deregisterColumn(this.rd);
this.rd = null;
e.event = delegateRemove(e.event, runOn(this, this.r8));
}
var f = typeCast(IFastItemsSource_$type, d);
if (f != null) {
this.rm = null;
this.rd = this.re(this.dateTimeMemberPath);
f.event = delegateCombine(f.event, runOn(this, this.r8));
}
this.sb(false);
break;
case TimeAxisBase.$$p[0]:
if (this.pm != null) {
this.pm.deregisterColumn(this.rd);
this.rd = this.re(this.dateTimeMemberPath);
this.rm = null;
}
break;
case TimeAxisBase.$$p[3]:
this.ed();
this.sb(false);
break;
case TimeAxisBase.$$p[2]:
this.ed();
this.sb(false);
break;
case "DateTimeColumn":
this.r9();
break;
}
};
TimeAxisBase.prototype.r8 = function (a, b) {
this.rm = null;
};
TimeAxisBase.prototype.re = function (a) {
return TimeAxisBase.rf(a, this);
};
TimeAxisBase.rf = function (a, b) {
if (a == null) {
return b.pm.registerColumnDateTime(null, null, false);
}
var c = null;
var d = SeriesViewer.de(a, b.coercionMethods);
c = d.a;
return b.pm.registerColumnDateTime(a, c, b.expectFunctions);
};
TimeAxisBase.prototype.a0 = function () {
if (this.ei) {
return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel'));
}
else {
return new HorizontalAxisLabelPanel();
}
};
TimeAxisBase.prototype.get_bm = function () {
return 0;
};
Object.defineProperty(TimeAxisBase.prototype, "bm", {
get: function () {
return this.get_bm();
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.lz = function (a) {
_super.prototype.lz.call(this, a);
var b = this.bp.ba();
var c = this.bp.bd();
var d = this.bp.bb();
var e = this.bp.bc();
var f = this.bp.f();
var g = this.bp.g();
var h = this.bp.h();
this.ma();
this.kk(b);
this.kk(c);
this.kk(d);
this.kk(e);
this.eq.clear();
this.er.clear();
this.pt.clear();
this.a1.ae = this;
var i = this.b7 != null ? this.b7.yr : Rect.empty;
var j = !i.isEmpty ? this.o6 : Rect.empty;
this.a1.da = i;
this.a1.c9 = j;
if (i.isEmpty || j.isEmpty) {
this.ci.count = 0;
this.ch.count = 0;
this.cf.count = 0;
this.cg.count = 0;
}
if (this.ci.count == 0 && this.bp.n()) {
this.a1.ab.clear();
}
if (this.a4 != null) {
this.a4.registerAxis(this);
}
this.r9();
};
TimeAxisBase.prototype.get_dj = 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.qa == 0) {
return 0;
}
var d = this.o4(b, c);
return d.width / (this.qa * a.width);
};
TimeAxisBase.prototype.getGroupCenter = function (a, b, c, d) {
return this.getCategorySize(b, c, d) * 0.5;
};
TimeAxisBase.prototype.pz = function (a, b, c) {
var d = this.p6(a, b, c);
var e = 1 - 0.5 * d;
var f = this.getCategorySize(a, b, c) * e;
return f;
};
TimeAxisBase.prototype.get_dv = function () {
return true;
};
TimeAxisBase.prototype.r7 = function (a, b) {
return (0);
};
TimeAxisBase.prototype.preferredCategoryMode = function (a) {
return this.dg ? 0 : 1;
};
TimeAxisBase.prototype.ht = function (a) {
var b = new ScalerParams(1, this.b7.za, this.b7.y9, this.dn);
var c = this.f9(a, b);
return dateFromTicks(truncate(c));
};
Object.defineProperty(TimeAxisBase.prototype, "isVertical", {
get: function () {
return this.dy;
},
enumerable: false,
configurable: true
});
TimeAxisBase.prototype.j$d = function (a, b) {
return this.f9.apply(this, arguments);
};
TimeAxisBase.prototype.j$c = function (a, b) {
return this.f6.apply(this, arguments);
};
TimeAxisBase.prototype.j$e = function (a, b, c, d, e) {
this.k0.apply(this, arguments);
};
TimeAxisBase.prototype.j$f = function (a, b, c, d) {
this.k1.apply(this, arguments);
};
TimeAxisBase.prototype.j$g = function (a, b, c, d) {
this.k2.apply(this, arguments);
};
Object.defineProperty(TimeAxisBase.prototype, "j$b", {
get: function () {
return this.dn;
},
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.dj;
},
enumerable: false,
configurable: true
});
TimeAxisBase.$t = markType(TimeAxisBase, 'TimeAxisBase', CategoryAxisBase.$, [ISortingAxis_$type, IDateTimeAxis_$type]);
TimeAxisBase.$$p = markDep(DependencyProperty, PropertyMetadata, TimeAxisBase, 'ls', ['DateTimeMemberPath::sf', [2, null], 'IsDataPreSorted:ri:sg', [0, false], 'MaximumValue::sh', [3, null], 'MinimumValue::si', [3, null]]);
return TimeAxisBase;
}(CategoryAxisBase));
export { TimeAxisBase };