import * as echarts from 'echarts';

export function stackRightOptions(xAxisData, yAxisData) {
  return {
    tooltip: {},
    xAxis: {
      data: xAxisData,
      axisTick: { show: false },
      splitLine: { show: false },
      splitArea: { show: false }
    },
    yAxis: {
      axisTick: { show: false },
      splitLine: { show: false },
      splitArea: { show: false }
    },
    grid: {
      top: 10,
      bottom: 20,
      left: 50
    },
    series: [
      {
        type: 'bar',
        stack: 'one',
        data: yAxisData.data1,
        barWidth: 8,
        itemStyle: {
          normal: {
            color: '#00479D'
          }
        }
      },
      {
        type: 'bar',
        stack: 'one',
        data: yAxisData.data2,
        barWidth: 8,
        itemStyle: {
          normal: {
            color: '#EA68A2'
          }
        }
      },
      {
        type: 'bar',
        stack: 'one',
        data: yAxisData.data3,
        barWidth: 8,
        itemStyle: {
          normal: {
            color: '#00B7EE'
          }
        }
      },
      {
        type: 'bar',
        stack: 'one',
        data: yAxisData.data4,
        barWidth: 8,
        itemStyle: {
          normal: {
            color: '#18CC54'
          }
        }
      },
      {
        name: 'bar5',
        type: 'bar',
        stack: 'one',
        data: yAxisData.data4,
        barWidth: 8,
        itemStyle: {
          normal: {
            color: '#FFF34D'
          }
        }
      },
      {
        name: 'bar6',
        type: 'bar',
        stack: 'one',
        data: yAxisData.data4,
        barWidth: 8,
        itemStyle: {
          normal: {
            color: '#FF9500'
          }
        }
      }
    ]
  };
}

export function stackLeftOptions(xAxisData, yAxisData) {
  return {
    xAxis: [
      {
        type: 'category',
        data: xAxisData,
        axisPointer: {
          show: false
        },
        axisTick: { show: false },
        splitLine: { show: false },
        splitArea: { show: false }
      }
    ],
    grid: {
      top: 10,
      bottom: 20,
      left: 50,
      right: 50
    },
    yAxis: [
      {
        type: 'value',
        min: 0
      },
      {
        type: 'value',
        min: 0
      }
    ],
    series: [
      {
        type: 'bar',
        barWidth: 3,
        data: yAxisData.data1,
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: '#0080FF'
            },
            {
              offset: 1,
              color: 'rgba(0,128,255,0)'
            }
          ])
        }
      },
      {
        type: 'bar',
        barWidth: 3,
        data: yAxisData.data2,
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: '#00D5FF'
            },
            {
              offset: 1,
              color: 'rgba(0,195,255,0)'
            }
          ])
        }
      },
      {
        type: 'bar',
        barWidth: 3,
        data: yAxisData.data4,
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: '#00D5FF'
            },
            {
              offset: 1,
              color: 'rgba(0,195,255,0)'
            }
          ])
        }
      },
      {
        type: 'bar',
        barWidth: 3,
        data: yAxisData.data3,
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: '#00D5FF'
            },
            {
              offset: 1,
              color: 'rgba(0,195,255,0)'
            }
          ])
        }
      },
      {
        type: 'line',
        smooth: true,
        yAxisIndex: 1,
        showSymbol: false,
        data: yAxisData.line,
        lineStyle: {
          color: '#FFD400',
          width: 1
        },
        areaStyle: {
          opacity: 0.8,
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: '#FFD400'
            },
            {
              offset: 1,
              color: 'rgba(255,212,0,0)'
            }
          ])
        }
      }
    ]
  };
}
