UNPKG

igniteui-angular-charts

Version:

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

416 lines (414 loc) 18.2 kB
import { __extends } from "tslib"; import { Component, ViewContainerRef, ViewChild, Input, ChangeDetectionStrategy } from '@angular/core'; import { AngularRenderer, AngularWrapper } from "igniteui-angular-core"; import { TypeRegistrar } from "igniteui-angular-core"; import { DataPieChart } from './DataPieChart'; import { DataPieChartType_$type } from './DataPieChartType'; import { CategoryTransitionInMode_$type } from './CategoryTransitionInMode'; import { TransitionInSpeedType_$type } from './TransitionInSpeedType'; import { ensureEnum, ensureBool, NamePatcher } from "igniteui-angular-core"; import { DataChartStylingDefaults } from './DataChartStylingDefaults'; import { DataSeriesType } from "igniteui-angular-core"; import { IgxDataContext } from "igniteui-angular-core"; import { IgxProportionalCategoryAngleAxisComponent } from './igx-proportional-category-angle-axis-component'; import { IgxNumericRadiusAxisComponent } from './igx-numeric-radius-axis-component'; import { IgxDataPieBaseChartComponent } from './igx-data-pie-base-chart-component'; import * as i0 from "@angular/core"; /** * Represents a DataPie chart control that can plot DataPie data */ var IgxDataPieChartComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgxDataPieChartComponent, _super); function IgxDataPieChartComponent(renderer, _elRef, ngZone, injector, componentFactoryResolver) { var _this = _super.call(this) || this; _this.renderer = renderer; _this._elRef = _elRef; _this.ngZone = ngZone; _this.injector = injector; _this.componentFactoryResolver = componentFactoryResolver; _this._dataSource = null; _this._defaultTooltips = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._zoneRunner = function (act) { return ngZone.run(act); }; _this.container = renderer.createElement("div"); renderer.appendChild(_elRef.element.nativeElement, _this.container); renderer.setStyle(_this.container, "display", "block"); renderer.setStyle(_this.container, "width", "100%"); renderer.setStyle(_this.container, "height", "100%"); var root; root = _this.container; if (_this.container != null) { root = _this.container; } var ren = new AngularRenderer(root, _this.renderer, window.document, _this.ngZone, true, DataChartStylingDefaults); _this._wrapper = ren; var chart = _this.i; _this._chart = chart; if (chart.angleAxis) { var x = new IgxProportionalCategoryAngleAxisComponent(); x._provideRenderer(ren); x._implementation = chart.angleAxis; chart.angleAxis.externalObject = x; } if (chart.valueAxis) { var y = new IgxNumericRadiusAxisComponent(); y._provideRenderer(ren); y._implementation = chart.valueAxis; chart.valueAxis.externalObject = y; } chart.provideContainer(ren); _this.bindData(); chart.notifyResized(); ren.addSizeWatcher(function () { _this._chart.notifyResized(); }); return _this; } Object.defineProperty(IgxDataPieChartComponent.prototype, "height", { get: function () { return this._height; }, set: function (value) { this._height = value; this.renderer.setStyle(this._elRef.element.nativeElement, "height", value); this._chart.notifyResized(); }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "width", { get: function () { return this._width; }, set: function (value) { this._width = value; this.renderer.setStyle(this._elRef.element.nativeElement, "width", value); this._chart.notifyResized(); }, enumerable: false, configurable: true }); IgxDataPieChartComponent.prototype.ngOnDestroy = function () { this._chart.destroy(); this._wrapper.destroy(); }; IgxDataPieChartComponent.prototype.createImplementation = function () { return new DataPieChart(); }; Object.defineProperty(IgxDataPieChartComponent.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgxDataPieChartComponent.prototype.createSeriesComponent = function (type) { if (TypeRegistrar.isRegistered(type)) { var 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); } }; IgxDataPieChartComponent.prototype.createSeries = function (type) { switch (type) { case DataSeriesType.Pie: return this.createSeriesComponent('IgxRadialPieSeriesComponent'); case DataSeriesType.ItemToolTipLayer: return this.createSeriesComponent('IgxItemToolTipLayerComponent'); case DataSeriesType.CategoryToolTipLayer: return this.createSeriesComponent('IgxCategoryToolTipLayerComponent'); case DataSeriesType.CrosshairLayer: return this.createSeriesComponent('IgxCrosshairLayerComponent'); case DataSeriesType.FinalValueLayer: return this.createSeriesComponent('IgxFinalValueLayerComponent'); case DataSeriesType.CalloutLayer: return this.createSeriesComponent('IgxCalloutLayerComponent'); case DataSeriesType.CategoryHighlightLayer: return this.createSeriesComponent('IgxCategoryHighlightLayerComponent'); case DataSeriesType.CategoryItemHighlightLayer: return this.createSeriesComponent('IgxCategoryItemHighlightLayerComponent'); case DataSeriesType.DataToolTipLayer: return this.createSeriesComponent('IgxDataToolTipLayerComponent'); case DataSeriesType.ValueLayer: return this.createSeriesComponent('IgxValueLayerComponent'); default: return this.createSeriesComponent('IgxRadialPieSeriesComponent'); } }; Object.defineProperty(IgxDataPieChartComponent.prototype, "dataSource", { get: function () { return this._dataSource; }, set: function (value) { this._dataSource = value; this.bindData(); }, enumerable: false, configurable: true }); IgxDataPieChartComponent.prototype.bindData = function () { if (this._chart != null && this._chart !== undefined) { this._chart.itemsSource = this._dataSource; } }; IgxDataPieChartComponent.prototype.ngAfterContentInit = function () { var _this = this; if (TypeRegistrar.isRegistered("IgxDataChartDefaultTooltipsComponent")) { var c = TypeRegistrar.get("IgxDataChartDefaultTooltipsComponent"); var cf = this.componentFactoryResolver.resolveComponentFactory(c); //let cr = cf.create(this.injector); var cr_1 = this._dynamicContent.createComponent(cf); this._defaultTooltips = cr_1; cr_1.instance.onContentReady.subscribe(function () { _this._onDefaultTooltipsReady(cr_1); }); this.container.appendChild(cr_1.location.nativeElement); } this._styling(this.container, this); }; IgxDataPieChartComponent.prototype.createTooltip = function () { if (!TypeRegistrar.isRegistered("IgxTooltipContainerComponent")) { return null; } var t = TypeRegistrar.get("IgxTooltipContainerComponent"); var cf = this.componentFactoryResolver.resolveComponentFactory(t); //let cr = cf.create(this.injector); var cr = this._dynamicContent.createComponent(cf); var ele = cr.location.nativeElement; var self = this; ele.updateToolTip = function (c, isSubContent) { if (c.externalObject) { c = c.externalObject; } else { var ext = new IgxDataContext(); ext._implementation = c; c = ext; } if (!isSubContent) { if (ele.parentElement != self.container) { if (ele.parentElement != null) { ele.parentElement.removeChild(ele); } self.container.appendChild(ele); } } else { c.isSubContent = true; } cr.instance.context = c; ele.style.display = "block"; return true; }; ele.hideToolTip = function () { ele.style.display = "none"; }; ele.style.display = "none"; return cr; }; IgxDataPieChartComponent.prototype._ensureTooltipCreated = function (series) { var _this = this; series._ensureTooltipCreated(function () { return _this.createTooltip(); }, function (ele) { var wrapper = new AngularWrapper(ele, _this.renderer, _this.ngZone); wrapper.updateToolTip = ele.updateToolTip; wrapper.hideToolTip = ele.hideToolTip; return wrapper; }); }; IgxDataPieChartComponent.prototype._createAngleAxis = function () { var x = new IgxProportionalCategoryAngleAxisComponent(); x._provideRenderer(this.renderer); return x.i; }; IgxDataPieChartComponent.prototype._createValueAxis = function () { var y = new IgxNumericRadiusAxisComponent(); y.provideRenderer(this.renderer); return y.i; }; IgxDataPieChartComponent.prototype._ensureDefaultTooltip = function (series) { if (this._defaultTooltips == null) { return; } this._defaultTooltips.instance["ensureDefaultTooltip"](series); }; IgxDataPieChartComponent.prototype._onDefaultTooltipsReady = function (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); } } } }; Object.defineProperty(IgxDataPieChartComponent.prototype, "transitionInDuration", { /** * Gets or sets the duration used for animating series plots when the chart is loading into view */ get: function () { return this.i.akz; }, set: function (v) { this.i.akz = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "transitionOutDuration", { /** * Gets or sets the duration used for animating series plots when the series is leaving view */ get: function () { return this.i.ak0; }, set: function (v) { this.i.ak0 = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "transitionInEasingFunction", { /** * 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: function () { return this.i.akt; }, set: function (v) { this.i.akt = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "transitionOutEasingFunction", { /** * 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: function () { return this.i.aku; }, set: function (v) { this.i.aku = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "domainType", { /** * Gets the domain type of this chart */ get: function () { return this.i.cb; }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "chartType", { /** * Gets or sets the type of chart series to generate from the data. */ get: function () { return this.i.ako; }, set: function (v) { this.i.ako = ensureEnum(DataPieChartType_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "isTransitionInEnabled", { /** * Gets or sets whether animation of series plots is enabled when the chart is loading into view */ get: function () { return this.i.akw; }, set: function (v) { this.i.akw = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "transitionInMode", { /** * Gets or sets the method that determines how to animate series plots when the chart is loading into view */ get: function () { return this.i.akm; }, set: function (v) { this.i.akm = ensureEnum(CategoryTransitionInMode_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxDataPieChartComponent.prototype, "transitionInSpeedType", { /** * Gets or sets the arrival speed used for animating series plots when the chart is loading into view */ get: function () { return this.i.akq; }, set: function (v) { this.i.akq = ensureEnum(TransitionInSpeedType_$type, v); }, enumerable: false, configurable: true }); /** * Export serialized visual data. */ IgxDataPieChartComponent.prototype.exportSerializedVisualData = function () { var iv = this.i.ak2(); return (iv); }; IgxDataPieChartComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxDataPieChartComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component }); IgxDataPieChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxDataPieChartComponent, selector: "igx-data-pie-chart", inputs: { height: "height", width: "width", dataSource: "dataSource", transitionInDuration: "transitionInDuration", transitionOutDuration: "transitionOutDuration", transitionInEasingFunction: "transitionInEasingFunction", transitionOutEasingFunction: "transitionOutEasingFunction", chartType: "chartType", isTransitionInEnabled: "isTransitionInEnabled", transitionInMode: "transitionInMode", transitionInSpeedType: "transitionInSpeedType" }, host: { classAttribute: "ig-data-pie-chart igx-data-pie-chart" }, providers: [], viewQueries: [{ propertyName: "_dynamicContent", first: true, predicate: ["dynamicContent"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: "<ng-container #dynamicContent></ng-container>", isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); return IgxDataPieChartComponent; }(IgxDataPieBaseChartComponent)); export { IgxDataPieChartComponent }; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxDataPieChartComponent, decorators: [{ type: Component, args: [{ selector: 'igx-data-pie-chart', template: "<ng-container #dynamicContent></ng-container>", changeDetection: ChangeDetectionStrategy.OnPush, providers: [], host: { 'class': 'ig-data-pie-chart igx-data-pie-chart' }, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"] }] }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ViewContainerRef }, { type: i0.NgZone }, { type: i0.Injector }, { type: i0.ComponentFactoryResolver }]; }, propDecorators: { _dynamicContent: [{ type: ViewChild, args: ["dynamicContent", { read: ViewContainerRef, static: true }] }], height: [{ type: Input }], width: [{ type: Input }], dataSource: [{ type: Input }], transitionInDuration: [{ type: Input }], transitionOutDuration: [{ type: Input }], transitionInEasingFunction: [{ type: Input }], transitionOutEasingFunction: [{ type: Input }], chartType: [{ type: Input }], isTransitionInEnabled: [{ type: Input }], transitionInMode: [{ type: Input }], transitionInSpeedType: [{ type: Input }] } });