igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
753 lines (752 loc) • 26.6 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 { CategoryAxisBase } from "./CategoryAxisBase";
import { IZoomableCategoryAxis_$type } from "./IZoomableCategoryAxis";
import { DependencyProperty } from "igniteui-react-core";
import { Axis } from "./Axis";
import { Rect } from "igniteui-react-core";
import { Base, typeCast, Array_$type, Number_$type, markType, markDep } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { NumericScaler } from "./NumericScaler";
import { VerticalAxisLabelPanel } from "./VerticalAxisLabelPanel";
import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs";
import { MathUtil } from "igniteui-react-core";
import { LinearCategorySnapper } from "./LinearCategorySnapper";
import { NumericXAxis } from "./NumericXAxis";
import { LabelPosition } from "./LabelPosition";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { CategoryAxisBaseView } from "./CategoryAxisBaseView";
import { AxisDefaults } from "./AxisDefaults";
/**
* @hidden
*/
var CategoryYAxis = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(CategoryYAxis, _super);
function CategoryYAxis() {
var _this = _super.call(this) || this;
_this.rh = 0;
_this.ri = 0;
_this.rr = 1;
_this.rq = 1;
_this.pv = new List$1(Number_$type, 0);
_this.ab = CategoryYAxis.$;
return _this;
}
CategoryYAxis.prototype.bo = function () {
return new CategoryYAxisView(this);
};
CategoryYAxis.prototype.k8 = function (a) {
_super.prototype.k8.call(this, a);
this.rf = a;
};
CategoryYAxis.prototype.al = function () {
return new CategoryYAxis();
};
CategoryYAxis.prototype.ko = function (a) {
_super.prototype.ko.call(this, a);
this.kr(a, "ActualInterval");
this.kr(a, "ActualMinorInterval");
this.kr(a, "ZoomToItemSpan");
this.kr(a, "ZoomToCategoryStart");
this.kr(a, "ZoomToCategoryRange");
this.kr(a, "ZoomMaximumItemSpan");
this.kr(a, "ZoomMaximumCategoryRange");
};
CategoryYAxis.prototype.kr = function (a, b) {
_super.prototype.kr.call(this, a, b);
var c = typeCast(CategoryYAxis.$, a);
if (c == null) {
return;
}
var d = this;
if (b == "ActualMinorInterval") {
c.rp = Axis.gu(d.rm, d.rk);
}
if (b == "ActualInterval") {
c.ro = Axis.gu(d.rl, d.rj);
}
if (b == "ZoomToItemSpan") {
c.zoomToItemSpan = d.zoomToItemSpan;
}
if (b == "ZoomToCategoryStart") {
c.zoomToCategoryStart = d.zoomToCategoryStart;
}
if (b == "ZoomToCategoryRange") {
c.zoomToCategoryRange = d.zoomToCategoryRange;
}
if (b == "ZoomMaximumItemSpan") {
c.zoomMaximumItemSpan = d.zoomMaximumItemSpan;
}
if (b == "ZoomMaximumCategoryRange") {
c.zoomMaximumCategoryRange = d.zoomMaximumCategoryRange;
}
};
CategoryYAxis.prototype.get_dz = function () {
return true;
};
CategoryYAxis.prototype.f6 = function () {
return this.o2().height;
};
CategoryYAxis.prototype.rc = function (a, b, c) {
return this.rd(a, b, c, true);
};
CategoryYAxis.prototype.re = function (a) {
if (typeCast(List$1.$.specialize(Array_$type), a) !== null) {
return a.asArray();
}
return null;
};
CategoryYAxis.prototype.k2 = function (a, b, c, d, e) {
var f;
var g = e.e;
var h = e.d;
var i = e.c;
var j = e.a;
var k = !i.isEmpty;
var l = this.categoryMode == 0 ? this.qc - 1 : this.qc;
if (l < 0) {
l = 0;
}
var m = i.top;
var n = i.height;
var o = g.top;
var p = g.height;
var q = h.top;
var r = h.height;
var s = 0;
var t = 1;
var u = this.re(a);
var v = false;
if (u != null) {
v = true;
}
var w;
for (var x = 0; x < b.count; x++) {
w = b.item(x);
for (var y = c; y < d; y++) {
if (v) {
f = u[y];
}
else {
f = a.item(y);
}
if (k) {
var z = l >= 1 ? (f[w]) / (l) : l == 0 ? 0.5 : NaN;
if (!j) {
z = 1 - z;
}
z = m + n * (z - s) / t;
var aa = (z - e.d.top) / e.d.height;
aa = e.d.top + e.d.height * (aa - e.e.top) / e.e.height;
f[w] = aa;
}
else {
var ab = l >= 1 ? (f[w]) / (l) : l == 0 ? 0.5 : NaN;
if (!j) {
ab = 1 - ab;
}
ab = q + r * (ab - o) / p;
f[w] = ab;
}
}
}
};
Object.defineProperty(CategoryYAxis.prototype, "ro", {
get: function () {
return this.c(CategoryYAxis.sb);
},
set: function (a) {
this.h(CategoryYAxis.sb, a);
},
enumerable: false,
configurable: true
});
CategoryYAxis.prototype.rg = function () {
return !isNaN_(this.ro);
};
Object.defineProperty(CategoryYAxis.prototype, "rj", {
get: function () {
return this.rh;
},
set: function (a) {
if (this.rj != a) {
var b = this.rh;
this.rh = a;
this.lu("ActualInterval", b, this.rj);
}
},
enumerable: false,
configurable: true
});
CategoryYAxis.prototype.gk = function () {
return this.rj;
};
Object.defineProperty(CategoryYAxis.prototype, "rp", {
get: function () {
return this.c(CategoryYAxis.sc);
},
set: function (a) {
this.h(CategoryYAxis.sc, a);
},
enumerable: false,
configurable: true
});
Object.defineProperty(CategoryYAxis.prototype, "rk", {
get: function () {
return this.ri;
},
set: function (a) {
if (this.rk != a) {
var b = this.ri;
this.ri = a;
this.lu("ActualMinorInterval", b, this.rk);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CategoryYAxis.prototype, "rt", {
get: function () {
return this.rr;
},
set: function (a) {
this.rr = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(CategoryYAxis.prototype, "rs", {
get: function () {
return this.rq;
},
set: function (a) {
this.rq = a;
},
enumerable: false,
configurable: true
});
CategoryYAxis.prototype.f7 = function (a, b) {
if (!b.c.isEmpty) {
var c = this.rn(a, NumericScaler.ac, b.c);
c = (c - b.d.top) / b.d.height;
c = b.d.top + b.d.height * (c - b.e.top) / b.e.height;
return c;
}
return this.rn(a, b.e, b.d);
};
CategoryYAxis.prototype.rn = function (a, b, c) {
var d = this.categoryMode == 0 ? this.qc - 1 : this.qc;
if (d < 0) {
d = 0;
}
var e = d >= 1 ? (a) / (d) : d == 0 ? 0.5 : NaN;
if (!this.dp) {
e = 1 - e;
}
return c.top + c.height * (e - b.top) / b.height;
};
CategoryYAxis.prototype.ga = function (a, b) {
if (!b.c.isEmpty) {
var c = b.e.top + b.e.height * (a - b.d.top) / b.d.height;
c = (c * b.d.height) + b.d.top;
c = this.getUnscaledValue3(c, NumericScaler.ac, b.c, this.categoryMode);
return c;
}
return this.getUnscaledValue3(a, b.e, b.d, this.categoryMode);
};
CategoryYAxis.prototype.gb = function (a, b, c) {
if (!b.c.isEmpty) {
var d = b.e.top + b.e.height * (a - b.d.top) / b.d.height;
d = (d * b.d.height) + b.d.top;
d = this.getUnscaledValue3(d, NumericScaler.ac, b.c, c);
return d;
}
return this.getUnscaledValue3(a, b.e, b.d, c);
};
CategoryYAxis.prototype.getUnscaledValue3 = function (a, b, c, d) {
var e = b.top + (a - c.top) * b.height / c.height;
if (!this.dp) {
e = 1 - e;
}
var f = d == 0 ? this.qc - 1 : this.qc;
if (f < 0) {
f = 0;
}
return e * f;
};
CategoryYAxis.prototype.r6 = function (a, b) {
if (isNaN_(a) || isNaN_(b) || this.po == null || this.po.count == 0) {
return;
}
var c = a / this.po.count;
var d = b / this.po.count;
this.b7.zb = new Rect(0, this.b7.zb.x, 1 - d, this.b7.zb.width, d - c);
};
CategoryYAxis.prototype.a0 = function () {
return new VerticalAxisLabelPanel();
};
CategoryYAxis.prototype.fs = function () {
return this.ro;
};
CategoryYAxis.prototype.getCategorySize = function (a, b, c) {
var d = this.o6(b, c);
return d.height / (this.qc * a.height);
};
CategoryYAxis.prototype.p1 = function (a, b, c) {
var d = this.p8(a, b, c);
var e = 0;
if (!isNaN_(this.p7)) {
e = Math.min(this.p7, 1);
}
var f = 1 - 0.5 * d;
var g = this.getCategorySize(a, b, c) * f / (this.qe - (this.qe - 1) * e);
return g;
};
CategoryYAxis.prototype.getGroupCenter = function (a, b, c, d) {
var e = 0.5;
if (this.qe > 1) {
var f = this.p8(b, c, d);
var g = 0;
if (!isNaN_(this.p7)) {
g = Math.min(this.p7, 1);
}
var h = 1 - 0.5 * f;
var i = h / (this.qe - (this.qe - 1) * g);
var j = (h - i) / (this.qe - 1);
e = 0.25 * f + 0.5 * i + a * j;
}
return this.getCategorySize(b, c, d) * e;
};
CategoryYAxis.prototype.r5 = function (a) {
var b = this.b7 != null ? this.b7.ys : Rect.empty;
b = b.copy();
var c = this.o8;
var d = new Rect(0, 0, 0, 1, 1);
var e = this.o5();
var f = new ScalerParams(0, d, d, this.dn, e);
var g = !b.isEmpty && !c.isEmpty && this.po != null ? this.po.indexOf(a) : -1;
var h = g > -1 ? this.f7(g, f) : NaN;
if (!isNaN_(h) && this.b7.gb) {
if (!isNaN_(h)) {
if (h < b.top + 0.1 * b.height) {
h = h + 0.4 * b.height;
b.y = h - 0.5 * b.height;
}
if (h > b.bottom - 0.1 * b.height) {
h = h - 0.4 * b.height;
b.y = h - 0.5 * b.height;
}
}
this.b7.uf(b, false, true);
}
};
CategoryYAxis.prototype.eg = function () {
if (this.d1 && this.eh) {
this.b1 = this.b0();
}
if (this.po == null) {
return false;
}
var a = false;
var b = this.po.count;
if (b != this.rs) {
var c = new AxisRangeChangedEventArgs(0, 1, 1, this.rs, b);
this.rs = b;
this.lv(c);
a = true;
}
this.r8();
this.r7();
return a;
};
CategoryYAxis.prototype.getWindowZoomFromCategories = function (a) {
var b = MathUtil.b(a) && a > 0;
var c = this.po.count;
if (c > 0 && b) {
var d = this.b7.za.height;
var e = isNaN_(d) || isInfinity(d);
if (e) {
return NaN;
}
var f = new Rect(0, 0, 0, 1, 1);
var g = this.b7.za;
var h = this.getCategorySize(f, g, g);
var i = isNaN_(h) || isInfinity(h);
if (i) {
return NaN;
}
var j = h * a / d;
if (j >= 0 && j <= 1) {
return j;
}
}
return NaN;
};
CategoryYAxis.prototype.getWindowZoomFromItemSpan = function (a) {
var b = MathUtil.b(a) && a > 0;
var c = this.po.count;
if (c > 0 && b) {
var d = this.b7.za.height;
var e = isNaN_(d) || isInfinity(d);
if (e) {
return NaN;
}
var f = new Rect(0, 0, 0, 1, 1);
var g = this.b7.za;
var h = this.p1(f, g, g);
var i = a / h;
var j = Math.min(1, 1 / i);
if (j > 0 && j <= 1) {
return j;
}
}
return NaN;
};
CategoryYAxis.prototype.r8 = function () {
if (this.po == null || this.b7 == null) {
return;
}
var a = !isNaN_(this.b7.jw) && !isNaN_(this.b7.jy);
if (a) {
return;
}
if (!isNaN_(this.zoomMaximumItemSpan) && !isInfinity(this.zoomMaximumItemSpan)) {
var b = this.getWindowZoomFromItemSpan(this.zoomMaximumItemSpan);
if (!isNaN_(b) && !isInfinity(b)) {
this.b7.io = b;
}
}
else if (!isNaN_(this.zoomMaximumCategoryRange) && !isInfinity(this.zoomMaximumCategoryRange)) {
var c = this.getWindowZoomFromCategories(this.zoomMaximumCategoryRange);
if (!isNaN_(c) && !isInfinity(c)) {
this.b7.io = c;
}
}
};
CategoryYAxis.prototype.r7 = function () {
if (this.po == null || this.b7 == null) {
return;
}
var a = NaN;
var b = NaN;
var c = this.b7.iv();
var d = this.b7.iw();
var e = false;
if (MathUtil.b(this.zoomToItemSpan)) {
e = true;
d = this.getWindowZoomFromItemSpan(this.zoomToItemSpan);
d = Math.max(d, this.b7.io);
}
else if (MathUtil.b(this.zoomToCategoryRange)) {
e = true;
d = this.getWindowZoomFromCategories(this.zoomToCategoryRange);
d = Math.max(d, this.b7.io);
}
if (MathUtil.b(this.zoomToCategoryStart) && this.zoomToCategoryStart >= 0 && this.zoomToCategoryStart < this.qd) {
e = true;
b = this.getWindowZoomFromCategories(this.zoomToCategoryStart);
var f = d + a - 1;
var g = d - f;
if (f > 0 && g > this.b7.io) {
d = g;
d = Math.max(d, this.b7.io);
}
}
if (e) {
this.b7.uc(a, b, c, d);
}
};
CategoryYAxis.prototype.lc = function (a, b, c, d) {
_super.prototype.lc.call(this, a, b, c, d);
switch (b) {
case CategoryYAxis.$$p[2]:
case CategoryYAxis.$$p[3]:
this.r8();
break;
case CategoryYAxis.$$p[4]:
case CategoryYAxis.$$p[5]:
case CategoryYAxis.$$p[6]:
this.r7();
break;
case CategoryYAxis.$$p[0]:
case CategoryYAxis.$$p[1]:
this.ky(b);
break;
}
};
CategoryYAxis.prototype.ky = function (a) {
_super.prototype.ky.call(this, a);
switch (a) {
case CategoryYAxis.$$p[0]:
case CategoryYAxis.$$p[1]:
this.kt(a);
break;
}
};
CategoryYAxis.prototype.pr = function (a) {
if (a == null) {
return false;
}
var b = this.b3();
if (b == null) {
return false;
}
return b.synchronizeVertically;
};
CategoryYAxis.prototype.l1 = function (a) {
_super.prototype.l1.call(this, a);
var b = this.b7 != null ? this.b7.ys : Rect.empty;
var c = this.o8;
var d = this.o3();
var e = this.o2();
var f = new ScalerParams(0, b, c, this.dn, d);
var g = this.bp.bb();
var h = this.bp.be();
var i = this.bp.bc();
var j = this.bp.bd();
var k = this.bp.g();
var l = this.bp.h();
var m = this.bp.i();
this.mc();
this.km(g);
this.km(h);
this.km(i);
this.km(j);
this.er.clear();
this.es.clear();
this.pv.clear();
this.bp.a6(this, b, c);
if (b.isEmpty || c.isEmpty) {
this.ci.count = 0;
this.ch.count = 0;
this.cf.count = 0;
this.ce.count = 0;
this.cg.count = 0;
}
if (this.ci.count == 0 && this.ch.count == 0 && this.bp.o()) {
this.bp.ak();
}
if (this.a4 != null) {
this.a4.registerAxis(this);
}
if (this.itemsSource == null || this.po == null || this.po.count == 0) {
this.ci.count = 0;
this.ch.count = 0;
this.cf.count = 0;
this.ce.count = 0;
this.cg.count = 0;
this.bp.ak();
return;
}
if (!b.isEmpty && !c.isEmpty) {
var n = this.ga(e.top, f);
var o = this.ga(e.bottom, f);
if (!this.dn) {
n = Math.ceil(n);
o = Math.floor(o);
}
else {
n = Math.floor(n);
o = Math.ceil(o);
}
var p = c.left;
var q = 0;
if (this.an != null) {
var r = typeCast(NumericXAxis.$, this.an);
if (r != null) {
var s = this.l6(p, q, b, c, d, c.left, c.right);
p = s.p0;
q = s.p1;
}
}
this.md(g, p, c, k, true);
this.bp.a1(q);
var t = Math.min(n, o);
var u = Math.max(n, o);
var v = new LinearCategorySnapper(1, t, u, e.height, this.ro, this.categoryMode, this.go());
var w = v.g;
w = this.fp(w, this.rg(), b, c, d);
if (v.g != w) {
v = new LinearCategorySnapper(1, t, u, e.height, w, this.categoryMode, this.go());
}
var x = Math.floor((t - 0) / v.g);
var y = Math.ceil((u - 0) / v.g);
if (!isNaN_(x) && !isNaN_(y)) {
var z = truncate(x);
var aa = truncate(y);
var ab = this.f7(0 + z * v.g, f);
var ac = Math.abs(this.f7(v.g, f) - this.f7(0, f));
this.a1.b3 = this.f7(v.g, f);
for (var ad = z; ad <= aa; ++ad) {
var ae = this.f7(0 + (ad + 1) * v.g, f);
if (ab <= e.bottom) {
if (ad % 2 == 0) {
this.k7(h, ab, ae, c);
}
this.k6(i, ab, c, l, false);
this.pv.add(ab);
}
if (this.categoryMode != 0 && this.qe != 0 && this.eb) {
if (this.rp > 0 && this.rp < v.g) {
var af = ac * this.rp;
if (!this.dn) {
var ag = ab;
while (ag - af > ae) {
ag -= af;
if (Math.abs(ag - ae) < 0.0001) {
break;
}
this.k6(j, ag, c, m, false);
}
}
else {
var ah = ab;
while (ah + af < ae) {
ah += af;
if (Math.abs(ah - ae) < 0.0001) {
break;
}
this.k6(j, ah, c, m, false);
}
}
this.rk = this.rp;
}
else {
for (var ai = 0; ai < truncate(v.g); ai++) {
for (var aj = 0; aj < this.qe; aj++) {
var ak = this.getGroupCenter(aj, b, c, d);
if (!this.dn) {
ak = -ak;
}
var al = this.f7(ai + ad * v.g, f) + ak;
this.k6(j, al, c, m, false);
}
}
this.rk = 0.5;
}
}
var am = ab;
if (this.categoryMode != 0) {
var an = this.f7(ad * v.g + 1, f);
am = (ab + an) / 2;
}
if (am <= e.bottom && am >= e.top) {
var ao = 0;
if (v.g >= 1) {
ao = ad * truncate(Math.floor(v.g));
}
else {
if ((ad * v.g) * 2 % 2 == 0) {
ao = truncate(Math.floor(ad * v.g));
}
else {
ao = -1;
}
}
if (this.po != null && ao < this.po.count && ao >= 0) {
var ap = this.po.item(ao);
var aq = this.hy(ap);
if (!isNaN_(am) && !isInfinity(am) && aq != null) {
if ((typeof aq === 'string') && Base.equalsStatic(aq, "")) {
}
else {
this.er.add1(aq);
this.es.add(new LabelPosition(0, am));
}
}
}
}
ab = ae;
}
}
this.rj = v.g;
if ((this.a4 == null || this.a4.visibility == 0) && this.an != null) {
if (this.a4 != null && (this.a4.location == 6 || this.a4.location == 7)) {
this.b7.ps();
}
}
this.bp.a7(this.er, this.es);
this.q2();
}
};
CategoryYAxis.prototype.get_bm = function () {
return 1;
};
Object.defineProperty(CategoryYAxis.prototype, "bm", {
get: function () {
return this.get_bm();
},
enumerable: false,
configurable: true
});
Object.defineProperty(CategoryYAxis.prototype, "isVertical", {
get: function () {
return this.dz;
},
enumerable: false,
configurable: true
});
CategoryYAxis.prototype.j$d = function (a, b) {
return this.ga.apply(this, arguments);
};
CategoryYAxis.prototype.j$c = function (a, b) {
return this.f7.apply(this, arguments);
};
CategoryYAxis.prototype.j$e = function (a, b, c, d, e) {
this.k2.apply(this, arguments);
};
CategoryYAxis.prototype.j$f = function (a, b, c, d) {
this.k3.apply(this, arguments);
};
CategoryYAxis.prototype.j$g = function (a, b, c, d) {
this.k4.apply(this, arguments);
};
Object.defineProperty(CategoryYAxis.prototype, "j$b", {
get: function () {
return this.dn;
},
enumerable: false,
configurable: true
});
CategoryYAxis.prototype.j$a = function () {
return this.ag.apply(this, arguments);
};
CategoryYAxis.$t = markType(CategoryYAxis, 'CategoryYAxis', CategoryAxisBase.$, [IZoomableCategoryAxis_$type]);
CategoryYAxis.sb = DependencyProperty.i("Interval", Number_$type, CategoryYAxis.$, new PropertyMetadata(2, NaN, function (a, b) {
a.lu("Interval", b.oldValue, b.newValue);
a.l0(false);
}));
CategoryYAxis.sc = DependencyProperty.i("MinorInterval", Number_$type, CategoryYAxis.$, new PropertyMetadata(2, NaN, function (a, b) {
(typeCast(CategoryYAxis.$, a)).lu("MinorInterval", b.oldValue, b.newValue);
(typeCast(CategoryYAxis.$, a)).l0(false);
}));
CategoryYAxis.$$p = markDep(DependencyProperty, PropertyMetadata, CategoryYAxis, 'lu', ['CompanionAxisInterval:rl:r9', [1, NaN], 'CompanionAxisMinorInterval:rm:sa', [1, NaN], 'ZoomMaximumCategoryRange::sd', [1, NaN], 'ZoomMaximumItemSpan::se', [1, NaN], 'ZoomToCategoryRange::sf', [1, NaN], 'ZoomToCategoryStart::sg', [1, NaN], 'ZoomToItemSpan::sh', [1, NaN]]);
return CategoryYAxis;
}(CategoryAxisBase));
export { CategoryYAxis };
/**
* @hidden
*/
var CategoryYAxisView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(CategoryYAxisView, _super);
function CategoryYAxisView(a) {
var _this = _super.call(this, a) || this;
_this.bv = null;
_this.bv = a;
return _this;
}
CategoryYAxisView.prototype.as = function () {
_super.prototype.as.call(this);
this.c.g8 = AxisDefaults.categoryAxis_TickLength;
};
CategoryYAxisView.$t = markType(CategoryYAxisView, 'CategoryYAxisView', CategoryAxisBaseView.$);
return CategoryYAxisView;
}(CategoryAxisBaseView));
export { CategoryYAxisView };