import * as echarts from "echarts";

const getPieChart = (data) => {
  return {
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'vertical',  // 垂直排列
      left: 'left',        // 靠左放置
      top: 'center',       // 垂直居中
      itemGap: 24,
      textStyle: {        // 图例文本样式
        color: '#777',
        fontSize: 12
      },
    },
    color: ['#317ef3', '#fcc31f', '#fc5531'],
    series: [
      {
        name: 'Access From',
        type: 'pie',
        radius: ['35%', '70%'],
        avoidLabelOverlap: false,
        padAngle: 5,
        itemStyle: {
          borderRadius: 10
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 30,
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: false
        },
        label: {
          show: true,
          formatter: '{d}%',
          // 防止标签重叠
          position: 'inner',
          alignTo: 'edge',
          margin: 20
        },
        // 设置饼图半径，为标签留出空间
        data: data
      }
    ]
  }
}

export default getPieChart;