import * as tslib_1 from "tslib";
import { Component, ChangeDetectionStrategy, ViewChild, ViewContainerRef, Input, NgZone, ComponentFactoryResolver, Renderer2, Injector } from '@angular/core';
import { AngularRenderer } from "igniteui-angular-core/ES5/angular-renderer";
import { TypeRegistrar } from "igniteui-angular-core/ES5/type";
import { IgxPieChartBaseComponent } from './igx-pie-chart-base-component';
import { DataChartStylingDefaults } from './DataChartStylingDefaults';
import { XamPieChart } from './XamPieChart';
import { NamePatcher } from "igniteui-angular-core/ES5/componentUtil";
export var IgxPieChartComponent_PROVIDERS = [];
/**
 * Represents Infragistics IgxPieChartComponent control.
*/
var IgxPieChartComponent = /** @class */ (function (_super) {
    tslib_1.__extends(IgxPieChartComponent, _super);
    function IgxPieChartComponent(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._root = null;
        _this._dataSource = 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;
        }
        _this._root = root;
        var ren = new AngularRenderer(root, _this.renderer, window.document, _this.ngZone, true, DataChartStylingDefaults);
        _this._wrapper = ren;
        var chart = _this.i;
        _this._chart = chart;
        chart.provideContainer(ren);
        _this.bindData();
        chart.notifyContainerResized();
        ren.addSizeWatcher(function () {
            _this._chart.notifyContainerResized();
        });
        return _this;
    }
    Object.defineProperty(IgxPieChartComponent.prototype, "height", {
        get: function () {
            return this._height;
        },
        set: function (value) {
            this._height = value;
            this.renderer.setStyle(this._elRef.element.nativeElement, "height", value);
            this._chart.notifyContainerResized();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxPieChartComponent.prototype, "width", {
        get: function () {
            return this._width;
        },
        set: function (value) {
            this._width = value;
            this.renderer.setStyle(this._elRef.element.nativeElement, "width", value);
            this._chart.notifyContainerResized();
        },
        enumerable: true,
        configurable: true
    });
    IgxPieChartComponent.prototype.ngAfterContentInit = function () {
        this._styling(this._root, this);
        this.i.notifyContainerResized();
    };
    IgxPieChartComponent.prototype.ngOnDestroy = function () {
        this._chart.destroy();
        this._wrapper.destroy();
    };
    IgxPieChartComponent.prototype.createImplementation = function () {
        return new XamPieChart();
    };
    Object.defineProperty(IgxPieChartComponent.prototype, "i", {
        get: function () {
            return this._implementation;
        },
        enumerable: true,
        configurable: true
    });
    IgxPieChartComponent.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);
        }
    };
    Object.defineProperty(IgxPieChartComponent.prototype, "dataSource", {
        get: function () {
            return this._dataSource;
        },
        set: function (value) {
            this._dataSource = value;
            this.bindData();
        },
        enumerable: true,
        configurable: true
    });
    IgxPieChartComponent.prototype.bindData = function () {
        if (this._chart != null && this._chart !== undefined) {
            this._chart.itemsSource = this._dataSource;
        }
    };
    Object.defineProperty(IgxPieChartComponent.prototype, "legend", {
        /**
         * Gets or sets the legend used for the current chart.
        */
        get: function () {
            if (this.i.legend != null)
                return this.i.legend.externalObject;
        },
        set: function (v) {
            if (v != undefined && v != null)
                this.i.legend = v.i;
        },
        enumerable: true,
        configurable: true
    });
    tslib_1.__decorate([
        ViewChild("dynamicContent", { read: ViewContainerRef, static: true }),
        tslib_1.__metadata("design:type", ViewContainerRef)
    ], IgxPieChartComponent.prototype, "_dynamicContent", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String),
        tslib_1.__metadata("design:paramtypes", [String])
    ], IgxPieChartComponent.prototype, "height", null);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String),
        tslib_1.__metadata("design:paramtypes", [String])
    ], IgxPieChartComponent.prototype, "width", null);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Array),
        tslib_1.__metadata("design:paramtypes", [Array])
    ], IgxPieChartComponent.prototype, "dataSource", null);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object),
        tslib_1.__metadata("design:paramtypes", [Object])
    ], IgxPieChartComponent.prototype, "legend", null);
    IgxPieChartComponent = tslib_1.__decorate([
        Component({
            selector: 'igx-pie-chart',
            template: "<ng-container #dynamicContent></ng-container>",
            changeDetection: ChangeDetectionStrategy.OnPush,
            providers: IgxPieChartComponent_PROVIDERS,
            host: { 'class': 'ig-pie-chart igx-pie-chart' },
            styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"]
        }),
        tslib_1.__metadata("design:paramtypes", [Renderer2,
            ViewContainerRef,
            NgZone,
            Injector,
            ComponentFactoryResolver])
    ], IgxPieChartComponent);
    return IgxPieChartComponent;
}(IgxPieChartBaseComponent));
export { IgxPieChartComponent };
//# sourceMappingURL=igx-pie-chart-component.js.map