UNPKG

igniteui-webcomponents-charts

Version:

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

368 lines (366 loc) 15.6 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 { WebComponentRenderer, WebComponentWrapper } from "igniteui-webcomponents-core"; import { TypeRegistrar } from "igniteui-webcomponents-core"; import { DataPieChart } from './DataPieChart'; import { DataPieChartType_$type } from './DataPieChartType'; import { CategoryTransitionInMode_$type } from './CategoryTransitionInMode'; import { TransitionInSpeedType_$type } from './TransitionInSpeedType'; import { ensureEnum, ensureBool, NamePatcher, enumToString, getAllPropertyNames, toSpinal } from "igniteui-webcomponents-core"; import { DataChartStylingDefaults } from './DataChartStylingDefaults'; import { DataSeriesType } from "igniteui-webcomponents-core"; import { IgcDataContext } from "igniteui-webcomponents-core"; import { IgcProportionalCategoryAngleAxisComponent } from './igc-proportional-category-angle-axis-component'; import { IgcNumericRadiusAxisComponent } from './igc-numeric-radius-axis-component'; import { RegisterElementHelper } from "igniteui-webcomponents-core"; import { IgcDataPieBaseChartComponent } from './igc-data-pie-base-chart-component'; /** * Represents a DataPie chart control that can plot DataPie data */ export let IgcDataPieChartComponent = /*@__PURE__*/ (() => { class IgcDataPieChartComponent extends IgcDataPieBaseChartComponent { set height(value) { this._height = value; this.style.height = value; this.notifyResized(); } get height() { return this._height; } set width(value) { this._width = value; this.style.width = value; this.notifyResized(); } get width() { return this._width; } constructor() { super(); this._disconnected = false; this._dataSource = null; this._defaultTooltips = 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%"); this._wrapper = this._renderer; var chart = this.i; this._chart = chart; if (chart.angleAxis) { let x = document.createElement("igc-proportional-category-angle-axis"); //new IgcCategoryXAxisComponent(); //(<any>x)._provideRenderer(this._renderer); x._implementation = chart.angleAxis; chart.angleAxis.externalObject = x; } if (chart.valueAxis) { let y = document.createElement("igc-numeric-radius-axis"); //(<any>y)._provideRenderer(this._renderer); y._implementation = chart.valueAxis; chart.valueAxis.externalObject = y; } chart.provideContainer(this._renderer); this.bindData(); chart.notifyResized(); this._renderer.addSizeWatcher(() => { this._chart.notifyResized(); }); //this._initialized = true; } destroy() { this._chart.destroy(); this._wrapper.destroy(); } 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-data-pie-chart"); this.classList.add("igc-data-pie-chart"); this.appendChild(this._renderer.rootWrapper.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); this.afterContentInit(); } afterContentInit() { this.initializeContent(); } createImplementation() { return new DataPieChart(); } get i() { return this._implementation; } createSeriesComponent(type) { if (TypeRegistrar.isRegistered(type)) { let s = TypeRegistrar.create(type); s.owner = this; s._provideRenderer(this._wrapper); return s; } else { //we shouldn't get here, hopefully. throw Error("series type not loaded: " + type); } } createSeries(type) { switch (type) { case DataSeriesType.Pie: return this.createSeriesComponent('IgcRadialPieSeriesComponent'); case DataSeriesType.ItemToolTipLayer: return this.createSeriesComponent('IgcItemToolTipLayerComponent'); case DataSeriesType.CategoryToolTipLayer: return this.createSeriesComponent('IgcCategoryToolTipLayerComponent'); case DataSeriesType.CrosshairLayer: return this.createSeriesComponent('IgcCrosshairLayerComponent'); case DataSeriesType.FinalValueLayer: return this.createSeriesComponent('IgcFinalValueLayerComponent'); case DataSeriesType.CalloutLayer: return this.createSeriesComponent('IgcCalloutLayerComponent'); case DataSeriesType.CategoryHighlightLayer: return this.createSeriesComponent('IgcCategoryHighlightLayerComponent'); case DataSeriesType.CategoryItemHighlightLayer: return this.createSeriesComponent('IgcCategoryItemHighlightLayerComponent'); case DataSeriesType.DataToolTipLayer: return this.createSeriesComponent('IgcDataToolTipLayerComponent'); case DataSeriesType.ValueLayer: return this.createSeriesComponent('IgcValueLayerComponent'); default: return this.createSeriesComponent('IgcRadialPieSeriesComponent'); } } 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; } } initializeContent() { if (TypeRegistrar.isRegistered("IgcDataChartDefaultTooltipsComponent")) { let d = TypeRegistrar.create("IgcDataChartDefaultTooltipsComponent"); this._defaultTooltips = d; this._onDefaultTooltipsReady(d); //this._container.appendChild(cr.location.nativeElement); } // supports angular themes or custom properties set in CSS this._styling(this, this); this._chart.notifyResized(); } createTooltip() { if (!TypeRegistrar.isRegistered("IgcTooltipContainerComponent")) { return null; } let cr = TypeRegistrar.create("IgcTooltipContainerComponent"); let ele = cr; let self = this; ele.updateToolTip = function (c, isSubContent) { if (c.externalObject) { c = c.externalObject; } else { let ext = new IgcDataContext(); ext._implementation = c; c = ext; } if (!isSubContent) { if (ele.parentElement != self._container.getNativeElement()) { if (ele.parentElement != null) { ele.parentElement.removeChild(ele); } self._container.getNativeElement().appendChild(ele); } } else { c.isSubContent = true; } cr.context = c; ele.style.display = "block"; return true; }; ele.hideToolTip = function () { ele.style.display = "none"; }; ele.style.display = "none"; return cr; } _ensureTooltipCreated(series) { series._ensureTooltipCreated(() => this.createTooltip(), (ele) => { let wrapper = new WebComponentWrapper(ele, this._renderer); wrapper.updateToolTip = ele.updateToolTip; wrapper.hideToolTip = ele.hideToolTip; return wrapper; }); } _createAngleAxis() { let x = new IgcProportionalCategoryAngleAxisComponent(); x._provideRenderer(this._wrapper); return x.i; } _createValueAxis() { let y = new IgcNumericRadiusAxisComponent(); y.provideRenderer(this._wrapper); return y.i; } _ensureDefaultTooltip(series) { if (this._defaultTooltips == null) { return; } this._defaultTooltips["ensureDefaultTooltip"](series); } _onDefaultTooltipsReady(cr) { if (this.i.dataChart) { var currSeries = this.i.dataChart.series; for (var i = 0; i < currSeries.count; i++) { if (currSeries.item(i).externalObject.showDefaultTooltip) { this._ensureDefaultTooltip(currSeries.item(i).externalObject); } } } } static get observedAttributes() { if (IgcDataPieChartComponent._observedAttributesIgcDataPieChartComponent == null) { let names = getAllPropertyNames(IgcDataPieChartComponent); for (let i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcDataPieChartComponent._observedAttributesIgcDataPieChartComponent = names; } return IgcDataPieChartComponent._observedAttributesIgcDataPieChartComponent; } static register() { if (!IgcDataPieChartComponent._isElementRegistered) { IgcDataPieChartComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcDataPieChartComponent.htmlTagName, IgcDataPieChartComponent); } } /** * Gets or sets the duration used for animating series plots when the chart is loading into view */ get transitionInDuration() { return this.i.al7; } set transitionInDuration(v) { this.i.al7 = +v; this._a("transitionInDuration", this.i.al7); } /** * Gets or sets the duration used for animating series plots when the series is leaving view */ get transitionOutDuration() { return this.i.al8; } set transitionOutDuration(v) { this.i.al8 = +v; this._a("transitionOutDuration", this.i.al8); } /** * Gets or sets the easing function used for animating series plots when the chart is loading into view * This can be set to one of the known values "linear" or "cubic," or it can be set to an easing function which takes a single numeric parameter and returns a number. */ get transitionInEasingFunction() { return this.i.al1; } set transitionInEasingFunction(v) { this.i.al1 = v; } /** * Gets or sets the easing function used for animating series plots when the chart is loading into view * This can be set to one of the known values "linear" or "cubic," or it can be set to an easing function which takes a single numeric parameter and returns a number. */ get transitionOutEasingFunction() { return this.i.al2; } set transitionOutEasingFunction(v) { this.i.al2 = v; } /** * Gets the domain type of this chart */ get domainType() { return this.i.cb; } /** * Gets or sets the type of chart series to generate from the data. */ get chartType() { return this.i.alw; } set chartType(v) { this.i.alw = ensureEnum(DataPieChartType_$type, v); this._a("chartType", enumToString(DataPieChartType_$type, this.i.alw)); } /** * Gets or sets whether animation of series plots is enabled when the chart is loading into view */ get isTransitionInEnabled() { return this.i.al4; } set isTransitionInEnabled(v) { this.i.al4 = ensureBool(v); this._a("isTransitionInEnabled", this.i.al4); } /** * Gets or sets the method that determines how to animate series plots when the chart is loading into view */ get transitionInMode() { return this.i.alu; } set transitionInMode(v) { this.i.alu = ensureEnum(CategoryTransitionInMode_$type, v); this._a("transitionInMode", enumToString(CategoryTransitionInMode_$type, this.i.alu)); } /** * Gets or sets the arrival speed used for animating series plots when the chart is loading into view */ get transitionInSpeedType() { return this.i.aly; } set transitionInSpeedType(v) { this.i.aly = ensureEnum(TransitionInSpeedType_$type, v); this._a("transitionInSpeedType", enumToString(TransitionInSpeedType_$type, this.i.aly)); } /** * Export serialized visual data. */ exportSerializedVisualData() { let iv = this.i.ama(); return (iv); } } IgcDataPieChartComponent._observedAttributesIgcDataPieChartComponent = null; IgcDataPieChartComponent.htmlTagName = "igc-data-pie-chart"; IgcDataPieChartComponent._isElementRegistered = false; return IgcDataPieChartComponent; })();