fix nan issue

master
TZGyn 11 months ago
parent 4f8b6b7101
commit 09a307f8d6

2
.gitignore vendored

@ -34,3 +34,5 @@ yarn-error.log*
# typescript # typescript
*.tsbuildinfo *.tsbuildinfo
next-env.d.ts next-env.d.ts
output.txt

@ -97,16 +97,12 @@ export default async function Home() {
<CardContent> <CardContent>
<TabsContent value="month"> <TabsContent value="month">
<DayChart <DayChart
chartData={convertDataToThisMonthPerDayChartData( chartData={convertDataToThisMonthPerDayChartData(thisMonthData)}
thisMonthData
)}
/> />
</TabsContent> </TabsContent>
<TabsContent value="day"> <TabsContent value="day">
<HourChart <HourChart
chartData={convertDataToTodayPerHourChartData( chartData={convertDataToTodayPerHourChartData(todayData)}
todayData
)}
/> />
</TabsContent> </TabsContent>
<TabsContent value="hour"> <TabsContent value="hour">
@ -135,8 +131,6 @@ const convertDataToThisMonthPerDay = (
nextMonthTimestamp.setDate(1); nextMonthTimestamp.setDate(1);
nextMonthTimestamp.setMonth(nextMonthTimestamp.getMonth() + 1); nextMonthTimestamp.setMonth(nextMonthTimestamp.getMonth() + 1);
console.log(thisMonthTimestamp.getTime(), nextMonthTimestamp.getTime());
const thisMonthData = data.filter( const thisMonthData = data.filter(
(data) => (data) =>
data.timestamp >= thisMonthTimestamp.getTime() && data.timestamp >= thisMonthTimestamp.getTime() &&
@ -175,7 +169,7 @@ const convertDataToThisMonthPerDayChartData = (
day: "Day " + day, day: "Day " + day,
value: todayDataPerHour[day].count, value: todayDataPerHour[day].count,
foldtime: foldtime:
todayDataPerHour[day].foldTime / todayDataPerHour[day].count, todayDataPerHour[day].foldTime / todayDataPerHour[day].count || 0,
}; };
}); });
@ -191,8 +185,6 @@ const convertDataToThisHourPerMinute = (
nextHourTimestamp.setHours(nextHourTimestamp.getHours() + 1); nextHourTimestamp.setHours(nextHourTimestamp.getHours() + 1);
nextHourTimestamp.setMinutes(0, 0, 0); nextHourTimestamp.setMinutes(0, 0, 0);
console.log(thisHourTimestamp.getTime(), nextHourTimestamp.getTime());
const todayData = data.filter( const todayData = data.filter(
(data) => (data) =>
data.timestamp >= thisHourTimestamp.getTime() && data.timestamp >= thisHourTimestamp.getTime() &&
@ -224,7 +216,7 @@ const convertDataToThisHourPerMinuteChartData = (
return { return {
minute: "Minute " + i, minute: "Minute " + i,
value: todayDataPerHour[i].count, value: todayDataPerHour[i].count,
foldtime: todayDataPerHour[i].foldTime / todayDataPerHour[i].count, foldtime: todayDataPerHour[i].foldTime / todayDataPerHour[i].count || 0,
}; };
}); });
@ -240,8 +232,6 @@ const convertDataToTodayPerHour = (
tomorrowTimestamp.setHours(0, 0, 0, 0); tomorrowTimestamp.setHours(0, 0, 0, 0);
tomorrowTimestamp.setDate(tomorrowTimestamp.getDate() + 1); tomorrowTimestamp.setDate(tomorrowTimestamp.getDate() + 1);
console.log(todayTimestamp.getTime(), tomorrowTimestamp.getTime());
const todayData = data.filter( const todayData = data.filter(
(data) => (data) =>
data.timestamp >= todayTimestamp.getTime() && data.timestamp >= todayTimestamp.getTime() &&
@ -273,7 +263,7 @@ const convertDataToTodayPerHourChartData = (
return { return {
hour: i + 1 + ":00", hour: i + 1 + ":00",
value: todayDataPerHour[i].count, value: todayDataPerHour[i].count,
foldtime: todayDataPerHour[i].foldTime / todayDataPerHour[i].count, foldtime: todayDataPerHour[i].foldTime / todayDataPerHour[i].count || 0,
}; };
}); });

@ -1 +0,0 @@
1736158869.154258,Towel Detected,6.52
Loading…
Cancel
Save