//公用饼图
import ReactEcharts from 'echarts-for-react';
import { CSSProperties } from 'react';
interface ChartProps {
  data: any;
  style?: CSSProperties;
  color: string[];
}
const Chart: React.FC<ChartProps> = ({ data, color, style }) => {
  const getOption = () => {
    return {
      color,
      tooltip: {
        trigger: 'item',
        confine: true,
        formatter: '{b0}: {c0}',
      },
      series: [
        {
          name: '',
          type: 'pie',
          minAngle: 20, //最小的扇区角度（0 ~ 360），用于防止某个值过小导致扇区太小影响交互。
          radius: ['82%', '100%'],
          label: {
            show: false,
          },
          data: data,
        },
      ],
    };
  };
  return (
    <ReactEcharts
      notMerge={true}
      lazyUpdate={true}
      option={getOption()}
      style={{ ...style }}
    />
  );
};
export default Chart;
