export function checkEmptyData()

in src/common/checkFunctions.ts [7:35]


export function checkEmptyData(data: any, chartType: string) {
  const type = (getEmptyDataType() as any)[chartType]?.emptyJudge;
  if (type === EmptyJudgeType.COMMON) {
    return (
      !data ||
      (Array.isArray(data) && data?.length === 0) ||
      (Array.isArray(data) &&
        data?.every((item: any) => !item?.data || item?.data?.length === 0)) ||
      Object.keys(data)?.length === 0
    );
  }
  if (type === EmptyJudgeType.CHILDREN) {
    return !data || !data?.children || data?.children?.length === 0;
  }
  if (type === EmptyJudgeType.ARRAY) {
    return !data || data?.length === 0;
  }
  if (type === EmptyJudgeType.GRAPH) {
    return (
      !data ||
      !data?.nodes ||
      data?.nodes?.length === 0 ||
      !data?.links ||
      data?.links?.length === 0
    );
  }

  return false;
}