import { __assign } from "tslib";
import { adaptor as columnAdaptor } from '../column/adaptor';
/**
 * 柱形图适配器
 * @param params
 */
export function adaptor(params) {
    var chart = params.chart, options = params.options;
    var xField = options.xField, yField = options.yField, xAxis = options.xAxis, yAxis = options.yAxis, barStyle = options.barStyle, barWidthRatio = options.barWidthRatio, label = options.label, data = options.data, seriesField = options.seriesField, isStack = options.isStack;
    // label of bar charts default position is left, if plot has label
    if (label && !label.position) {
        label.position = 'left';
    }
    // 默认 legend 位置
    var legend = options.legend;
    if (seriesField) {
        if (legend !== false) {
            legend = __assign({ position: isStack ? 'top-left' : 'right-top' }, legend);
        }
    }
    else {
        legend = false;
    }
    // @ts-ignore 直接改值
    params.options.legend = legend;
    // transpose column to bar
    chart.coordinate().transpose();
    return columnAdaptor({
        chart: chart,
        options: __assign(__assign({}, options), { label: label, 
            // switch xField and yField
            xField: yField, yField: xField, xAxis: yAxis, yAxis: xAxis, 
            // rename attrs as column
            columnStyle: barStyle, columnWidthRatio: barWidthRatio, 
            // bar 调整数据顺序
            data: data ? data.slice().reverse() : data }),
    }, true);
}
//# sourceMappingURL=adaptor.js.map