-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #543 from COS301-SE-2024/release/demo4
Release/demo4
- Loading branch information
Showing
16 changed files
with
415 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
"use client"; | ||
|
||
import { TrendingUp } from "lucide-react"; | ||
import { Area, AreaChart, CartesianGrid, XAxis } from "recharts"; | ||
|
||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/components/ui/card"; | ||
import { | ||
ChartConfig, | ||
ChartContainer, | ||
ChartTooltip, | ||
ChartTooltipContent, | ||
} from "@/components/ui/chart"; | ||
import { useMemo } from "react"; | ||
|
||
export const description = "A simple area chart"; | ||
|
||
const chartData = [ | ||
{ month: "January", desktop: 186 }, | ||
{ month: "February", desktop: 305 }, | ||
{ month: "March", desktop: 237 }, | ||
{ month: "April", desktop: 73 }, | ||
{ month: "May", desktop: 209 }, | ||
{ month: "June", desktop: 214 }, | ||
]; | ||
|
||
const chartConfig = { | ||
desktop: { | ||
label: "Desktop", | ||
color: "hsl(var(--chart-1))", | ||
}, | ||
} satisfies ChartConfig; | ||
|
||
export function MonthlyChart({ data }: { data: Record<string, number> }) { | ||
const processed = useMemo( | ||
() => | ||
Object.keys(data) | ||
.sort() | ||
.map((key) => ({ | ||
time: key, | ||
count: data[key], | ||
})), | ||
[data] | ||
); | ||
|
||
return ( | ||
<Card className="mx-0"> | ||
<CardHeader> | ||
<CardTitle>Dispute Length</CardTitle> | ||
<CardDescription>Showing how long disputes take over time</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<ChartContainer config={chartConfig}> | ||
<AreaChart | ||
accessibilityLayer | ||
data={processed} | ||
margin={{ | ||
left: 12, | ||
right: 12, | ||
}} | ||
> | ||
<CartesianGrid vertical={false} /> | ||
<XAxis dataKey="time" tickLine={false} axisLine={false} tickMargin={8} /> | ||
<ChartTooltip cursor={false} content={<ChartTooltipContent indicator="line" />} /> | ||
<Area | ||
dataKey="count" | ||
type="natural" | ||
fill="#78A8FF" | ||
fillOpacity={0.4} | ||
stroke="#78A8FF" | ||
/> | ||
</AreaChart> | ||
</ChartContainer> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
52 changes: 52 additions & 0 deletions
52
admin-frontend/src/components/analytics/objections-bars.tsx
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,52 @@ | ||
"use client"; | ||
|
||
import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"; | ||
|
||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; | ||
import { | ||
ChartConfig, | ||
ChartContainer, | ||
ChartTooltip, | ||
ChartTooltipContent, | ||
} from "@/components/ui/chart"; | ||
import { useMemo } from "react"; | ||
|
||
const chartConfig = {} satisfies ChartConfig; | ||
|
||
export function ObjectionBarChart({ | ||
title, | ||
description, | ||
data, | ||
}: { | ||
title: string; | ||
description: string; | ||
data: Record<string, number>; | ||
}) { | ||
const processed = useMemo( | ||
() => | ||
Object.entries(data).map(([key, value]) => ({ | ||
name: key, | ||
count: value, | ||
})), | ||
[data] | ||
); | ||
|
||
return ( | ||
<Card className="mx-0"> | ||
<CardHeader> | ||
<CardTitle>{title}</CardTitle> | ||
<CardDescription>{description}</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<ChartContainer config={chartConfig}> | ||
<BarChart accessibilityLayer data={processed}> | ||
<CartesianGrid vertical={false} /> | ||
<XAxis dataKey="name" tickLine={false} tickMargin={10} axisLine={false} /> | ||
<ChartTooltip cursor={false} content={<ChartTooltipContent hideLabel />} /> | ||
<Bar dataKey="count" radius={8} fill="#78A8FF" /> | ||
</BarChart> | ||
</ChartContainer> | ||
</CardContent> | ||
</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
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
Oops, something went wrong.