import defaultsDeep from 'lodash/defaultsDeep';
export default function getLineAndBar(
    barData,
    lineData,
    xAxisData,
    color,
    tooltipFormatter,
    lineOpt,
    barOpt,
    changeOpt,
    type
) {
    let opt = {
        color,
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            },
            tooltipFormatter
        },
        legend: {
            icon: "circle",
            textStyle: {
                color: type == "dark" ? "#fff" : "#000"
            }
        },
        toolbox: {
            show: true,
        },
        xAxis: {
            type: 'category',
            data: xAxisData,
            axisLine: {
                lineStyle: {
                    color: type == "dark" ? "#2f309c" : "#000",
                    type: "dotted"
                }
            },
            axisLabel: {
                color: type == "dark" ? "#2f309c" : "#000"
            },
            axisTick: {
                show: false
            }
        },
        yAxis: {
            type: 'value',
            axisLine: {
                show: false,
                lineStyle: {
                    color: type == "dark" ? "#2f309c" : "#000",
                }
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                color: type == "dark" ? "#bac4e8" : "#000"
            },
            splitLine: {
                lineStyle: {
                    color: type == "dark" ? "#2f309c" : "#000",
                    type: "dotted"
                }
            }
        },
        series: [
            {
                name: barData.name,
                type: 'bar',
                barCategoryGap: "55%",
                data: barData.data,
            },
            {
                name: lineData.name,
                type: 'line',
                symbolSize: 10,
                symbol: 'circle',
                itemStyle: {
                    borderWidth: 0,
                },
                data: lineData.data
            },
        ]
    }
    if (changeOpt) {
        opt = defaultsDeep({}, changeOpt, opt)
    }
    if (lineOpt) {
        opt.series[1] = defaultsDeep({}, lineOpt, opt.series[1])
    }
    if (barOpt) {
        opt.series[0] = defaultsDeep({}, barOpt, opt.series[0])
    }
    return opt
}
