"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 ColumnChart = /** @class */ (function (_super) {
    __extends(ColumnChart, _super);
    function ColumnChart() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    /**
     *  Render method
     */
    ColumnChart.prototype.render = function () {
        var _this = this;
        var DEFAULT_COLORS = ['#224b81', '#0088FE', '#00C49F', '#FFBB28', '#FF8042'];
        var COLORS = this.props.config.variables.colors ? this.props.config.variables.colors : DEFAULT_COLORS;
        var showLegend = (this.props.config.variables.showLegend ? this.props.config.variables.showLegend : false);
        var xAxis = '';
        var bars = [];
        this.props.config.fields.forEach(function (f) {
            if (f.key === _this.props.config.variables.x)
                xAxis = f.name;
            for (var _i = 0, _a = _this.props.config.variables.y; _i < _a.length; _i++) {
                var key = _a[_i];
                if (f.key === key)
                    bars.push(f.name);
            }
        });
        return React.createElement(recharts_1.ResponsiveContainer, { width: '100%', height: 210 },
            React.createElement(recharts_1.BarChart, { data: this.props.dataSource, layout: 'horizontal' },
                React.createElement(recharts_1.XAxis, { dataKey: xAxis }),
                React.createElement(recharts_1.YAxis, null),
                showLegend === true && React.createElement(recharts_1.Legend, null),
                bars.map(function (b, index) {
                    return React.createElement(recharts_1.Bar, { dataKey: b, stroke: '#224b81', fill: COLORS[index % COLORS.length] });
                })));
    };
    return ColumnChart;
}(React.Component));
exports.ColumnChart = ColumnChart;
exports.default = ColumnChart;
