import * as echarts from 'echarts'

const getMultiLineChart = (data) => {
  return {
    tooltip: {
      trigger: 'item',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985'
        }
      }
    },
    grid: {
      width: '95%',
      height: '83%',
      top: '15%',
      left: '1%',
      containLabel: true
    },
    legend: {
      show: true,
      top: 10,
      icon: 'circle',
      textStyle: {
        color: 'rgba(95, 101, 108, 1)',
        fontFamily: 'Microsoft YaHei',
        fontSize: '14px',
      }
    },
    color: ['#0A57A6', '#FA8C16', '#722ED1'],
    xAxis: [
      {
        type: 'category',
        boundaryGap: false,
        data: data.title,
        axisLine: {
          show: true,
          lineStyle: {
              color: '#e7f3ff',
          },
        },
        axisLabel: {
          show: true,
          textStyle: {
            color: 'rgba(95, 101, 108, 1)',
            fontFamily: 'Microsoft YaHei',
            fontsize: 14,
          }
        }
      }
    ],
    yAxis: [
      {
        type: 'value',
        position: 'left',
        name: '数量',
        nameLocation: 'end',
        nameGap: 12,
        nameTextStyle: {
          color: '#666',
          fontSize: 14,
          fontWeight: 400,
          padding: [0, 0, 6, -20]
        },
        axisLabel: {
          formatter: '{value}',
          color: '#666',
          fontSize: 14,
          fontWeight: 400
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: '#e7f3ff',
            type: 'dashed',
          }
        },
      }
    ],
    series: [
      {
        name: data.data[0]?.name,
        type: 'line',
        smooth: true,
        symbol: 'emptyCircle',
        symbolSize: 6,
        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',
        smooth: true,
        symbol: 'emptyCircle',
        symbolSize: 6,
        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',
        smooth: true,
        symbol: 'emptyCircle',
        symbolSize: 6,
        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