import * as React from 'react';
import { IgrLegendBase } from './igr-legend-base';
import { Legend } from "./Legend";
import { LegendOrientation_$type } from './LegendOrientation';
import { ReactRenderer } from "igniteui-react-core/ES2015/react-renderer";
import { DataChartStylingDefaults } from './DataChartStylingDefaults';
import { ensureEnum } from "igniteui-react-core/ES2015/componentUtil";
/**
 * Represents a legend in a IgxDataChartComponent control.
*
* The `IgrLegend` helps end-user identify visuals of chart series with contextual information related to the data plotted in the chart control.
*
* ```ts
* <IgrDataChart
* 	dataSource={this.data}
* 	ref={this.onChartRef} width="100%" height="400px">
* <IgrCategoryXAxis name="xAxis" label="Country" />
* <IgrNumericYAxis name="yAxis" minimumValue={0}  />
*
* <IgrLegend ref={this.onLegendRef}
*            orientation="Horizontal" />
* ```
*
* ```ts
* public onChartRef(chart: IgrDataChart) {
*     this.chart = chart;
*     if (this.legend) {
*         this.chart.legend = this.legend;
*     }
* }
*
* public onLegendRef(legend: IgrLegend) {
*     this.legend = legend;
*     if (this.chart) {
*         this.chart.legend = this.legend;
*     }
* }
* ```
*/
export class IgrLegend extends IgrLegendBase {
    render() {
        let div = React.createElement("div", {
            ref: this._getMainRef
        });
        return div;
    }
    _getMainRef(div) {
        this._elRef = div;
    }
    componentDidMount() {
        super.componentDidMount();
        this.initializeContent();
    }
    initializeContent() {
        this._elRef.appendChild(this.container.getNativeElement());
    }
    constructor(props) {
        super(props);
        this._getMainRef = this._getMainRef.bind(this);
        let container;
        if (document) {
            container = document.createElement("div");
            container.style.display = "block";
            container.style.width = "100%";
            container.style.height = "100%";
        }
        var root;
        root = container;
        var ren = new ReactRenderer(root, document, true, DataChartStylingDefaults);
        this.container = ren.getWrapper(container);
        this._wrapper = ren;
        this.i.provideContainer(ren);
    }
    destroy() {
        this._wrapper.destroy();
    }
    createImplementation() {
        return new Legend();
    }
    get i() {
        return this._implementation;
    }
    /**
 * Gets or sets the current Legend object's orientation.
*/
    get orientation() {
        return this.i.a9;
    }
    set orientation(v) {
        this.i.a9 = ensureEnum(LegendOrientation_$type, v);
    }
    /**
     * Gets or sets color of text
    */
    get textColor() {
        return this.i.bf;
    }
    set textColor(v) {
        this.i.bf = v;
    }
    /**
     * Gets or sets style of text.
    */
    get textStyle() {
        return this.i.bg;
    }
    set textStyle(v) {
        this.i.bg = v;
    }
}
