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' } },
    legend: {
      data: ['集成电路', '生物科技', '量子科技', '能源', '人工智能', '通信网络'],
      top: 0,
      icon: 'circle',
      textStyle: { color: '#757B82', fontSize: 15 }
    },
    grid: { top: '20%', right: '3%', bottom: '0%', left: '3%', containLabel: true },
    xAxis: {
      type: 'category',
      data: nameList,
      axisLine: { show: false },
      axisTick: { show: false },
      axisLabel: { color: '#666', fontSize: 12 }
    },
    yAxis: {
      type: 'value',
      axisLine: { show: false },
      axisTick: { show: false },
      axisLabel: { color: '#666' },
      splitLine: {
        show: true, lineStyle: {
          type: "dashed",
          color: "#E7F3FF"
        }
      }
    },
    graphic: [{                 // 右上角单位
      type: 'text',
      right: 20,
      top: 40,
      style: { text: '单位：万人', font: '14px sans-serif', fill: '#666' }
    }],
    series: [
      {
        name: '集成电路',
        type: 'bar',
        stack: 'total',        // 堆叠关键
        barWidth: 20,
        itemStyle: { borderRadius: 0, color: '#0560C3' },
        data: series1,

      },
      {
        name: '生物科技',
        type: 'bar',
        stack: 'total',
        barWidth: 20,
        itemStyle: { borderRadius: 0, color: '#14A8A8' },
        data: series2
      },
      {
        name: '量子科技',
        type: 'bar',
        stack: 'total',
        barWidth: 20,
        itemStyle: { borderRadius: 0, color: '#722FD1' },
        data: series2
      },
      {
        name: '能源',
        type: 'bar',
        stack: 'total',
        barWidth: 20,
        itemStyle: { borderRadius: 0, color: '#FA8C15' },
        data: series2
      },
      {
        name: '人工智能',
        type: 'bar',
        stack: 'total',
        barWidth: 20,
        itemStyle: { borderRadius: 0, color: '#69B2FF' },
        data: series2
      },
      {
        name: '通信网络',
        type: 'bar',
        stack: 'total',
        barWidth: 20,
        itemStyle: { borderRadius: 0, color: '#CF4F51' },
        data: series2,
        label: {
          show: true, // 开启显示
          position: 'top', // 文字显示位置，这里选择'top'或'bottom'取决于你的需求
          formatter: '{c}', // 格式化标签显示，{c}表示系列当前数值
          fontSize: 16,
          fontWeight: 'bold',
          color: 'rgba(5, 95, 194, 1)'
        },
      }
    ]
  }
}


export default getColumnChart