import * as echarts from "echarts";
const getColumnChart = (nameList, series1, series2, isPer) => {
  // 两套渐变
  const gradBlue = new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    { offset: 0, color: '#055FC2' },
    { offset: 1, color: '#BAE0FF' }
  ])
  const gradCyan = new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    { offset: 0, color: '#CE4F51' },
    { offset: 1, color: '#FFA39E' }
  ])

  return {
    tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
    grid: { top: '10%', right: '3%', bottom: '15%', left: '3%', containLabel: true },
    legend: { data: ['中国', '美国'], top: 0 },
    xAxis: {
      type: 'category',
      data: nameList,
      axisLine: { show: false },
      axisTick: { show: false },
      axisLabel: { rotate: 45, color: '#666', fontSize: 12 }
    },
    yAxis: {
      type: 'value',
      axisLine: { show: false },
      axisTick: { show: false },
      axisLabel: { show: true, color: '#666' },
      splitLine: { show: true, lineStyle: { color: '#ebebeb' } }
    },
    series: [
      {
        name: '中国',
        type: 'bar',
        data: series1,
        barWidth: 16,
        label: { show: false },
        itemStyle: { borderRadius: [8, 8, 0, 0], color: gradBlue }
      },
      {
        name: '美国',
        type: 'bar',
        data: series2,
        barWidth: 16,
        label: { show: false },
        itemStyle: { borderRadius: [8, 8, 0, 0], color: gradCyan }
      }
    ]
  }
}

export default getColumnChart