const getPieChart = (data) => {
  let option = {
    color: ["#ffa39e",
      "#4096ff",
      "#ff9c6e",
      "#b37feb",
      "#ff7875",
      "#d9f7be",
      "#d6e4ff",
      "#85a5ff",
      "#69b1ff",
      "#b7eb8f",
      "#ffc069",
      "#fff565",
      "#87e8de",
      "#597ef7"
    ],
    series: [
      {
        type: 'pie',
        radius: [70, 100],
        height: '100%',
        left: 'center',
        width: '100%',
        itemStyle: {
          borderColor: '#fff',
          borderWidth: 1
        },
        label: {
          alignTo: 'edge',
          formatter: '{name|{b}}\n{time|{c} 台 {d}%}',
          minMargin: 5,
          edgeDistance: 10,
          lineHeight: 15,
          rich: {
            time: {
              fontSize: 10,
              color: '#999'
            }
          }
        },
        labelLine: {
          length: 15,
          length2: 0,
          maxSurfaceAngle: 80
        },
        labelLayout: function (params) {
          const isLeft = params.labelRect.x < 256 / 2;
          const points = params.labelLinePoints;
          // Update the end point.
          points[2][0] = isLeft
            ? params.labelRect.x
            : params.labelRect.x + params.labelRect.width;
          return {
            labelLinePoints: points
          };
        },
        data: data
      }]
  }
  return option
}

export default getPieChart;