igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
259 lines (258 loc) • 9.17 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, __read, __spreadArray, __values } from "tslib";
import { Base, typeCast, runOn, delegateRemove, delegateCombine, fromEnum, markType } from "igniteui-react-core";
import { IAxisAnnotationManager_$type } from "./IAxisAnnotationManager";
import { DeviceUtils } from "igniteui-react-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { AxisAnnotation } from "./AxisAnnotation";
import { LabelPosition } from "./LabelPosition";
import { MathUtil } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { BrushUtilCore } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
/**
* @hidden
*/
var AxisAnnotationManager = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(AxisAnnotationManager, _super);
function AxisAnnotationManager() {
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
_this._owner = null;
return _this;
}
Object.defineProperty(AxisAnnotationManager.prototype, "owner", {
get: function () {
return this._owner;
},
set: function (a) {
this._owner = a;
},
enumerable: false,
configurable: true
});
AxisAnnotationManager.prototype.onAddAnnotations = function (a) {
var b = 0;
for (var c = 0; c < a.at.count; c++) {
b = this.b(a, a.at._inner[c], b);
}
for (var d = 0; d < a.as.count; d++) {
b = this.b(a, a.as._inner[d], b);
}
a.cf.count = b;
a.ce.count = b;
a.ch.count = b;
a.cg.count = b;
};
AxisAnnotationManager.a = function (a) {
if (isNaN_(a) || a < 0) {
return DeviceUtils.g(3);
}
return a;
};
AxisAnnotationManager.prototype.b = function (a, b, c) {
var d = NaN;
d = b.value;
if (typeCast(AxisAnnotation.$, b) !== null) {
var e = b.m;
if (e && a.df && !a.dj) {
var f = typeCast(CategoryAxisBase.$, a);
if (f.categoryMode != 0) {
d = d + 0.5;
}
}
}
var g = new LabelPosition(0, a.gt(d));
if (a.dg) {
var h = a;
if (h.categoryMode == 2) {
var i = a.b7.yr;
var j = a.o6;
var k = a.o1();
g.h += (a.dn ? -h.getCategorySize(i, j, k) * 0.5 : h.getCategorySize(i, j, k) * 0.5);
}
}
var l = g.h;
if (a.dy) {
if ((g.h > a.o6.bottom && !MathUtil.a(g.h, a.o6.bottom)) || (g.h < a.o6.top && !MathUtil.a(g.h, a.o6.top))) {
return c;
}
}
else {
if ((g.h > a.o6.right && !MathUtil.a(g.h, a.o6.right)) || (g.h < a.o6.left && !MathUtil.a(g.h, a.o6.left))) {
return c;
}
}
var m = a.cf.item(c);
var n = a.ch.item(c);
var o = a.cg.item(c);
var p = 100 + c * 2;
c++;
AxisAnnotationManager.f(b, n);
AxisAnnotationManager.d(b, m);
AxisAnnotationManager.e(b, o, n.al != null && n.al.length > 0);
o.ah = a;
AxisAnnotationManager.g(m, n, o, p);
b.checkForExtentReset(function () { return g.d = true; });
g.b = true;
g.a = b.isBadgeEnabled;
g.e = b.isBadgeEnabled ? o.a7().width : 0;
g.i = b.backgroundPadding;
g.g = b.backgroundCornerRadius;
g.c = b.isPillShaped;
a.er.add(g);
a.eq.add1(n.al);
return c;
};
AxisAnnotationManager.g = function (a, b, c, d) {
a.s = d;
c.s = d + 1;
b.s = d + 1;
};
AxisAnnotationManager.f = function (a, b) {
b.al = a.resolveLabelValue();
if (a.textColor != null) {
b.ao = a.textColor;
}
};
AxisAnnotationManager.d = function (a, b) {
b._fill = a.background;
b.ap = AxisAnnotationManager.a(a.backgroundCornerRadius);
b.aq = AxisAnnotationManager.a(a.backgroundCornerRadius);
b._stroke = a.outline;
b.ad = a.strokeThickness;
};
AxisAnnotationManager.e = function (a, b, c) {
b.am = DeviceUtils.g(a.badgeSize);
b.bb = new Thickness(1, 0, 0, c ? a.badgeMargin : 0, 0);
b.a5 = a.badgeBackground;
b.al = a.badgeCornerRadius;
b.a6 = a.badgeOutline;
b.ba = a.badgeOutline == null || BrushUtilCore.a(a.badgeOutline) ? new Thickness(0, 0) : new Thickness(0, a.badgeOutlineThickness);
b._visibility = a.isBadgeEnabled ? 0 : 1;
b.as = a.badgeImagePath;
};
AxisAnnotationManager.prototype.arrangeAnnotations = function (a, b, c, d, e, f, g, h, i, j) {
for (var k = 0; k < a.ch.count; k++) {
var l = a.cf.item(k);
var m = a.ce.item(k);
var n = a.cg.item(k);
var o = -1;
for (var p = c.count - 1; p >= 0; p--) {
if (c._inner[p] == a.ch.item(k)) {
o = p;
break;
}
}
if (o == -1) {
continue;
}
var q = a.er._inner[o];
if (e) {
var r = b.av(l, a.ch.item(k), n, q, d._inner[o], g, h, i, j);
b.aq(l, a.ch.item(k), n, q, d._inner[o], g, h, i, j, f);
m.d = r.x;
m.e = r.y;
m.f = r.width;
m.c = r.height;
}
else {
var s = b.av(l, a.ch.item(k), n, q, d._inner[o], g, h, i, j);
b.ac(l, n);
m.d = s.x;
m.e = s.y;
m.f = s.width;
m.c = s.height;
}
if (q.c) {
l.ap = m.c * 0.5;
l.aq = l.ap;
}
}
};
AxisAnnotationManager.prototype.c = function (a, b) {
this.owner.d0 = true;
this.owner.lx();
};
AxisAnnotationManager.prototype.h = function (a) {
if (a.oldItems != null) {
for (var b = 0; b < a.oldItems.count; b++) {
var c = a.oldItems.item(b);
if (c == null) {
continue;
}
var d = c;
d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.c));
}
}
if (a.newItems != null) {
for (var e = 0; e < a.newItems.count; e++) {
var f = a.newItems.item(e);
if (f == null) {
continue;
}
var g = f;
g.propertyChanged = delegateCombine(g.propertyChanged, runOn(this, this.c));
}
}
this.owner.d0 = true;
this.owner.lx();
};
AxisAnnotationManager.prototype.onAnnotionsChanged = function (a, b, c) {
this.h(c);
};
AxisAnnotationManager.prototype.onAnnotionsReset = function (a, b, c) {
var e_1, _a;
try {
for (var _b = __values(fromEnum(b)), _c = _b.next(); !_c.done; _c = _b.next()) {
var d = _c.value;
d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.c));
}
}
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;
}
}
};
AxisAnnotationManager.prototype.onAutoAnnotionsChanged = function (a, b, c) {
this.h(c);
};
AxisAnnotationManager.prototype.onAutoAnnotionsReset = function (a, b, c) {
var e_2, _a;
try {
for (var _b = __values(fromEnum(b)), _c = _b.next(); !_c.done; _c = _b.next()) {
var d = _c.value;
d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.c));
}
}
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;
}
}
};
AxisAnnotationManager.$t = markType(AxisAnnotationManager, 'AxisAnnotationManager', Base.$, [IAxisAnnotationManager_$type]);
return AxisAnnotationManager;
}(Base));
export { AxisAnnotationManager };