

const getRadarChart = (data) => {
  const indicators = data.title.map(item => {
    return {
      name: item, max: data.maxNum
    }
  })
  const option = {
    color: ["rgba(5, 95, 194, 1)", "rgba(250, 140, 22, 1)", "rgba(146, 84, 222, 1)"],
    legend: {
      top: 8,
      left: 'center',
      icon: "circle",
      itemWidth: 12,
      itemHeight: 12,
      itemGap: 24,
      textStyle: {
        color: "rgb(95, 101, 108)",
        fontSize: 16,
        fontFamily: "Microsoft YaHei",
        fontWeight: 400,
        lineHeight: 24
      },
      data: ["337调查", "301调查", "232调查"]
    },
    radar: {
      shape: "polygon",
      splitNumber: 5,
      indicator: indicators,
      center: ["50%", "56%"],
      radius: "58%",
      startAngle: 90,
      clockwise: false,
      axisName: {
        color: "rgba(59, 65, 75, 1)",
        fontSize: 16,
        fontFamily: "Microsoft YaHei",
        fontWeight: 700,
        lineHeight: 24,
        padding: [0, 5]
      },
      splitLine: {
        lineStyle: {
          color: "#d0d0d0",
          width: 1
        }
      },
      axisLine: {
        lineStyle: {
          color: "#d0d0d0",
          width: 1
        }
      },
      splitArea: {
        show: true,
        areaStyle: {
          color: ["#fff", "rgb(247, 248, 249)", "#fff", "rgb(247, 248, 249)", "#fff"]
        }
      }
    },
    series: [
      {
        // name: "337调查",
        name: data.data[0].name,
        type: "radar",
        data: [{ value: data.data[0].value }],
        lineStyle: {
          width: 2,
          color: "rgba(5, 95, 194,1)"
        },
        symbol: "none",
        areaStyle: {
          color: "rgba(5, 95, 194,0.15)"
        }
      },
      {
        name: data.data[1].name,
        type: "radar",
        data: [{ value: data.data[1].value }],
        lineStyle: {
          width: 2,
          color: "rgba(250, 140, 22, 1)"
        },
        symbol: "none",
        areaStyle: {
          color: "rgba(250, 140, 22, 0.15)"
        }
      },
      {
        name: data.data[2].name,
        type: "radar",
        data: [{ value: data.data[2].value }],
        lineStyle: {
          width: 2,
          color: "rgba(146, 84, 222, 1)"
        },
        symbol: "none",
        areaStyle: {
          color: "rgba(146, 84, 222, 0.15)"
        }
      },
    ]
  };

  return option
}

export default getRadarChart