igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
418 lines (417 loc) • 17.3 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends } from "tslib";
import { TimeAxisBase } from "./TimeAxisBase";
import { DependencyProperty } from "igniteui-react-core";
import { TimeAxisDisplayType_$type } from "./TimeAxisDisplayType";
import { Base, typeCast, enumGetBox, Number_$type, typeGetValue, markType, markDep } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { NumericYAxis } from "./NumericYAxis";
import { LinearNumericSnapper } from "./LinearNumericSnapper";
import { LabelPosition } from "./LabelPosition";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, intDivide, isNaN_, isInfinity } from "igniteui-react-core";
import { dateMinValue, dateFromTicks } from "igniteui-react-core";
import { timeSpanFromMilliseconds } from "igniteui-react-core";
import { CategoryAxisBaseView } from "./CategoryAxisBaseView";
import { AxisDefaults } from "./AxisDefaults";
/**
* @hidden
*/
var CategoryDateTimeXAxis = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(CategoryDateTimeXAxis, _super);
function CategoryDateTimeXAxis() {
var _this = _super.call(this) || this;
_this.sr = 0;
_this.ss = 0;
_this.ab = CategoryDateTimeXAxis.$;
_this.actualMinimumValue = (new Date());
_this.actualMaximumValue = (new Date());
return _this;
}
CategoryDateTimeXAxis.prototype.al = function () {
return new CategoryDateTimeXAxis();
};
CategoryDateTimeXAxis.prototype.km = function (a) {
_super.prototype.km.call(this, a);
this.kp(a, "ActualInterval");
this.kp(a, "ActualMinorInterval");
this.kp(a, "DisplayType");
this.kp(a, "UnevenlySpacedLabels");
};
CategoryDateTimeXAxis.prototype.kp = function (a, b) {
_super.prototype.kp.call(this, a, b);
var c = typeCast(CategoryDateTimeXAxis.$, a);
if (c == null) {
return;
}
if (b == "ActualInterval") {
c.st = this.st;
}
if (b == "ActualMinorInterval") {
c.sx = this.su;
}
if (b == "DisplayType") {
c.sk = this.sk;
}
if (b == "UnevenlySpacedLabels") {
c.sn = this.sn;
}
};
CategoryDateTimeXAxis.prototype.get_di = function () {
return this.sk == 0;
};
CategoryDateTimeXAxis.prototype.bo = function () {
return new CategoryDateTimeXAxisView(this);
};
CategoryDateTimeXAxis.prototype.k6 = function (a) {
_super.prototype.k6.call(this, a);
this.sj = a;
};
Object.defineProperty(CategoryDateTimeXAxis.prototype, "st", {
get: function () {
return this.sr;
},
set: function (a) {
if (this.st != a) {
var b = this.sr;
this.sr = a;
this.ls("ActualInterval", b, this.st);
}
},
enumerable: false,
configurable: true
});
CategoryDateTimeXAxis.prototype.gi = function () {
return this.st;
};
Object.defineProperty(CategoryDateTimeXAxis.prototype, "sx", {
get: function () {
return typeGetValue(this.c(CategoryDateTimeXAxis.s9));
},
set: function (a) {
this.h(CategoryDateTimeXAxis.s9, a);
},
enumerable: false,
configurable: true
});
Object.defineProperty(CategoryDateTimeXAxis.prototype, "su", {
get: function () {
return this.ss;
},
set: function (a) {
if (this.su != a) {
var b = this.ss;
this.ss = a;
this.ls("ActualMinorInterval", b, this.su);
}
},
enumerable: false,
configurable: true
});
CategoryDateTimeXAxis.prototype.ek = function (a, b, c) {
var d = _super.prototype.ek.call(this, a, b, c);
if (!d) {
return false;
}
return +(this.actualMinimumValue) != +(this.actualMaximumValue);
};
CategoryDateTimeXAxis.prototype.fr = function () {
return this.st;
};
CategoryDateTimeXAxis.prototype.lz = function (a) {
_super.prototype.lz.call(this, a);
var b = this.b7 != null ? this.b7.yr : Rect.empty;
var c = !b.isEmpty ? this.o6 : Rect.empty;
var d = this.o1();
var e = this.o0();
var f = new ScalerParams(0, b, c, this.dn, d);
if ((this.rd == null || this.rd.count < 1) && !this.rj() && !this.rk()) {
return;
}
if (!b.isEmpty && !c.isEmpty && (this.sk != 1 || this.rd != null)) {
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.l4(g, h, b, c, d, c.top, c.bottom);
g = j.p0;
h = j.p1;
}
}
if (isNaN_(g)) {
g = 0;
}
this.k4(this.bp.ba(), g, c, this.bp.f(), true);
this.a1.bl = h;
var k = this.bp.bd();
var l = this.bp.g();
var m = this.bp.bb();
var n = this.bp.bc();
var o = this.bp.h();
if (this.sk == 1) {
var p = this.i$e(b, c, d, e);
var q = this.i$g(b, c, d, e);
if (p < 0 || q < 0) {
return;
}
var r = NaN;
for (var s = p; s <= q; s++) {
var t = this.rm == null ? s : this.rm._inner[s];
var u = this.f6(this.rd.item(t).getTime(), f);
if (u == r) {
continue;
}
r = u;
if (this.categoryMode == 2) {
u += this.dn ? -this.getGroupCenter(s, b, c, d) : this.getGroupCenter(s, b, c, d);
}
if (u < e.left || u > e.right) {
continue;
}
this.mb(m, u, c, l, false);
this.pt.add(u);
if (this.pm != null && s < this.pm.count) {
var v = this.pm.item(t);
var w = _super.prototype.hw.call(this, v);
if (!isNaN_(u) && !isInfinity(u) && w != null) {
if ((typeof w === 'string') && Base.equalsStatic(w, "")) {
}
else {
this.eq.add1(w);
this.er.add(new LabelPosition(0, u));
}
}
}
}
}
else {
var x = this.f9(e.left, f);
var y = this.f9(e.right, f);
var z = Math.min(x, y);
var aa = Math.max(x, y);
var ab = new LinearNumericSnapper(0, z, aa, e.width, this.gm(), this.sq());
var ac = this.rh ? this.sp() : ab.g;
this.s5(truncate(ac));
var ad = truncate(Math.floor((z - this.actualMinimumValue.getTime()) / ac));
var ae = truncate(Math.ceil((aa - this.actualMinimumValue.getTime()) / ac));
var af = 0;
if (this.categoryMode == 2) {
af = this.getGroupCenter(0, b, c, d);
af = this.dn ? -af : af;
}
var ag = truncate(Math.ceil(e.right));
var ah = truncate(Math.floor(e.left));
var ai = this.f6(this.actualMinimumValue.getTime() + ad * ac, f) + af;
for (var aj = ad; aj <= ae; aj++) {
var ak = this.f6(this.actualMinimumValue.getTime() + (aj + 1) * ac, f) + af;
if (!isNaN_(ai) && !isInfinity(ai)) {
var al = truncate(Math.round(ai));
if (al <= ag) {
if (aj % 2 == 0) {
this.mc(k, ai, ak, c);
}
this.mb(m, ai, c, l, false);
this.pt.add(ai);
if (this.ea) {
var am = this.sv();
if (am > 0 && am < ac) {
if (ac / am < 20) {
var an = ai;
var ao = Math.abs(this.f6(this.actualMinimumValue.getTime() + am, f) - this.f6(this.actualMinimumValue.getTime(), f));
while (an + ao < ak) {
if (Math.abs(an + ao - ak) < 0.0001) {
break;
}
an += ao;
if (an > 0) {
this.mb(n, an, c, o, false);
}
}
this.s6(am);
}
}
else {
if (ab.j >= 1) {
for (var ap = 1; ap < ab.j; ++ap) {
var aq = this.f6(this.actualMinimumValue.getTime() + aj * ac + (ap * ac) / ab.j, f) + af;
this.mb(n, aq, c, o, false);
}
}
if (ab.j > 0) {
this.s6(truncate((ac / ab.j)));
}
}
}
}
if (al >= ah && al <= ag) {
var ar = this.actualMinimumValue.getTime() + aj * ac;
var ticks_ = truncate(Math.floor(ar));
var as = (new Date(ticks_));
var at = this.hw(as);
if (at != null) {
this.eq.add1(at);
this.er.add(new LabelPosition(0, ai));
}
}
}
ai = ak;
}
}
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.pr();
}
}
this.a1.be = this.eq;
this.a1.bf = this.er;
this.q0();
}
};
CategoryDateTimeXAxis.prototype.sq = function () {
return -1;
};
CategoryDateTimeXAxis.prototype.sp = function () {
return this.st;
};
CategoryDateTimeXAxis.prototype.sv = function () {
return this.sx;
};
CategoryDateTimeXAxis.prototype.s5 = function (a) {
this.st = a;
};
CategoryDateTimeXAxis.prototype.s6 = function (a) {
this.su = a;
};
CategoryDateTimeXAxis.prototype.sm = function () {
return this.sw != 0;
};
CategoryDateTimeXAxis.prototype.sl = function () {
return this.st == 0;
};
CategoryDateTimeXAxis.prototype.so = function (a) {
return this.rd == null ? dateMinValue() : this.rd.item(a);
};
CategoryDateTimeXAxis.prototype.s4 = function (a, b) {
if (a > b || this.pm == null || this.pm.count == 0) {
return;
}
var c = (a.getTime() - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime());
var d = (b.getTime() - this.actualMinimumValue.getTime()) / (this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime());
this.b7.za = new Rect(0, c, this.b7.za.y, d - c, this.b7.za.height);
};
CategoryDateTimeXAxis.prototype.la = function (a, b, c, d) {
_super.prototype.la.call(this, a, b, c, d);
switch (b) {
case CategoryDateTimeXAxis.$$p[0]:
this.d0 = true;
this.a1.an = this.sk == 1 || this.sn;
this.ly(false);
break;
case CategoryDateTimeXAxis.$$p[1]:
this.d0 = true;
this.ly(false);
break;
case CategoryDateTimeXAxis.$$p[2]:
this.a1.an = this.sk == 1 || this.sn;
break;
}
};
CategoryDateTimeXAxis.prototype.r9 = function () {
_super.prototype.r9.call(this);
if (this.sm()) {
this.st = this.sw;
var a = this.b7 != null ? this.b7.yr : Rect.empty;
var b = !a.isEmpty ? this.o6 : Rect.empty;
var c = Math.abs(this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime());
this.rh = this.sl() || (this.sk == 1) || (1 * c / this.sp() > (b.width / a.width)) ? false : true;
}
else {
this.rh = false;
}
};
CategoryDateTimeXAxis.prototype.r7 = function (a, b) {
var c = b.getTime() - a.getTime();
var timeOffset_ = truncate(Math.round(intDivide(c, this.qa) / 2));
return timeOffset_ == 0 ? timeSpanFromMilliseconds(1) : timeSpanFromMilliseconds(timeOffset_);
};
CategoryDateTimeXAxis.prototype.get_dg = function () {
return true;
};
Object.defineProperty(CategoryDateTimeXAxis.prototype, "isVertical", {
get: function () {
return this.dy;
},
enumerable: false,
configurable: true
});
CategoryDateTimeXAxis.prototype.j$d = function (a, b) {
return this.f9.apply(this, arguments);
};
CategoryDateTimeXAxis.prototype.j$c = function (a, b) {
return this.f6.apply(this, arguments);
};
CategoryDateTimeXAxis.prototype.j$e = function (a, b, c, d, e) {
this.k0.apply(this, arguments);
};
CategoryDateTimeXAxis.prototype.j$f = function (a, b, c, d) {
this.k1.apply(this, arguments);
};
CategoryDateTimeXAxis.prototype.j$g = function (a, b, c, d) {
this.k2.apply(this, arguments);
};
Object.defineProperty(CategoryDateTimeXAxis.prototype, "j$b", {
get: function () {
return this.dn;
},
enumerable: false,
configurable: true
});
CategoryDateTimeXAxis.prototype.j$a = function () {
return this.ag.apply(this, arguments);
};
Object.defineProperty(CategoryDateTimeXAxis.prototype, "i$a", {
get: function () {
return this.dj;
},
enumerable: false,
configurable: true
});
CategoryDateTimeXAxis.$t = markType(CategoryDateTimeXAxis, 'CategoryDateTimeXAxis', TimeAxisBase.$);
CategoryDateTimeXAxis.s9 = DependencyProperty.i("MinorInterval", Number_$type, CategoryDateTimeXAxis.$, new PropertyMetadata(2, 0, function (a, b) {
(typeCast(CategoryDateTimeXAxis.$, a)).ls("MinorInterval", b.oldValue, b.newValue);
(typeCast(CategoryDateTimeXAxis.$, a)).ly(false);
}));
CategoryDateTimeXAxis.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryDateTimeXAxis, 'ls', ['DisplayType:sk:s7', [TimeAxisDisplayType_$type, enumGetBox(TimeAxisDisplayType_$type, 0)], 'Interval:sw:s8', [1, 0], 'UnevenlySpacedLabels:sn:ta', [0, false]]);
return CategoryDateTimeXAxis;
}(TimeAxisBase));
export { CategoryDateTimeXAxis };
/**
* @hidden
*/
var CategoryDateTimeXAxisView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(CategoryDateTimeXAxisView, _super);
function CategoryDateTimeXAxisView(a) {
var _this = _super.call(this, a) || this;
_this.bs = null;
_this.bs = a;
return _this;
}
CategoryDateTimeXAxisView.prototype.ar = function () {
_super.prototype.ar.call(this);
this.b.g6 = AxisDefaults.categoryAxis_TickLength;
};
CategoryDateTimeXAxisView.prototype.v = function (a) {
var b = this.t(dateFromTicks(truncate(a)));
return b;
};
CategoryDateTimeXAxisView.$t = markType(CategoryDateTimeXAxisView, 'CategoryDateTimeXAxisView', CategoryAxisBaseView.$);
return CategoryDateTimeXAxisView;
}(CategoryAxisBaseView));
export { CategoryDateTimeXAxisView };