UNPKG

igniteui-webcomponents-charts

Version:

Ignite UI Web Components charting components for building rich data visualizations using TypeScript APIs.

151 lines (150 loc) 5.77 kB
import { WebComponentRenderer } from "igniteui-webcomponents-core"; import { TypeRegistrar } from "igniteui-webcomponents-core"; import { IgcPieChartBaseComponent } from './igc-pie-chart-base-component'; import { DataChartStylingDefaults } from './DataChartStylingDefaults'; import { XamPieChart } from './XamPieChart'; import { getAllPropertyNames, toSpinal, NamePatcher } from "igniteui-webcomponents-core"; import { RegisterElementHelper } from "igniteui-webcomponents-core"; export let IgcPieChartComponent = /*@__PURE__*/ (() => { class IgcPieChartComponent extends IgcPieChartBaseComponent { set height(value) { this._height = value; this.style.height = value; this.notifyContainerResized(); } get height() { return this._height; } set width(value) { this._width = value; this.style.width = value; this.notifyContainerResized(); } get width() { return this._width; } notifyContainerResized() { this._chart.notifyContainerResized(); } constructor() { super(); this._disconnected = false; this._dataSource = null; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._renderer = new WebComponentRenderer(this, document, true, DataChartStylingDefaults); this._implementation = this.createImplementation(); this.container = this._renderer.createElement("div"); this._renderer.updateRoot(this.container); //this._renderer.rootWrapper.append(this._container); this.container.setStyleProperty("display", "block"); this.container.setStyleProperty("width", "100%"); this.container.setStyleProperty("height", "100%"); var root; root = this.container; if (this.container.getNativeElement() != null) { root = this.container.getNativeElement(); } this._wrapper = this._renderer; var chart = this.i; this._chart = chart; chart.provideContainer(this._renderer); this.bindData(); chart.notifyContainerResized(); this._renderer.addSizeWatcher(() => { this._chart.notifyContainerResized(); }); } disconnectedCallback() { this._disconnected = true; if (this.i) { this.i.onDetachedFromUI(); } } connectedCallback() { if (this._disconnected) { this._disconnected = false; if (this.i) { this.i.onAttachedToUI(); } return; } this.classList.add("ig-pie-chart"); this.classList.add("igc-pie-chart"); this.appendChild(this.container.getNativeElement()); this._attached = true; this.style.display = "block"; this.style.height = this._height; this.style.width = this._width; this._flushQueuedAttributes(); // supports themes or custom properties set in CSS this._styling(this, this); } destroy() { this._chart.destroy(); this._wrapper.destroy(); } createImplementation() { return new XamPieChart(); } get i() { return this._implementation; } createSeriesComponent(type) { if (TypeRegistrar.isRegistered(type)) { let s = TypeRegistrar.create(type); s.owner = this; s._provideRenderer(this._renderer); return s; } else { //we shouldn't get here, hopefully. throw Error("series type not loaded: " + type); } } set dataSource(value) { this._dataSource = value; this.bindData(); } get dataSource() { return this._dataSource; } bindData() { if (this._chart != null && this._chart !== undefined) { this._chart.itemsSource = this._dataSource; } } /** * Gets or sets the legend used for the current chart. */ get legend() { if (this.i.legend != null) return this.i.legend.externalObject; } set legend(v) { if (v != undefined && v != null) this.i.legend = v.i; } static get observedAttributes() { if (IgcPieChartComponent._observedAttributesIgcPieChartComponent == null) { let names = getAllPropertyNames(IgcPieChartComponent); for (let i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcPieChartComponent._observedAttributesIgcPieChartComponent = names; } return IgcPieChartComponent._observedAttributesIgcPieChartComponent; } static register() { if (!IgcPieChartComponent._isElementRegistered) { IgcPieChartComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcPieChartComponent.htmlTagName, IgcPieChartComponent); } } } IgcPieChartComponent._observedAttributesIgcPieChartComponent = null; IgcPieChartComponent.htmlTagName = "igc-pie-chart"; IgcPieChartComponent._isElementRegistered = false; return IgcPieChartComponent; })();