修改测试bug

This commit is contained in:
GGJ
2024-10-22 10:50:47 +08:00
parent 29150a3c82
commit 7d2394f75d
6 changed files with 126 additions and 65 deletions

View File

@@ -1,3 +1,4 @@
// 处理y轴最大最小值
export const yMethod = (arr: any) => {
let maxValue = 0
let minValue = 0
@@ -24,3 +25,24 @@ export const yMethod = (arr: any) => {
}
return [min, max]
}
// 导出csv文件
const convertToCSV = (title: object,data) => {
let csv = '';
// 添加列头
csv += ' ,'+title.join(',') + '\n';
// 遍历数据并添加到CSV字符串中
data.forEach(item => {
csv += `${item.x},${item.y}\n`;
});
return csv;
}
export const exportCSV = (title: object,data: any,filename:string) => {
const csv = convertToCSV(title,data);
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = filename;
link.click();
// 释放URL对象
URL.revokeObjectURL(link.href);
}