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.st = 0;
_this.su = 0;
_this.ab = CategoryDateTimeXAxis.$;
_this.actualMinimumValue = (new Date());
_this.actualMaximumValue = (new Date());
return _this;
}
CategoryDateTimeXAxis.prototype.al = function () {
return new CategoryDateTimeXAxis();
};
CategoryDateTimeXAxis.prototype.ko = function (a) {
_super.prototype.ko.call(this, a);
this.kr(a, "ActualInterval");
this.kr(a, "ActualMinorInterval");
this.kr(a, "DisplayType");
this.kr(a, "UnevenlySpacedLabels");
};
CategoryDateTimeXAxis.prototype.kr = function (a, b) {
_super.prototype.kr.call(this, a, b);
var c = typeCast(CategoryDateTimeXAxis.$, a);
if (c == null) {
return;
}
if (b == "ActualInterval") {
c.sv = this.sv;
}
if (b == "ActualMinorInterval") {
c.sz = this.sw;
}
if (b == "DisplayType") {
c.sm = this.sm;
}
if (b == "UnevenlySpacedLabels") {
c.sp = this.sp;
}
};
CategoryDateTimeXAxis.prototype.get_di = function () {
return this.sm == 0;
};
CategoryDateTimeXAxis.prototype.bo = function () {
return new CategoryDateTimeXAxisView(this);
};
CategoryDateTimeXAxis.prototype.k8 = function (a) {
_super.prototype.k8.call(this, a);
this.sl = a;
};
Object.defineProperty(CategoryDateTimeXAxis.prototype, "sv", {
get: function () {
return this.st;
},
set: function (a) {
if (this.sv != a) {
var b = this.st;
this.st = a;
this.lu("ActualInterval", b, this.sv);
}
},
enumerable: false,
configurable: true
});
CategoryDateTimeXAxis.prototype.gk = function () {
return this.sv;
};
Object.defineProperty(CategoryDateTimeXAxis.prototype, "sz", {
get: function () {
return typeGetValue(this.c(CategoryDateTimeXAxis.tb));
},
set: function (a) {
this.h(CategoryDateTimeXAxis.tb, a);
},
enumerable: false,
configurable: true
});
Object.defineProperty(CategoryDateTimeXAxis.prototype, "sw", {
get: function () {
return this.su;
},
set: function (a) {
if (this.sw != a) {
var b = this.su;
this.su = a;
this.lu("ActualMinorInterval", b, this.sw);
}
},
enumerable: false,
configurable: true
});
CategoryDateTimeXAxis.prototype.el = function (a, b, c) {
var d = _super.prototype.el.call(this, a, b, c);
if (!d) {
return false;
}
return +(this.actualMinimumValue) != +(this.actualMaximumValue);
};
CategoryDateTimeXAxis.prototype.fs = function () {
return this.sv;
};
CategoryDateTimeXAxis.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.rf.count < 1) && !this.rl() && !this.rm()) {
return;
}
if (!b.isEmpty && !c.isEmpty && (this.sm != 1 || this.rf != 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.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 = this.bp.be();
var l = this.bp.h();
var m = this.bp.bc();
var n = this.bp.bd();
var o = this.bp.i();
if (this.sm == 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.ro == null ? s : this.ro._inner[s];
var u = this.f7(this.rf.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.md(m, u, c, l, false);
this.pv.add(u);
if (this.po != null && s < this.po.count) {
var v = this.po.item(t);
var w = _super.prototype.hy.call(this, v);
if (!isNaN_(u) && !isInfinity(u) && w != null) {
if ((typeof w === 'string') && Base.equalsStatic(w, "")) {
}
else {
this.er.add1(w);
this.es.add(new LabelPosition(0, u));
}
}
}
}
}
else {
var x = this.ga(e.left, f);
var y = this.ga(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.go(), this.ss());
var ac = this.rj ? this.sr() : ab.g;
this.s7(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.f7(this.actualMinimumValue.getTime() + ad * ac, f) + af;
for (var aj = ad; aj <= ae; aj++) {
var ak = this.f7(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.me(k, ai, ak, c);
}
this.md(m, ai, c, l, false);
this.pv.add(ai);
if (this.eb) {
var am = this.sx();
if (am > 0 && am < ac) {
if (ac / am < 20) {
var an = ai;
var ao = Math.abs(this.f7(this.actualMinimumValue.getTime() + am, f) - this.f7(this.actualMinimumValue.getTime(), f));
while (an + ao < ak) {
if (Math.abs(an + ao - ak) < 0.0001) {
break;
}
an += ao;
if (an > 0) {
this.md(n, an, c, o, false);
}
}
this.s8(am);
}
}
else {
if (ab.j >= 1) {
for (var ap = 1; ap < ab.j; ++ap) {
var aq = this.f7(this.actualMinimumValue.getTime() + aj * ac + (ap * ac) / ab.j, f) + af;
this.md(n, aq, c, o, false);
}
}
if (ab.j > 0) {
this.s8(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.hy(as);
if (at != null) {
this.er.add1(at);
this.es.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.ps();
}
}
this.a1.bg = this.er;
this.a1.bh = this.es;
this.q2();
}
};
CategoryDateTimeXAxis.prototype.ss = function () {
return -1;
};
CategoryDateTimeXAxis.prototype.sr = function () {
return this.sv;
};
CategoryDateTimeXAxis.prototype.sx = function () {
return this.sz;
};
CategoryDateTimeXAxis.prototype.s7 = function (a) {
this.sv = a;
};
CategoryDateTimeXAxis.prototype.s8 = function (a) {
this.sw = a;
};
CategoryDateTimeXAxis.prototype.so = function () {
return this.sy != 0;
};
CategoryDateTimeXAxis.prototype.sn = function () {
return this.sv == 0;
};
CategoryDateTimeXAxis.prototype.sq = function (a) {
return this.rf == null ? dateMinValue() : this.rf.item(a);
};
CategoryDateTimeXAxis.prototype.s6 = function (a, b) {
if (a > b || this.po == null || this.po.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.zb = new Rect(0, c, this.b7.zb.y, d - c, this.b7.zb.height);
};
CategoryDateTimeXAxis.prototype.lc = function (a, b, c, d) {
_super.prototype.lc.call(this, a, b, c, d);
switch (b) {
case CategoryDateTimeXAxis.$$p[0]:
this.d1 = true;
this.a1.an = this.sm == 1 || this.sp;
this.l0(false);
break;
case CategoryDateTimeXAxis.$$p[1]:
this.d1 = true;
this.l0(false);
break;
case CategoryDateTimeXAxis.$$p[2]:
this.a1.an = this.sm == 1 || this.sp;
break;
}
};
CategoryDateTimeXAxis.prototype.sb = function () {
_super.prototype.sb.call(this);
if (this.so()) {
this.sv = this.sy;
var a = this.b7 != null ? this.b7.ys : Rect.empty;
var b = !a.isEmpty ? this.o8 : Rect.empty;
var c = Math.abs(this.actualMaximumValue.getTime() - this.actualMinimumValue.getTime());
this.rj = this.sn() || (this.sm == 1) || (1 * c / this.sr() > (b.width / a.width)) ? false : true;
}
else {
this.rj = false;
}
};
CategoryDateTimeXAxis.prototype.r9 = function (a, b) {
var c = b.getTime() - a.getTime();
var timeOffset_ = truncate(Math.round(intDivide(c, this.qc) / 2));
return timeOffset_ == 0 ? timeSpanFromMilliseconds(1) : timeSpanFromMilliseconds(timeOffset_);
};
CategoryDateTimeXAxis.prototype.get_dg = function () {
return true;
};
Object.defineProperty(CategoryDateTimeXAxis.prototype, "isVertical", {
get: function () {
return this.dz;
},
enumerable: false,
configurable: true
});
CategoryDateTimeXAxis.prototype.j$d = function (a, b) {
return this.ga.apply(this, arguments);
};
CategoryDateTimeXAxis.prototype.j$c = function (a, b) {
return this.f7.apply(this, arguments);
};
CategoryDateTimeXAxis.prototype.j$e = function (a, b, c, d, e) {
this.k2.apply(this, arguments);
};
CategoryDateTimeXAxis.prototype.j$f = function (a, b, c, d) {
this.k3.apply(this, arguments);
};
CategoryDateTimeXAxis.prototype.j$g = function (a, b, c, d) {
this.k4.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.tb = DependencyProperty.i("MinorInterval", Number_$type, CategoryDateTimeXAxis.$, new PropertyMetadata(2, 0, function (a, b) {
(typeCast(CategoryDateTimeXAxis.$, a)).lu("MinorInterval", b.oldValue, b.newValue);
(typeCast(CategoryDateTimeXAxis.$, a)).l0(false);
}));
CategoryDateTimeXAxis.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryDateTimeXAxis, 'lu', ['DisplayType:sm:s9', [TimeAxisDisplayType_$type, enumGetBox(TimeAxisDisplayType_$type, 0)], 'Interval:sy:ta', [1, 0], 'UnevenlySpacedLabels:sp:tc', [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.bv = null;
_this.bv = a;
return _this;
}
CategoryDateTimeXAxisView.prototype.as = function () {
_super.prototype.as.call(this);
this.c.g8 = AxisDefaults.categoryAxis_TickLength;
};
CategoryDateTimeXAxisView.prototype.w = function (a) {
var b = this.u(dateFromTicks(truncate(a)));
return b;
};
CategoryDateTimeXAxisView.$t = markType(CategoryDateTimeXAxisView, 'CategoryDateTimeXAxisView', CategoryAxisBaseView.$);
return CategoryDateTimeXAxisView;
}(CategoryAxisBaseView));
export { CategoryDateTimeXAxisView };