UNPKG

igniteui-webcomponents-charts

Version:

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

427 lines (425 loc) 17.7 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 { __extends } from "tslib"; 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 */ var IgcDataPieChartComponent = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgcDataPieChartComponent, _super); function IgcDataPieChartComponent() { var _this = _super.call(this) || this; _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) { var 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) { var 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(function () { _this._chart.notifyResized(); }); return _this; //this._initialized = true; } Object.defineProperty(IgcDataPieChartComponent.prototype, "height", { get: function () { return this._height; }, set: function (value) { this._height = value; this.style.height = value; this.notifyResized(); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.prototype, "width", { get: function () { return this._width; }, set: function (value) { this._width = value; this.style.width = value; this.notifyResized(); }, enumerable: false, configurable: true }); IgcDataPieChartComponent.prototype.destroy = function () { this._chart.destroy(); this._wrapper.destroy(); }; IgcDataPieChartComponent.prototype.disconnectedCallback = function () { this._disconnected = true; if (this.i) { this.i.onDetachedFromUI(); } }; IgcDataPieChartComponent.prototype.connectedCallback = function () { 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(); }; IgcDataPieChartComponent.prototype.afterContentInit = function () { this.initializeContent(); }; IgcDataPieChartComponent.prototype.createImplementation = function () { return new DataPieChart(); }; Object.defineProperty(IgcDataPieChartComponent.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgcDataPieChartComponent.prototype.createSeriesComponent = function (type) { if (TypeRegistrar.isRegistered(type)) { var 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); } }; IgcDataPieChartComponent.prototype.createSeries = function (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'); } }; Object.defineProperty(IgcDataPieChartComponent.prototype, "dataSource", { get: function () { return this._dataSource; }, set: function (value) { this._dataSource = value; this.bindData(); }, enumerable: false, configurable: true }); IgcDataPieChartComponent.prototype.bindData = function () { if (this._chart != null && this._chart !== undefined) { this._chart.itemsSource = this._dataSource; } }; IgcDataPieChartComponent.prototype.initializeContent = function () { if (TypeRegistrar.isRegistered("IgcDataChartDefaultTooltipsComponent")) { var 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(); }; IgcDataPieChartComponent.prototype.createTooltip = function () { if (!TypeRegistrar.isRegistered("IgcTooltipContainerComponent")) { return null; } var cr = TypeRegistrar.create("IgcTooltipContainerComponent"); var ele = cr; var self = this; ele.updateToolTip = function (c, isSubContent) { if (c.externalObject) { c = c.externalObject; } else { var 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; }; IgcDataPieChartComponent.prototype._ensureTooltipCreated = function (series) { var _this = this; series._ensureTooltipCreated(function () { return _this.createTooltip(); }, function (ele) { var wrapper = new WebComponentWrapper(ele, _this._renderer); wrapper.updateToolTip = ele.updateToolTip; wrapper.hideToolTip = ele.hideToolTip; return wrapper; }); }; IgcDataPieChartComponent.prototype._createAngleAxis = function () { var x = new IgcProportionalCategoryAngleAxisComponent(); x._provideRenderer(this._wrapper); return x.i; }; IgcDataPieChartComponent.prototype._createValueAxis = function () { var y = new IgcNumericRadiusAxisComponent(); y.provideRenderer(this._wrapper); return y.i; }; IgcDataPieChartComponent.prototype._ensureDefaultTooltip = function (series) { if (this._defaultTooltips == null) { return; } this._defaultTooltips["ensureDefaultTooltip"](series); }; IgcDataPieChartComponent.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(IgcDataPieChartComponent, "observedAttributes", { get: function () { if (IgcDataPieChartComponent._observedAttributesIgcDataPieChartComponent == null) { var names = getAllPropertyNames(IgcDataPieChartComponent); for (var i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcDataPieChartComponent._observedAttributesIgcDataPieChartComponent = names; } return IgcDataPieChartComponent._observedAttributesIgcDataPieChartComponent; }, enumerable: false, configurable: true }); IgcDataPieChartComponent.register = function () { if (!IgcDataPieChartComponent._isElementRegistered) { IgcDataPieChartComponent._isElementRegistered = true; RegisterElementHelper.registerElement(IgcDataPieChartComponent.htmlTagName, IgcDataPieChartComponent); } }; Object.defineProperty(IgcDataPieChartComponent.prototype, "transitionInDuration", { /** * Gets or sets the duration used for animating series plots when the chart is loading into view */ get: function () { return this.i.al7; }, set: function (v) { this.i.al7 = +v; this._a("transitionInDuration", this.i.al7); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.prototype, "transitionOutDuration", { /** * Gets or sets the duration used for animating series plots when the series is leaving view */ get: function () { return this.i.al8; }, set: function (v) { this.i.al8 = +v; this._a("transitionOutDuration", this.i.al8); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.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.al1; }, set: function (v) { this.i.al1 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.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.al2; }, set: function (v) { this.i.al2 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.prototype, "domainType", { /** * Gets the domain type of this chart */ get: function () { return this.i.cb; }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.prototype, "chartType", { /** * Gets or sets the type of chart series to generate from the data. */ get: function () { return this.i.alw; }, set: function (v) { this.i.alw = ensureEnum(DataPieChartType_$type, v); this._a("chartType", enumToString(DataPieChartType_$type, this.i.alw)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.prototype, "isTransitionInEnabled", { /** * Gets or sets whether animation of series plots is enabled when the chart is loading into view */ get: function () { return this.i.al4; }, set: function (v) { this.i.al4 = ensureBool(v); this._a("isTransitionInEnabled", this.i.al4); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.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.alu; }, set: function (v) { this.i.alu = ensureEnum(CategoryTransitionInMode_$type, v); this._a("transitionInMode", enumToString(CategoryTransitionInMode_$type, this.i.alu)); }, enumerable: false, configurable: true }); Object.defineProperty(IgcDataPieChartComponent.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.aly; }, set: function (v) { this.i.aly = ensureEnum(TransitionInSpeedType_$type, v); this._a("transitionInSpeedType", enumToString(TransitionInSpeedType_$type, this.i.aly)); }, enumerable: false, configurable: true }); /** * Export serialized visual data. */ IgcDataPieChartComponent.prototype.exportSerializedVisualData = function () { var iv = this.i.ama(); return (iv); }; IgcDataPieChartComponent._observedAttributesIgcDataPieChartComponent = null; IgcDataPieChartComponent.htmlTagName = "igc-data-pie-chart"; IgcDataPieChartComponent._isElementRegistered = false; return IgcDataPieChartComponent; }(IgcDataPieBaseChartComponent)); export { IgcDataPieChartComponent };