-
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.
- Loading branch information
Showing
10 changed files
with
273 additions
and
4,938 deletions.
There are no files selected for viewing
126 changes: 69 additions & 57 deletions
126
client/src/components/pages/transaction/CategoryPieChart2.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 |
---|---|---|
@@ -1,96 +1,108 @@ | ||
"use client" | ||
|
||
import { TrendingUp } from "lucide-react" | ||
import { LabelList, Pie, PieChart } from "recharts" | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { LabelList, Pie, PieChart } from "recharts"; | ||
|
||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/components/ui/card" | ||
} from "@/components/ui/card"; | ||
import { | ||
ChartConfig, | ||
ChartContainer, | ||
ChartTooltip, | ||
ChartTooltipContent, | ||
} from "@/components/ui/chart" | ||
} from "@/components/ui/chart"; | ||
import { Skeleton } from "@/components/ui/skeleton"; | ||
const chartData = [ | ||
{ browser: "bills", transactions: 275, fill: "var(--color-bills)" }, | ||
{ browser: "safari", transactions: 200, fill: "var(--color-safari)" }, | ||
{ browser: "firefox", transactions: 187, fill: "var(--color-firefox)" }, | ||
{ browser: "edge", transactions: 173, fill: "var(--color-edge)" }, | ||
{ browser: "other", transactions: 90, fill: "var(--color-other)" }, | ||
] | ||
{ categoryName: "funds", transactions: 1, fill: "hsl(var(--chart-4))" }, | ||
{ categoryName: "beg", transactions: 1, fill: "hsl(var(--chart-5))" }, | ||
{ categoryName: "null", transactions: 4, fill: "hsl(var(--chart-3))" }, | ||
]; | ||
|
||
const chartConfig = { | ||
transactions: { | ||
label: "transactions", | ||
}, | ||
bills: { | ||
label: "Bills", | ||
beg: { | ||
label: "beg", | ||
color: "yellow", | ||
}, | ||
safari: { | ||
label: "Safari", | ||
funds: { | ||
label: "funds", | ||
color: "green", | ||
}, | ||
firefox: { | ||
label: "Firefox", | ||
null: { | ||
label: "null", | ||
color: "blue", | ||
}, | ||
edge: { | ||
label: "Edge", | ||
color: "red", | ||
}, | ||
other: { | ||
label: "Other", | ||
color: "purple", | ||
}, | ||
} satisfies ChartConfig | ||
} satisfies ChartConfig; | ||
|
||
export function CategoryPieChart2() { | ||
export function CategoryPieChart2({ | ||
data, | ||
isLoading, | ||
error, | ||
}: { | ||
data: any; | ||
isLoading?: boolean; | ||
error?: string; | ||
}) { | ||
return ( | ||
<Card className="flex flex-col"> | ||
<CardHeader className="items-center pb-0"> | ||
<CardTitle>Pie Chart - Label List</CardTitle> | ||
<CardDescription>January - June 2024</CardDescription> | ||
<CardTitle>Transaction Category</CardTitle> | ||
</CardHeader> | ||
|
||
<CardContent className="flex-1 pb-0"> | ||
<ChartContainer | ||
config={chartConfig} | ||
className="mx-auto aspect-square max-h-[250px] [&_.recharts-text]:fill-background" | ||
> | ||
<PieChart> | ||
<ChartTooltip | ||
content={<ChartTooltipContent className="" nameKey="transactions" hideLabel />} | ||
/> | ||
<Pie data={chartData} dataKey="transactions"> | ||
<LabelList | ||
dataKey="browser" | ||
className="fill-background" | ||
stroke="none" | ||
fontSize={12} | ||
formatter={(value: keyof typeof chartConfig) => | ||
chartConfig[value]?.label | ||
{isLoading ? ( | ||
<div className="py-8 flex items-center justify-center"> | ||
<Skeleton className="h-48 w-48 rounded-full bg-neutral-200" /> | ||
</div> | ||
): error ? ( | ||
<div className="py-20"> | ||
<p className="text-center text-xl">Error loading transactions Categories</p> | ||
</div> | ||
) :( | ||
<CardContent className="flex-1 pb-0"> | ||
<ChartContainer | ||
config={chartConfig} | ||
className="mx-auto aspect-square max-h-[250px] [&_.recharts-text]:fill-background" | ||
> | ||
<PieChart> | ||
<ChartTooltip | ||
content={ | ||
<ChartTooltipContent | ||
className="" | ||
nameKey="transactions" | ||
hideLabel | ||
/> | ||
} | ||
/> | ||
</Pie> | ||
</PieChart> | ||
</ChartContainer> | ||
</CardContent> | ||
<Pie data={chartData} dataKey="transactions"> | ||
<LabelList | ||
dataKey="categoryName" | ||
className="fill-background" | ||
stroke="none" | ||
fontSize={12} | ||
formatter={(value: keyof typeof chartConfig) => | ||
chartConfig[value]?.label | ||
} | ||
/> | ||
</Pie> | ||
</PieChart> | ||
</ChartContainer> | ||
</CardContent> | ||
)} | ||
|
||
<CardFooter className="flex-col gap-2 text-sm"> | ||
<div className="flex items-center gap-2 font-medium leading-none"> | ||
{/* <div className="flex items-center gap-2 font-medium leading-none"> | ||
Trending up by 5.2% this month <TrendingUp className="h-4 w-4" /> | ||
</div> | ||
<div className="leading-none text-muted-foreground"> | ||
Showing total visitors for the last 6 months | ||
</div> */} | ||
<div className="leading-none text-muted-foreground text-center"> | ||
Showing transaction category for the current month | ||
</div> | ||
</CardFooter> | ||
</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
Oops, something went wrong.