"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.drawSingleGeometry = void 0;
var tslib_1 = require("tslib");
var util_1 = require("@antv/util");
var geometries_1 = require("../../../adaptor/geometries");
var utils_1 = require("../../../utils");
var option_1 = require("./option");
/**
 * 绘制单个图形
 * @param params
 */
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 (option_1.isLine(geometryOption)) {
        // 绘制线
        geometries_1.line(utils_1.deepAssign({}, params, {
            options: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, utils_1.pick(options, FIELD_KEY)), geometryOption), { line: {
                    color: geometryOption.color,
                    style: geometryOption.lineStyle,
                } }),
        }));
        // 绘制点
        geometries_1.point(utils_1.deepAssign({}, params, {
            options: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, utils_1.pick(options, FIELD_KEY)), geometryOption), { point: geometryOption.point && tslib_1.__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) {
            util_1.each(chart.geometries, function (g) {
                g.adjust(adjust_1);
            });
        }
    }
    if (option_1.isColumn(geometryOption)) {
        geometries_1.interval(utils_1.deepAssign({}, params, {
            options: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, utils_1.pick(options, FIELD_KEY)), geometryOption), { widthRatio: geometryOption.columnWidthRatio, interval: tslib_1.__assign(tslib_1.__assign({}, utils_1.pick(geometryOption, ['color'])), { style: geometryOption.columnStyle }) }),
        }));
    }
    // 绘制 label
    var mainGeometry = utils_1.findGeometry(chart, 'line') || utils_1.findGeometry(chart, 'interval');
    if (!geometryOption.label) {
        mainGeometry.label(false);
    }
    else {
        var _a = geometryOption.label, callback = _a.callback, cfg = tslib_1.__rest(_a, ["callback"]);
        mainGeometry.label({
            fields: [yField],
            callback: callback,
            cfg: cfg,
        });
    }
    return params;
}
exports.drawSingleGeometry = drawSingleGeometry;
//# sourceMappingURL=geometry.js.map