igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
279 lines (278 loc) • 9.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 { LegendBase } from "./LegendBase";
import { IChartItemLegend_$type } from "igniteui-react-core";
import { LegendBaseView } from "./LegendBaseView";
import { fromEn, delegateCombine, typeCast, fromEnum, markType } from "igniteui-react-core";
import { ObservableCollection$1 } from "igniteui-react-core";
import { UIElement } from "igniteui-react-core";
import { ContentControl } from "igniteui-react-core";
import { ILegendContext_$type } from "igniteui-react-core";
import { LegendItemInfo } from "./LegendItemInfo";
import { LegendVisualData } from "./LegendVisualData";
import { LegendItemVisualData } from "./LegendItemVisualData";
import { RectData } from "igniteui-react-core";
/**
* @hidden
*/
export let ItemLegend = /*@__PURE__*/ (() => {
class ItemLegend extends LegendBase {
aj() {
return new ItemLegendView(this);
}
bd(a) {
super.bd(a);
this.bg = a;
}
constructor() {
super();
this.bg = null;
this.bi = null;
this.ab = ItemLegend.$;
this.bg = this.ak;
let a = this.aw;
a.collectionChanged = delegateCombine(a.collectionChanged, (a, b) => {
if (b.oldItems != null) {
for (let c of fromEn(b.oldItems)) {
this.bg.ao(c);
}
}
if (b.newItems != null) {
for (let d of fromEn(b.newItems)) {
this.bg.y(d);
}
}
});
}
addChildInOrder(a, b) {
if (!this.ak.n()) {
return;
}
this.bq(b);
}
get_isItemwise() {
return true;
}
createItemwiseLegendItems(a, b) {
this.a5(a, b);
}
a5(a, b) {
this.ak.ag();
this.clearLegendItemsForSeries(b);
if (b == null || a == null || a.count == 0) {
this.flushTextContentChangedCheck();
return;
}
for (let c of fromEnum(a)) {
let d = typeCast(ContentControl.$, c);
if (d != null && d.content != null) {
let e = typeCast(ILegendContext_$type, d.content);
if (e != null && !this.bj(e)) {
this.aw.add(c);
let 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;
}
this.ax.add(f);
}
}
}
this.flushTextContentChangedCheck();
this.ak.ah();
}
createLegendItemsInsert(a, b) {
this.bp(a, b);
}
bp(a, b) {
this.ak.ag();
try {
let c = this.bk(b);
if (b == null || a == null || a.count == 0) {
this.flushTextContentChangedCheck();
return;
}
for (let d of fromEnum(a)) {
let e = typeCast(ContentControl.$, d);
if (e != null && e.content != null) {
let f = typeCast(ILegendContext_$type, e.content);
if (f != null && !this.bj(f)) {
this.aw.insert(c, d);
c++;
let g = new LegendItemInfo();
g.b = f;
g.c = d;
g.a = b;
g.d = f.legendLabel != null ? f.legendLabel.toString() : f.itemLabel;
this.ax.add(g);
}
}
}
}
finally {
this.flushTextContentChangedCheck();
this.ak.ah();
}
}
renderItemwiseContent(a) {
this.bq(a);
}
bq(a) {
this.clearLegendItemsForSeries(a);
if (a.hasSubItems) {
let b = this.bl(a);
a.forSubItems((c) => {
let d = typeCast(ContentControl.$, c);
if (d != null && d.content != null) {
let e = typeCast(ILegendContext_$type, d.content);
if (e != null && !this.bj(e)) {
this.aw.insert(b, c);
let f = new LegendItemInfo();
f.b = e;
f.c = c;
f.a = a;
f.d = e.legendLabel != null ? e.legendLabel.toString() : e.itemLabel;
this.ax.insert(b, f);
b++;
}
}
});
}
this.flushTextContentChangedCheck();
}
bl(a) {
let b = 0;
let c = a.resolveLegendIndex();
for (let d of fromEnum(this.aw)) {
let e = typeCast(ContentControl.$, d);
if (e != null && e.content != null) {
let f = typeCast(ILegendContext_$type, e.content);
let g = f.series;
let h = g.resolveLegendIndex();
if (c == h) {
if (!a.isLayer) {
return b;
}
}
else if (h > c) {
return b;
}
}
b++;
}
return b;
}
bk(a) {
if (a == null || this.aw == null || this.aw.count == 0) {
return 0;
}
let b = new ObservableCollection$1(UIElement.$, 0);
let c = -1;
let d = 0;
for (let e of fromEnum(this.aw)) {
let f = typeCast(ContentControl.$, e);
if (f != null && f.content != null) {
let g = typeCast(ILegendContext_$type, f.content);
if (g != null && g.series == a) {
if (c == -1) {
c = d;
}
b.add(e);
}
}
d++;
}
for (let h of fromEnum(b)) {
this.aw.remove(h);
}
if (c == -1) {
return this.aw.count;
}
return c;
}
bj(a) {
return this.bg.aq(a);
}
get bh() {
return this.ak.l ? 0 : 1;
}
set bh(a) {
let b = this.ak.l;
this.ak.l = a == 0;
if (b != this.ak.l) {
}
}
get bn() {
return this.ak.w;
}
set bn(a) {
this.ak.w = a;
}
get bo() {
return this.ak.x;
}
set bo(a) {
let b = this.ak.x;
this.ak.x = a;
if (b != a) {
}
}
}
ItemLegend.$t = /*@__PURE__*/ markType(ItemLegend, 'ItemLegend', LegendBase.$, [IChartItemLegend_$type]);
return ItemLegend;
})();
/**
* @hidden
*/
export let ItemLegendView = /*@__PURE__*/ (() => {
class ItemLegendView extends LegendBaseView {
constructor(a) {
super(a);
this.ap = null;
this.ap = a;
}
al() {
super.al();
}
get_k() {
return true;
}
aq(a) {
return this.d.e(a);
}
g() {
let a = new LegendVisualData();
let b = this.d.g.rootWrapper;
b = b.getChildAt(0);
let c = b.getChildCount();
for (let d = 0; d < c; d++) {
let e = new LegendItemVisualData();
let 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 (let 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 = /*@__PURE__*/ markType(ItemLegendView, 'ItemLegendView', LegendBaseView.$);
return ItemLegendView;
})();