igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
398 lines (397 loc) • 13.7 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 { LegendBase } from "./LegendBase";
import { IChartItemLegend_$type } from "igniteui-angular-core";
import { LegendBaseView } from "./LegendBaseView";
import { fromEn, delegateCombine, typeCast, fromEnum, markType } from "igniteui-angular-core";
import { ObservableCollection$1 } from "igniteui-angular-core";
import { UIElement } from "igniteui-angular-core";
import { ContentControl } from "igniteui-angular-core";
import { ILegendContext_$type } from "igniteui-angular-core";
import { LegendItemInfo } from "./LegendItemInfo";
import { LegendVisualData } from "./LegendVisualData";
import { LegendItemVisualData } from "./LegendItemVisualData";
import { RectData } from "igniteui-angular-core";
/**
* @hidden
*/
var ItemLegend = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ItemLegend, _super);
function ItemLegend() {
var _this = _super.call(this) || this;
_this.bb = null;
_this.bd = null;
_this.ab = ItemLegend.$;
_this.bb = _this.ak;
var a = _this.at;
a.collectionChanged = delegateCombine(a.collectionChanged, function (a, b) {
var e_1, _a, e_2, _b;
if (b.oldItems != null) {
try {
for (var _c = __values(fromEn(b.oldItems)), _d = _c.next(); !_d.done; _d = _c.next()) {
var c = _d.value;
_this.bb.ao(c);
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_d && !_d.done && (_a = _c.return))
_a.call(_c);
}
finally {
if (e_1)
throw e_1.error;
}
}
}
if (b.newItems != null) {
try {
for (var _e = __values(fromEn(b.newItems)), _f = _e.next(); !_f.done; _f = _e.next()) {
var d = _f.value;
_this.bb.y(d);
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_f && !_f.done && (_b = _e.return))
_b.call(_e);
}
finally {
if (e_2)
throw e_2.error;
}
}
}
});
return _this;
}
ItemLegend.prototype.aj = function () {
return new ItemLegendView(this);
};
ItemLegend.prototype.a8 = function (a) {
_super.prototype.a8.call(this, a);
this.bb = a;
};
ItemLegend.prototype.addChildInOrder = function (a, b) {
if (!this.ak.n()) {
return;
}
this.bl(b);
};
ItemLegend.prototype.get_isItemwise = function () {
return true;
};
ItemLegend.prototype.createItemwiseLegendItems = function (a, b) {
this.a0(a, b);
};
ItemLegend.prototype.a0 = function (a, b) {
var e_3, _a;
this.ak.ag();
this.clearLegendItemsForSeries(b);
if (b == null || a == null || a.count == 0) {
return;
}
try {
for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
var d = typeCast(ContentControl.$, c);
if (d != null && d.content != null) {
var e = typeCast(ILegendContext_$type, d.content);
if (e != null && !this.be(e)) {
this.at.add(c);
var f = new LegendItemInfo();
f.b = e;
f.c = c;
f.a = b;
if (e.legendLabel != null) {
f.d = e.legendLabel;
}
else {
f.d = e.itemLabel;
}
}
}
}
}
catch (e_3_1) {
e_3 = { error: e_3_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_3)
throw e_3.error;
}
}
this.ak.ah();
};
ItemLegend.prototype.createLegendItemsInsert = function (a, b) {
this.bk(a, b);
};
ItemLegend.prototype.bk = function (a, b) {
var e_4, _a;
this.ak.ag();
try {
var c = this.bf(b);
if (b == null || a == null || a.count == 0) {
return;
}
try {
for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
var d = _c.value;
var e = typeCast(ContentControl.$, d);
if (e != null && e.content != null) {
var f = typeCast(ILegendContext_$type, e.content);
if (f != null && !this.be(f)) {
this.at.insert(c, d);
c++;
var g = new LegendItemInfo();
g.b = f;
g.c = d;
g.a = b;
g.d = f.legendLabel != null ? f.legendLabel.toString() : f.itemLabel;
}
}
}
}
catch (e_4_1) {
e_4 = { error: e_4_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_4)
throw e_4.error;
}
}
}
finally {
this.ak.ah();
}
};
ItemLegend.prototype.renderItemwiseContent = function (a) {
this.bl(a);
};
ItemLegend.prototype.bl = function (a) {
var _this = this;
this.clearLegendItemsForSeries(a);
if (a.hasSubItems) {
var b_1 = this.bg(a);
a.forSubItems(function (c) {
var d = typeCast(ContentControl.$, c);
if (d != null && d.content != null) {
var e = typeCast(ILegendContext_$type, d.content);
if (e != null && !_this.be(e)) {
_this.at.insert(b_1, c);
var f = new LegendItemInfo();
f.b = e;
f.c = c;
f.a = a;
f.d = e.legendLabel != null ? e.legendLabel.toString() : e.itemLabel;
b_1++;
}
}
});
}
};
ItemLegend.prototype.bg = function (a) {
var e_5, _a;
var b = 0;
var c = a.resolveLegendIndex();
try {
for (var _b = __values(fromEnum(this.at)), _c = _b.next(); !_c.done; _c = _b.next()) {
var d = _c.value;
var e = typeCast(ContentControl.$, d);
if (e != null && e.content != null) {
var f = typeCast(ILegendContext_$type, e.content);
var g = f.series;
var h = g.resolveLegendIndex();
if (c == h) {
if (!a.isLayer) {
return b;
}
}
else if (h > c) {
return b;
}
}
b++;
}
}
catch (e_5_1) {
e_5 = { error: e_5_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_5)
throw e_5.error;
}
}
return b;
};
ItemLegend.prototype.bf = function (a) {
var e_6, _a, e_7, _b;
if (a == null || this.at == null || this.at.count == 0) {
return 0;
}
var b = new ObservableCollection$1(UIElement.$, 0);
var c = -1;
var d = 0;
try {
for (var _c = __values(fromEnum(this.at)), _d = _c.next(); !_d.done; _d = _c.next()) {
var e = _d.value;
var f = typeCast(ContentControl.$, e);
if (f != null && f.content != null) {
var g = typeCast(ILegendContext_$type, f.content);
if (g != null && g.series == a) {
if (c == -1) {
c = d;
}
b.add(e);
}
}
d++;
}
}
catch (e_6_1) {
e_6 = { error: e_6_1 };
}
finally {
try {
if (_d && !_d.done && (_a = _c.return))
_a.call(_c);
}
finally {
if (e_6)
throw e_6.error;
}
}
try {
for (var _e = __values(fromEnum(b)), _f = _e.next(); !_f.done; _f = _e.next()) {
var h = _f.value;
this.at.remove(h);
}
}
catch (e_7_1) {
e_7 = { error: e_7_1 };
}
finally {
try {
if (_f && !_f.done && (_b = _e.return))
_b.call(_e);
}
finally {
if (e_7)
throw e_7.error;
}
}
if (c == -1) {
return this.at.count;
}
return c;
};
ItemLegend.prototype.be = function (a) {
return this.bb.aq(a);
};
Object.defineProperty(ItemLegend.prototype, "bc", {
get: function () {
return this.ak.l ? 0 : 1;
},
set: function (a) {
this.ak.l = a == 0;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ItemLegend.prototype, "bi", {
get: function () {
return this.ak.w;
},
set: function (a) {
this.ak.w = a;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ItemLegend.prototype, "bj", {
get: function () {
return this.ak.x;
},
set: function (a) {
this.ak.x = a;
},
enumerable: false,
configurable: true
});
ItemLegend.$t = markType(ItemLegend, 'ItemLegend', LegendBase.$, [IChartItemLegend_$type]);
return ItemLegend;
}(LegendBase));
export { ItemLegend };
/**
* @hidden
*/
var ItemLegendView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ItemLegendView, _super);
function ItemLegendView(a) {
var _this = _super.call(this, a) || this;
_this.ap = null;
_this.ap = a;
return _this;
}
ItemLegendView.prototype.al = function () {
_super.prototype.al.call(this);
};
ItemLegendView.prototype.get_k = function () {
return true;
};
ItemLegendView.prototype.aq = function (a) {
return this.d.e(a);
};
ItemLegendView.prototype.g = function () {
var a = new LegendVisualData();
var b = this.d.g.rootWrapper;
b = b.getChildAt(0);
var c = b.getChildCount();
for (var d = 0; d < c; d++) {
var e = new LegendItemVisualData();
var f = b.getChildAt(d);
e.label = f.getText();
e.label = e.label != null ? e.label.trim() : null;
e.bounds = new RectData(f.getOffset().left, f.getOffset().top, f.width(), f.height());
e.labelBounds = this.i(f);
e.badgeBounds = this.h(f);
a.items.add(e);
}
if (c == a.items.count) {
for (var g = 0; g < c; g++) {
a.items._inner[g].appearance.fill = this.a(g);
a.items._inner[g].appearance.stroke = this.b(g);
}
}
return a;
};
ItemLegendView.$t = markType(ItemLegendView, 'ItemLegendView', LegendBaseView.$);
return ItemLegendView;
}(LegendBaseView));
export { ItemLegendView };