import * as tslib_1 from "tslib";
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/ES5/react-renderer";
import { DataChartStylingDefaults } from './DataChartStylingDefaults';
import { ensureEnum } from "igniteui-react-core/ES5/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;
*     }
* }
* ```
*/
var IgrLegend = /** @class */ (function (_super) {
    tslib_1.__extends(IgrLegend, _super);
    function IgrLegend(props) {
        var _this = _super.call(this, props) || this;
        _this._getMainRef = _this._getMainRef.bind(_this);
        var 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);
        return _this;
    }
    IgrLegend.prototype.render = function () {
        var div = React.createElement("div", {
            ref: this._getMainRef
        });
        return div;
    };
    IgrLegend.prototype._getMainRef = function (div) {
        this._elRef = div;
    };
    IgrLegend.prototype.componentDidMount = function () {
        _super.prototype.componentDidMount.call(this);
        this.initializeContent();
    };
    IgrLegend.prototype.initializeContent = function () {
        this._elRef.appendChild(this.container.getNativeElement());
    };
    IgrLegend.prototype.destroy = function () {
        this._wrapper.destroy();
    };
    IgrLegend.prototype.createImplementation = function () {
        return new Legend();
    };
    Object.defineProperty(IgrLegend.prototype, "i", {
        get: function () {
            return this._implementation;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgrLegend.prototype, "orientation", {
        /**
     * Gets or sets the current Legend object's orientation.
    */
        get: function () {
            return this.i.a9;
        },
        set: function (v) {
            this.i.a9 = ensureEnum(LegendOrientation_$type, v);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgrLegend.prototype, "textColor", {
        /**
         * Gets or sets color of text
        */
        get: function () {
            return this.i.bf;
        },
        set: function (v) {
            this.i.bf = v;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgrLegend.prototype, "textStyle", {
        /**
         * Gets or sets style of text.
        */
        get: function () {
            return this.i.bg;
        },
        set: function (v) {
            this.i.bg = v;
        },
        enumerable: true,
        configurable: true
    });
    return IgrLegend;
}(IgrLegendBase));
export { IgrLegend };
