import * as echarts from "echarts";

const getBarChart = (nameList, valueList, isPer) => {
  const option = {
    title: { text: '' },
    legend: {
      show: false,
      icon: 'circle',
      orient: 'vertical',
      right: 0,
      top: 'center',
      align: 'left',
      data: ['法案', '行政令', '科技智库', '出口管制', '投融资限制', '市场准入']
    },
    radar: {
      shape: 'circle',          // ① 参考线变弧线
      indicator: [
        { name: '研究人员总数', max: 6500 },
        { name: '每万人研究人员数', max: 16000 },
        { name: '每万研究人员研发经费投入额', max: 30000 },
        { name: '每万人研发经费投入额', max: 38000 },
        { name: '研发经费占GDP的比重', max: 52000 },
        { name: '研发经费投入总额', max: 25000 }
      ],
      axisName: {
        // ② 文字在线上方 + 自动换两行
        formatter: function (txt) {
          // 按字数 10 左右自动断行
          const len = txt.length;
          if (len <= 5) return txt;
          const br = Math.ceil(len / 2);
          return txt.substring(0, br) + '\n' + txt.substring(br);
        },
        rich: {
          a: { lineHeight: 20 }   // 行高
        },
        color: 'rgba(59, 65, 75, 1)',
        fontSize: 14,
        fontWeight: 600
      },
      splitLine: {
        lineStyle: {
          color: 'rgba(200,200,200,.6)'
        }
      },
      splitArea: { show: false },
      axisLine: { show: false }
    },
    series: [{
      name: 'Budget vs spending',
      type: 'radar',
      data: [
        { value: [4200, 3000, 20000, 35000, 50000, 18000], name: '法案', areaStyle: { color: 'rgba(10, 87, 166, 0.2)' } },
        { value: [5000, 14000, 28000, 26000, 42000, 21000], name: '行政令', areaStyle: { color: 'rgba(206, 79, 81, 0.2)' } },
        { value: [4000, 14000, 18000, 21000, 32000, 10000], name: '科技智库', areaStyle: { color: 'rgba(250, 140, 22, 0.2)' } },
        { value: [4000, 14000, 18000, 21000, 32000, 10000], name: '出口管制', areaStyle: { color: 'rgba(22, 180, 120, 0.2)' } },
        { value: [4000, 14000, 18000, 21000, 32000, 10000], name: '投融资限制', areaStyle: { color: 'rgba(120, 100, 200, 0.2)' } },
        { value: [4000, 14000, 18000, 21000, 32000, 10000], name: '市场准入', areaStyle: { color: 'rgba(255, 100, 150, 0.2)' } }
      ]
    }],
    // ③ 最外层弧线加粗：用 graphic 画一个圆环覆盖在最外层
    graphic: [{
      type: 'circle',
      shape: { cx: 300, cy: 300, r: '65%' },
      style: { stroke: '#333', lineWidth: 30, fill: 'transparent' },
      z: 1000
    }]
  };


  return option
}

export default getBarChart