diff --git a/packages/xgen/components/chart/NumberChart/index.tsx b/packages/xgen/components/chart/NumberChart/index.tsx index c2cfad8d..5373c199 100644 --- a/packages/xgen/components/chart/NumberChart/index.tsx +++ b/packages/xgen/components/chart/NumberChart/index.tsx @@ -31,7 +31,7 @@ const Index = (props: IProps) => { const global = useGlobal() const ref = useRef(null) - const current = props.data[props.data.length - 1] + const current = props.data[props.data.length - 1] || { value : 0} const is_dark = global.theme === 'dark' const is_line = props.type === 'line' diff --git a/packages/xgen/services/utils/column.ts b/packages/xgen/services/utils/column.ts index 6c6e9254..5cdddcf3 100644 --- a/packages/xgen/services/utils/column.ts +++ b/packages/xgen/services/utils/column.ts @@ -40,7 +40,7 @@ export class ColumnUtils { } reduce(columns: Array, fields: Common.Fields) { - return columns.reduce((total: Array, item) => { + return (columns || []).reduce((total: Array, item) => { total.push(this.handleTableColumn(item, fields)) return total @@ -48,7 +48,7 @@ export class ColumnUtils { } reduceAny(columns: Array, fields: F & Fields) { - return columns.reduce((total: Array, item) => { + return (columns || []).reduce((total: Array, item) => { total.push(this.handleAnyColumn(item, fields)) return total @@ -69,11 +69,11 @@ export class ColumnUtils { return total } - return sections.reduce((total: Array, item) => { + return (sections || []).reduce((total: Array, item) => { total.push({ title: item.title, desc: item.desc, - columns: item.columns.reduce(getColumns, []) + columns: (item.columns || []).reduce(getColumns, []) }) return total @@ -94,11 +94,11 @@ export class ColumnUtils { return total } - return columns.reduce((total: Array, item) => { + return (columns || []).reduce((total: Array, item) => { if ('rows' in item) { total.push({ width: item.width, - rows: item.rows.reduce(getColumns, []) + rows: (item.rows || []).reduce(getColumns, []) }) } else { total.push(this.handleAnyColumn(item, fields))