import { __assign, __rest } from "tslib";
import { each } from '@antv/util';
import { point, line, interval } from '../../../adaptor/geometries';
import { pick, findGeometry, deepAssign } from '../../../utils';
import { isLine, isColumn } from './option';
/**
 * 绘制单个图形
 * @param params
 */
export function drawSingleGeometry(params) {
    var options = params.options, chart = params.chart;
    var geometryOption = options.geometryOption, yField = options.yField;
    var isStack = geometryOption.isStack, color = geometryOption.color, seriesField = geometryOption.seriesField, groupField = geometryOption.groupField, isGroup = geometryOption.isGroup;
    var FIELD_KEY = ['xField', 'yField'];
    if (isLine(geometryOption)) {
        // 绘制线
        line(deepAssign({}, params, {
            options: __assign(__assign(__assign({}, pick(options, FIELD_KEY)), geometryOption), { line: {
                    color: geometryOption.color,
                    style: geometryOption.lineStyle,
                } }),
        }));
        // 绘制点
        point(deepAssign({}, params, {
            options: __assign(__assign(__assign({}, pick(options, FIELD_KEY)), geometryOption), { point: geometryOption.point && __assign({ color: color, shape: 'circle' }, geometryOption.point) }),
        }));
        // adjust
        var adjust_1 = [];
        if (isGroup) {
            adjust_1.push({
                type: 'dodge',
                dodgeBy: groupField || seriesField,
                customOffset: 0,
            });
        }
        if (isStack) {
            adjust_1.push({
                type: 'stack',
            });
        }
        if (adjust_1.length) {
            each(chart.geometries, function (g) {
                g.adjust(adjust_1);
            });
        }
    }
    if (isColumn(geometryOption)) {
        interval(deepAssign({}, params, {
            options: __assign(__assign(__assign({}, pick(options, FIELD_KEY)), geometryOption), { widthRatio: geometryOption.columnWidthRatio, interval: __assign(__assign({}, pick(geometryOption, ['color'])), { style: geometryOption.columnStyle }) }),
        }));
    }
    // 绘制 label
    var mainGeometry = findGeometry(chart, 'line') || findGeometry(chart, 'interval');
    if (!geometryOption.label) {
        mainGeometry.label(false);
    }
    else {
        var _a = geometryOption.label, callback = _a.callback, cfg = __rest(_a, ["callback"]);
        mainGeometry.label({
            fields: [yField],
            callback: callback,
            cfg: cfg,
        });
    }
    return params;
}
//# sourceMappingURL=geometry.js.map