import React from 'react';
import { Line } from '@ant-design/charts';
import { LineConfig } from '@ant-design/charts/es/line';
import defaultConfig from '../_utils/theme';
import isEmpty from '../_utils/isEmpty';
import { Empty } from 'antd';
import './index.less';

export interface ILineChart extends LineConfig {}

const lineDefaultConfig = {
  point: {
    size: 5,
    shape: 'circle',
  },
};
export default ({ ...rest }: ILineChart) => {
  const { loading, data } = rest;
  if (loading === false && isEmpty(data)) {
    return <Empty />;
  }
  if (isEmpty(data)) {
    rest.data = [];
  }
  return <Line {...defaultConfig} {...lineDefaultConfig} {...rest} />;
};
