import React from 'react';
import { Pie  } from '@ant-design/charts';
import defaultConfig from '../_utils/theme';
import isEmpty from '../_utils/isEmpty';
import { Empty } from 'antd';
import { PieConfig } from '@ant-design/charts/es/pie';

export interface IPieChart extends PieConfig {}

export default ({...rest}: IPieChart) => {
  const {loading, data} = rest;
  if (loading === false && isEmpty(data)) {
    return <Empty />
  }
  if (isEmpty(data)) {
    rest.data = [];
  }
  return (
    <Pie {...defaultConfig} {...rest} />
  );
};
