修改mqtt连接方式

This commit is contained in:
GGJ
2024-12-30 10:07:26 +08:00
parent 0f57e4b746
commit 6a06652532
19 changed files with 173 additions and 93 deletions

View File

@@ -1,49 +1,46 @@
const dataProcessing = (arr: any[]) => {
return arr
.filter(item => typeof item == 'number' || (typeof item == 'string' && !isNaN(parseFloat(item))))
.map(item => (typeof item == 'number' ? item : parseFloat(item)))
.filter(item => typeof item === 'number' || (typeof item === 'string' && !isNaN(parseFloat(item))))
.map(item => (typeof item === 'number' ? item : parseFloat(item)))
}
// 处理y轴最大最小值
export const yMethod = (arr: any) => {
const numList = dataProcessing(arr);
const maxValue = Math.max(...numList);
const minValue = Math.min(...numList);
const calculateBoundary = (value: number, base: number) => {
return Math[value > 0? 'ceil' : 'floor'](value / base) * base;
};
let max: number;
let min: number;
let numList = dataProcessing(arr)
let maxValue = 0
let minValue = 0
let max = 0
let min = 0
maxValue = Math.max(...numList)
minValue = Math.min(...numList)
if (maxValue > 1000 || minValue < -1000) {
max = calculateBoundary(maxValue, 100);
min = minValue == 0? 0 : calculateBoundary(minValue, 100);
} else if (maxValue < 60 && minValue > 40) {
max = 60;
min = 40;
} else if (maxValue == minValue) {
if (maxValue < 10 && minValue > 0) {
max = calculateBoundary(maxValue, 10);
min = calculateBoundary(minValue, 10);
} else if (maxValue!== 0 && minValue!== 0) {
max = calculateBoundary(maxValue / 10 + 1, 10);
min = calculateBoundary(minValue / 10 - 1, 10);
max = Math.ceil(maxValue / 100) * 100
if (minValue == 0) {
min = 0
} else {
min = Math.floor(minValue / 100) * 100
}
} else if (maxValue < 60 && minValue > 40) {
max = 60
min = 40
} else if (maxValue == minValue && maxValue < 10 && minValue > 0) {
max = Math.ceil(maxValue / 10) * 10
min = Math.floor(minValue / 10) * 10
} else if (maxValue == minValue && maxValue != 0 && minValue != 0) {
max = Math.ceil(maxValue / 10 + 1) * 10
min = Math.floor(minValue / 10 - 1) * 10
} else {
max = calculateBoundary(maxValue, 10);
min = calculateBoundary(minValue, 10);
max = Math.ceil(maxValue / 10) * 10
min = Math.floor(minValue / 10) * 10
}
if (maxValue > 0 && maxValue < 1) {
max = 1;
max = 1
} else if (max == 0 && minValue > -1 && minValue < 0) {
min = -1
}
if (max == 0 && minValue > -1 && minValue < 0) {
min = -1;
}
return [min, max];
};
return [min, max]
}
/**
* title['A相','B相',]
@@ -51,7 +48,7 @@ export const yMethod = (arr: any) => {
*/
// 导出csv文件
const convertToCSV = (title: object, data: any) => {
// console.log('🚀 ~ convertToCSV ~ data:', data)
console.log('🚀 ~ convertToCSV ~ data:', data)
let csv = ''
// 添加列头
csv += ',' + title.join(',') + '\n'