import * as echarts from "echarts";

const getBarChart1 = (nameList, valueList) => {
  const option = {
    tooltip: {},
    grid: {
      top: '3%',
      right: '3%',
      bottom: '1%',
      left: '1%',
      containLabel: true
    },
    xAxis: {
      type: 'value',

      splitLine: {
        show: false
      },
      show: false
    },
    yAxis: {
      type: 'category',
      data: nameList,
      inverse: true,
      splitLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLine: {
        show: false
      },
      axisLabel: {
        show: true
      }
    },
    series: [{
      type: 'bar',
      data: valueList,
      label: {
        show: true,
        position: [610, 0],
        formatter: function (params) {
          return params.value + ' 次'
        }
      },
      barWidth: 8,
      itemStyle: {
        color: function (params) {
          return new echarts.graphic.LinearGradient(0, 0, 1, 0,
            [{
              offset: 0,
              color: 'rgba(22, 119, 255, 0)'
            },
            {
              offset: 1,
              color: 'rgba(22, 119, 255, 1)'
            }
            ]);
        },
        barBorderRadius: 4,
      }
    }]
  }
  return option
}

export default getBarChart1