Conformance: fix ConformanceResults show or not Time Trend.

This commit is contained in:
chiayin
2023-09-04 12:26:16 +08:00
parent 60182c3148
commit 9c53e298be
2 changed files with 45 additions and 30 deletions

View File

@@ -66,7 +66,6 @@ export function setBarChartData(baseData) {
y: i.y
}
})
// console.log(data);
return data
};
/**
@@ -119,7 +118,7 @@ export function yTimeRange(data, yAmount, yMax) {
if(yRange.length < yAmount) {
let len = yAmount - yRange.length;
for (let i = 0; i < len; i++) {
yRange.push(yMax)
yRange.push(yRange[yRange.length - 1]);
}
}
else if(yRange.length > yAmount) {
@@ -160,22 +159,24 @@ export function getXIndex(data, xValue) {
* @returns {string}
*/
export function formatTime(seconds) {
const days = Math.floor(seconds / (3600 * 24));
const hours = Math.floor((seconds % (3600 * 24)) / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const remainingSeconds = seconds % 60;
if(!isNaN(seconds)) {
const remainingSeconds = seconds % 60;
const minutes = (Math.floor(seconds - remainingSeconds) / 60) % 60;
const hours = (Math.floor(seconds / 3600)) % 24;
const days = Math.floor(seconds / (3600 * 24));
let result = '';
if (days > 0) {
result += `${days}d`;
}
if (hours > 0) {
result += `${hours}h`;
}
if (minutes > 0) {
result += `${minutes}m`;
}
result += `${remainingSeconds}s`;
let result = '';
if (days > 0) {
result += `${days}d`;
}
if (hours > 0) {
result += `${hours}h`;
}
if (minutes > 0) {
result += `${minutes}m`;
}
result += `${remainingSeconds}s`;
return result.trim(); // 去除最后一个空格
return result.trim(); // 去除最后一个空格
} else return null;
}