import * as echarts from 'echarts'

const getMultiLineChart = (data) => {
  console.log('dataaaa', data);

  return {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985'
        }
      }
    },
    grid: {
      top: 48,
      right: 24,
      bottom: 24,
      left: 24,
      containLabel: true
    },
    legend: {
      show: true,
      top: 10,
      left: '10%'
    },
    color: ['#0A57A6', '#FA8C16', '#722ED1'],
    xAxis: [
      {
        type: 'category',
        boundaryGap: false,
        data: data.title
      }
    ],
    yAxis: [
      {
        type: 'value',
        name: '数量',
        splitLine: {
          show: true,
          lineStyle: {
            type: 'dashed',    // 虚线类型
            color: 'rgb(231, 243, 255)',      // 灰色线条
            width: 1            // 线宽为1
          }
        }
      }
    ],
    series: [
      {
        name: data.data[0]?.name,
        type: 'line',

        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
            offset: 0,
            color: 'rgba(10, 87, 166, 0.7)' // 起始颜色
          }, {
            offset: 1,
            color: 'rgba(10, 87, 166, 0)' // 结束颜色
          }])
        },
        emphasis: {
          focus: 'series'
        },
        data: data.data[0]?.value
      },
      {
        name: data.data[1]?.name,
        type: 'line',
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
            offset: 0,
            color: 'rgba(255, 172, 77, 0.7)' // 起始颜色
          }, {
            offset: 1,
            color: 'rgba(255, 172, 77, 0)' // 结束颜色
          }])
        },
        emphasis: {
          focus: 'series'
        },
        data: data.data[1]?.value,
      },
      {
        name: data.data[2]?.name,
        type: 'line',
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
            offset: 0,
            color: 'rgba(114, 46, 209, 0.7)' // 起始颜色
          }, {
            offset: 1,
            color: 'rgba(114, 46, 209, 0)' // 结束颜色
          }])
        },
        emphasis: {
          focus: 'series'
        },
        data: data.data[2]?.value,
      }
    ]
  }
}

export default getMultiLineChart