import type { PieSeriesOption } from 'echarts';

const option = {
  // title: {
  //   text: 'Referer of a Website',
  //   subtext: 'Fake Data',
  //   left: 'center'
  // },
  // tooltip: {
  //   trigger: 'item'
  // },
  tooltip: {
    trigger: 'item',
    formatter: (p) => {
      switch (p.data.questionItem.question_type) {
      case 1:
      case 2:
        return `${p.data.name}: ${p.data.value} ${p.data.answerRate ? `(${p.data.answerRate})` : ''}`;
      case 10:
      case 9:
        return `${p.data.name}: ${p.data.value} ${p.data.answerRate ? `(${p.data.answerRate})` : ''}`;
      case 5:
      case 106:
        return `${p.data.avg ? '平均值<br>' : ''} ${p.data.name}: ${p.data.value}`;
      }
    }
  },
  legend: {
    icon: 'rect',
    itemWidth: 14,
    itemHeight: 14,
    // itemGap: 10,
    textStyle: {
      fontSize: 12
    },
    // orient: 'horizontal',
    bottom: 'top'
  },
  label: {
    formatter: '{b},{c}'
  },
  series: [
    {
      name: 'yl form chart',
      type: 'pie',
      radius: '50%',
      data: [],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
} as PieSeriesOption;

export const pieOption = option;
