"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var recharts_1 = require("recharts");
var PieChart = /** @class */ (function (_super) {
    __extends(PieChart, _super);
    function PieChart() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    /**
     *  Render method
     */
    PieChart.prototype.render = function () {
        var _this = this;
        var DEFAULT_COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042'];
        var COLORS = this.props.config.variables.colors ? this.props.config.variables.colors : DEFAULT_COLORS;
        var dataKey = '';
        this.props.config.fields.forEach(function (f) {
            if (f.key === _this.props.config.variables.dataKey) {
                dataKey = f.name;
            }
        });
        return React.createElement(recharts_1.ResponsiveContainer, { width: '100%', height: 210 },
            React.createElement(recharts_1.PieChart, { width: 730, height: 250 },
                React.createElement(recharts_1.Pie, { data: this.props.dataSource, dataKey: dataKey, nameKey: 'Category', cx: '50%', cy: '50%', fill: '#8884d8', label: true }, this.props.dataSource.map(function (entry, index) { return React.createElement(recharts_1.Cell, { fill: COLORS[index % COLORS.length] }); }))));
    };
    return PieChart;
}(React.Component));
exports.PieChart = PieChart;
exports.default = PieChart;
