import * as tslib_1 from "tslib";
import { Component, ChangeDetectionStrategy, ViewChild, ViewContainerRef, Input, Inject, NgZone, ComponentFactoryResolver, Renderer2, Injector } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';
import { AngularRenderer } from "igniteui-angular-core/ES2015/angular-renderer";
import { TypeRegistrar } from "igniteui-angular-core/ES2015/type";
import { IgxPieChartBaseComponent } from './igx-pie-chart-base-component';
import { DataChartStylingDefaults } from './DataChartStylingDefaults';
import { XamPieChart } from './XamPieChart';
export const IgxPieChartComponent_PROVIDERS = [];
/**
 * Represents Infragistics IgxPieChartComponent control.
*/
let IgxPieChartComponent = class IgxPieChartComponent extends IgxPieChartBaseComponent {
    constructor(renderer, _elRef, document, ngZone, injector, componentFactoryResolver) {
        super();
        this.renderer = renderer;
        this._elRef = _elRef;
        this.document = document;
        this.ngZone = ngZone;
        this.injector = injector;
        this.componentFactoryResolver = componentFactoryResolver;
        this._dataSource = null;
        this._zoneRunner = (act) => 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, this.document, this.ngZone, true, DataChartStylingDefaults);
        this._wrapper = ren;
        var chart = this.i;
        this._chart = chart;
        chart.provideContainer(ren);
        this.bindData();
        chart.notifyContainerResized();
        ren.addSizeWatcher(() => {
            this._chart.notifyContainerResized();
        });
    }
    set height(value) {
        this._height = value;
        this.renderer.setStyle(this._elRef.element.nativeElement, "height", value);
        this._chart.notifyContainerResized();
    }
    get height() {
        return this._height;
    }
    set width(value) {
        this._width = value;
        this.renderer.setStyle(this._elRef.element.nativeElement, "width", value);
        this._chart.notifyContainerResized();
    }
    get width() {
        return this._width;
    }
    ngOnDestroy() {
        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;
    }
};
tslib_1.__decorate([
    ViewChild("dynamicContent", { read: ViewContainerRef }),
    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,
        styles: [`
		:host {
			display: block;
		}
	`]
    }),
    tslib_1.__param(2, Inject(DOCUMENT)),
    tslib_1.__metadata("design:paramtypes", [Renderer2,
        ViewContainerRef, Object, NgZone,
        Injector,
        ComponentFactoryResolver])
], IgxPieChartComponent);
export { IgxPieChartComponent };
//# sourceMappingURL=igx-pie-chart-component.js.map