"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        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 extendStatics(d, b);
    };
    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 Content_1 = require("./Content");
var _ = require("lodash");
var d3 = require("d3");
var default_1 = /** @class */ (function (_super) {
    __extends(default_1, _super);
    function default_1() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.list = [];
        _this.labelFields = ['value'];
        _this.labelTexts = ['数量'];
        return _this;
    }
    default_1.prototype._append = function (enter) {
        var _this = this;
        var group = enter.append('g').attr('class', '_item');
        var count = this.labelFields.length;
        var _loop_1 = function (i) {
            var field = this_1.labelFields[i];
            range = d3.extent(this_1.props.bars, function (d) { return d[field]; });
            var scale = d3.scaleLinear().domain(range).range([10, 200]);
            var left = i * 8;
            group.append('rect')
                .attr('class', "_rect _rect_" + i)
                .attr('x', function (d) {
                var point = _this.PROJECTION(_this.BUILDER.getPoint(d.name));
                return point[0] - 4 + left;
            })
                .attr('y', function (d) {
                var height = scale(d[field]);
                var point = _this.PROJECTION(_this.BUILDER.getPoint(d.name));
                return point[1] - 4 - height;
            })
                .attr('width', 8)
                .attr('width', 0)
                .transition()
                .duration(2000)
                .attr('height', function (d) { return scale(d[field]); });
        };
        var this_1 = this, range;
        for (var i = 0; i < count; i++) {
            _loop_1(i);
        }
        // this.BUILDER.getPoint('')
        // var scale = d3.scaleLinear().domain([_.minBy(AreaList,'count').count,_.maxBy(AreaList,'count').count]).range([10, 200]);
        // var stacks = group.selectAll('rect.area-counts').data(AreaList,function(d){return d.area;});
        // stacks.attr('fill',function(d,i){
        // 		var index = _.findIndex(AreaList,{area:d.area});
        // 		return COLORS[index];
        // 	})
        // 	.transition()
        // 	.duration(1000)
        // 	.attr('y', function(d) {
        // 		var point = projection(builder.getPoint(d.area));
        // 		var index = _.findIndex(AreaList,{area:d.area});
        // 		return point[1] - 6 - scale(AreaList[index].count) ;
        // 	})
        // 	.attr('height', function(d) {
        // 		return scale(d.count);
        // 	});
        // stacks.enter()
        // 	.append('rect')
        // 	.attr('class', 'area-counts')
        // 	.attr('rx', 1)
        // 	.attr('ry', 1)
        // 	.attr('width', 10)
        // 	.attr('fill',function(d,i){
        // 		var index = _.findIndex(AreaList,{area:d.area});
        // 		return COLORS[index];
        // 	})
        // 	.attr('x', function(d) {
        // 		var point = projection(builder.getPoint(d.area));
        // 		return point[0] - 4 ;
        // 	})
        // 	.attr('y', function(d) {
        // 		var point = projection(builder.getPoint(d.area));
        // 		return point[1] - 6 ;
        // 	})
        // 	.attr('height', 0)
        // 	.transition()
        // 	.duration(1000)
        // 	.attr('y', function(d) {
        // 		var point = projection(builder.getPoint(d.area));
        // 		var index = _.findIndex(AreaList,{area:d.area});
        // 		return point[1] - 6 - scale(AreaList[index].count) ;
        // 	})
        // 	.attr('height', function(d) {
        // 		return scale(d.count);
        // 	});
    };
    default_1.prototype._update = function (group) {
    };
    default_1.prototype._delete = function (group) {
        group.exit().remove();
    };
    default_1.prototype.setData = function (group) {
        if (!_.has(this.props, 'bars')) {
            return;
        }
        if (_.has(this.props, 'barFields') && _.has(this.props, 'barTexts')) {
            this.labelFields = this.props.barFields;
            this.labelTexts = this.props.barTexts;
        }
        var container = group.selectAll('g._item').data(this.props.bars, function (d) { return d['name']; });
        this._append(container.enter());
        this._update(container);
        this._delete(container);
    };
    return default_1;
}(Content_1.default));
exports.default = default_1;
