diff --git a/app/results/[id]/page.tsx b/app/results/[id]/page.tsx index c3a16ea..93967e5 100644 --- a/app/results/[id]/page.tsx +++ b/app/results/[id]/page.tsx @@ -3,6 +3,11 @@ import {Chart} from "@components/custom/chart"; import Prisma from '@lib/prisma' +interface data { + name: string + total: number +} + export default async function Page({ params }: { params: { id: string } }) { const grades = await Prisma.grade.findMany({ where: { @@ -10,12 +15,27 @@ export default async function Page({ params }: { params: { id: string } }) { } }) + const allGrades = ['1', '1.5', '2', '2.5', '3', '3.5', '4', '4.5', '5', '5.5', '6'] + let gradeOccurences = new Array(allGrades.length).fill(0) + const gradeList = grades.map((grade) => grade.grade) + + for (let i = 0; i < gradeList.length; i++) { + gradeOccurences[allGrades.indexOf(gradeList[i].toString())]++ + } + + let data: data[] = [] + for (let i = 0; i < gradeOccurences.length; i++) { + data.push({ + name: allGrades[i], + total: gradeOccurences[i] + }) + } + for (let grade in grades) { console.log(grade); } return
- My Post: {params.id} - +
} diff --git a/components/custom/chart.tsx b/components/custom/chart.tsx index dcab596..50bd8fb 100644 --- a/components/custom/chart.tsx +++ b/components/custom/chart.tsx @@ -25,7 +25,8 @@ export function Chart({...props}: ChartProps) { fontSize={12} tickLine={false} axisLine={false} - tickFormatter={(value) => `$${value}`} + allowDecimals={false} + tickFormatter={(value) => `${value}`} /> diff --git a/components/custom/dayCard.tsx b/components/custom/dayCard.tsx index 9334e63..e0faea9 100644 --- a/components/custom/dayCard.tsx +++ b/components/custom/dayCard.tsx @@ -37,7 +37,7 @@ export function DayCard({ className, ...props }: DayCardProps) { } return ( - {route(props.enabled || false, props.day)}}> + {route(props.enabled || false, props.day)}}> {props.enabled ?