import { __rest } from '../_virtual/_tslib.js';
import { BarChart } from 'echarts/charts';
import { GridComponent } from 'echarts/components';
import * as echarts from 'echarts/core';
import { commonEchartsComponents, defineComponent } from '../utils/comp-factory.js';

echarts.use([...commonEchartsComponents, GridComponent, BarChart]);
const barOption = (props) => {
    const { data, xAxisData } = props, restProps = __rest(props, ["data", "xAxisData"]);
    let _series;
    if (data && Array.isArray(data[0])) {
        _series = Array.from({ length: data.length }, (_, idx) => (Object.assign({ type: 'bar', data: data[idx] }, restProps)));
    }
    else {
        _series = data ? [Object.assign({ type: 'bar', data }, restProps)] : undefined;
    }
    return {
        // 声明一个 X 轴，类目轴（category）。默认情况下，类目轴对应到 dataset 第一列。
        xAxis: { type: 'category', data: xAxisData },
        // 声明一个 Y 轴，数值轴。
        yAxis: {},
        series: _series,
    };
};
var bar = defineComponent(echarts, 'bar', barOption);

export { bar as default };
//# sourceMappingURL=bar.js.map
