import * as echarts from "echarts";

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

export default getPieChart2;