-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import dayjs from 'dayjs' | ||
type DataType = { | ||
date: string | ||
nowTotal: { ac: number; co: number } | ||
data: { date: string; accept: number; collect: number }[] | ||
} | ||
type ChartDataType = { | ||
label: string | ||
transition: number | ||
cumulative: number | ||
}[] | ||
export default (Data: DataType) => { | ||
// 検査陽性者の状況 | ||
const updatedAt = dayjs(Data.date).format('YYYY/MM/DD HH:mm') | ||
|
||
const data = Data.data | ||
const today = new Date() | ||
const chartDataAccept: ChartDataType = [] | ||
const chartDataCollect: ChartDataType = [] | ||
let acSum = 0 | ||
let coSum = 0 | ||
data | ||
.filter((d) => new Date(d.date) < today) | ||
.forEach((d) => { | ||
const date = new Date(d.date) | ||
if (!isNaN(d.accept) && !isNaN(d.collect)) { | ||
acSum += d.accept | ||
coSum += d.collect | ||
chartDataAccept.push({ | ||
label: `${date.getFullYear()}/${ | ||
date.getMonth() + 1 | ||
}/${date.getDate()}`, | ||
transition: d.accept, | ||
cumulative: acSum, | ||
}) | ||
chartDataCollect.push({ | ||
label: `${date.getFullYear()}/${ | ||
date.getMonth() + 1 | ||
}/${date.getDate()}`, | ||
transition: d.collect, | ||
cumulative: coSum, | ||
}) | ||
} | ||
}) | ||
|
||
return { | ||
chartDataAccept, | ||
chartDataCollect, | ||
updatedAt, | ||
} | ||
} |