feat(web): add download image function&fix null data point (#1653)

This commit is contained in:
chenluli
2024-06-21 17:02:49 +08:00
committed by GitHub
parent 889c3451d6
commit c57ee0289b
4 changed files with 97 additions and 30 deletions

View File

@@ -66,3 +66,12 @@ export const sortData = ({ data, chartType, xField }: {
}
return sortedData
}
/** 数据空值处理:后端返回的空数据为 '-', 在展示为图表时会有问题,修改为 null */
export const processNilData = (data: Datum[], emptyValue = '-') => data.map((datum) => {
const processedDatum: Record<string, string | number | null> = {};
Object.keys(datum).forEach((key) => {
processedDatum[key] = datum[key] === emptyValue ? null : datum[key];
});
return processedDatum;
});