-
Notifications
You must be signed in to change notification settings - Fork 1
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
yamaji
committed
Nov 14, 2024
1 parent
fb6d592
commit 9309429
Showing
7 changed files
with
381 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Place } from "@/interfaces/place.interface"; | ||
import { DataService } from "@/services/data.service"; | ||
import Card from "../card.component"; | ||
import { Graph } from "../graph.component"; | ||
|
||
export default async function DetectedLisencePlateGraph(props: { place: Place; date: Date }) { | ||
const dataService = new DataService(); | ||
|
||
const year = props.date.getFullYear(); | ||
const month = props.date.getMonth() + 1; | ||
const day = props.date.getDate(); | ||
|
||
const data = (await dataService.get(props.place, year, month, day)).filter( | ||
(row) => row[1] === "LicensePlate", | ||
); | ||
|
||
const licensePlateAt: number[] = (() => { | ||
const arr = []; | ||
for (let _ = 0; _ < 24; _++) arr.push(0); | ||
return arr; | ||
})(); | ||
data.forEach((row) => (licensePlateAt[new Date(row[2]).getHours()] += 1)); | ||
const options = { | ||
series: [ | ||
{ | ||
type: "column", | ||
data: licensePlateAt.map((v, i) => ({ x: `${i}時`, y: `${v}回` })), | ||
}, | ||
], | ||
labels: licensePlateAt.map((_, i) => (i % 3 === 0 ? `${i}時` : "")), | ||
}; | ||
|
||
return ( | ||
<Card title="単位時間あたりにナンバープレートが検出された回数"> | ||
<p className="text-sm">{`合計: ${licensePlateAt.reduce((sum, v) => sum + v, 0)}回`}</p> | ||
<Graph type="bar" series={options.series} options={options} /> | ||
</Card> | ||
); | ||
} |
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,50 @@ | ||
import { Place } from "@/interfaces/place.interface"; | ||
import { DataService } from "@/services/data.service"; | ||
import Card from "../card.component"; | ||
import { Graph } from "../graph.component"; | ||
import { aRegionFromRegion } from "@/interfaces/license-plate.interface"; | ||
|
||
export default async function EstimatedPrefectureGraph(props: { place: Place; date: Date }) { | ||
const dataService = new DataService(); | ||
|
||
const year = props.date.getFullYear(); | ||
const month = props.date.getMonth() + 1; | ||
const day = props.date.getDate(); | ||
|
||
const data = (await dataService.get(props.place, year, month, day)) | ||
.filter((row) => row[1] === "LicensePlate") | ||
.map((row) => aRegionFromRegion(row[7])) | ||
.filter((row) => typeof row !== "undefined") | ||
.reduce( | ||
(p: { answer: string; count: number }[][], c) => { | ||
if (!p[0].map((v) => v.answer).includes(c)) p[0].push({ answer: c, count: 0 }); | ||
p[0][p[0].map((v) => v.answer).indexOf(c)].count += 1; | ||
return p; | ||
}, | ||
[[]], | ||
)[0] | ||
.sort((a, b) => b.count - a.count); | ||
|
||
const options = { | ||
series: data.map((v) => v.count), | ||
labels: data.map((v) => v.answer), | ||
plotOptions: { | ||
pie: { | ||
donut: { | ||
labels: { | ||
show: true, | ||
total: { | ||
show: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<Card title="認識されたナンバープレートの地域の割合"> | ||
<Graph type="donut" series={options.series} options={options} /> | ||
</Card> | ||
); | ||
} |
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,48 @@ | ||
import { Place } from "@/interfaces/place.interface"; | ||
import { DataService } from "@/services/data.service"; | ||
import Card from "../card.component"; | ||
import { Graph } from "../graph.component"; | ||
|
||
export default async function EstimatedRentalCarGraph(props: { place: Place; date: Date }) { | ||
const dataService = new DataService(); | ||
|
||
const year = props.date.getFullYear(); | ||
const month = props.date.getMonth() + 1; | ||
const day = props.date.getDate(); | ||
|
||
const data = (await dataService.get(props.place, year, month, day)) | ||
.filter((row) => row[1] === "LicensePlate") | ||
.map((row) => (["れ", "わ"].includes(row[9]) ? "レンタカー" : "その他")) | ||
.reduce( | ||
(p: { answer: string; count: number }[][], c) => { | ||
if (!p[0].map((v) => v.answer).includes(c)) p[0].push({ answer: c, count: 0 }); | ||
p[0][p[0].map((v) => v.answer).indexOf(c)].count += 1; | ||
return p; | ||
}, | ||
[[]], | ||
)[0] | ||
.sort((a, b) => (a.answer === "レンタカー" ? 0 : 1) - (b.answer === "レンタカー" ? 0 : 1)); | ||
|
||
const options = { | ||
series: data.map((v) => v.count), | ||
labels: data.map((v) => v.answer), | ||
plotOptions: { | ||
pie: { | ||
donut: { | ||
labels: { | ||
show: true, | ||
total: { | ||
show: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<Card title="レンタカーと推測された車の割合"> | ||
<Graph type="donut" series={options.series} options={options} /> | ||
</Card> | ||
); | ||
} |
Oops, something went wrong.