UNPKG

igniteui-angular-charts

Version:

Ignite UI Angular charting components for building rich data visualizations for modern web apps.

265 lines (264 loc) 9.31 kB
/* 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-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 */ export let ItemLegend = /*@__PURE__*/ (() => { class ItemLegend extends LegendBase { constructor() { super(); this.bb = null; this.bd = null; this.ab = ItemLegend.$; this.bb = this.ak; let a = this.at; a.collectionChanged = delegateCombine(a.collectionChanged, (a, b) => { if (b.oldItems != null) { for (let c of fromEn(b.oldItems)) { this.bb.ao(c); } } if (b.newItems != null) { for (let d of fromEn(b.newItems)) { this.bb.y(d); } } }); } aj() { return new ItemLegendView(this); } a8(a) { super.a8(a); this.bb = a; } addChildInOrder(a, b) { if (!this.ak.n()) { return; } this.bl(b); } get_isItemwise() { return true; } createItemwiseLegendItems(a, b) { this.a0(a, b); } a0(a, b) { this.ak.ag(); this.clearLegendItemsForSeries(b); if (b == null || a == null || a.count == 0) { 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.be(e)) { this.at.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.ak.ah(); } createLegendItemsInsert(a, b) { this.bk(a, b); } bk(a, b) { this.ak.ag(); try { let c = this.bf(b); if (b == null || a == null || a.count == 0) { 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.be(f)) { this.at.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; } } } } finally { this.ak.ah(); } } renderItemwiseContent(a) { this.bl(a); } bl(a) { this.clearLegendItemsForSeries(a); if (a.hasSubItems) { let b = this.bg(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.be(e)) { this.at.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; b++; } } }); } } bg(a) { let b = 0; let c = a.resolveLegendIndex(); for (let d of fromEnum(this.at)) { 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; } bf(a) { if (a == null || this.at == null || this.at.count == 0) { return 0; } let b = new ObservableCollection$1(UIElement.$, 0); let c = -1; let d = 0; for (let e of fromEnum(this.at)) { 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.at.remove(h); } if (c == -1) { return this.at.count; } return c; } be(a) { return this.bb.aq(a); } get bc() { return this.ak.l ? 0 : 1; } set bc(a) { this.ak.l = a == 0; } get bi() { return this.ak.w; } set bi(a) { this.ak.w = a; } get bj() { return this.ak.x; } set bj(a) { this.ak.x = a; } } ItemLegend.$t = 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 = markType(ItemLegendView, 'ItemLegendView', LegendBaseView.$); return ItemLegendView; })();