Skip to content

Commit 8713d61

Browse files
committed
chore: add balance chart
1 parent 0aa9c8e commit 8713d61

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

src/components/BalanceChart.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts"
2+
import { type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent } from "@/components/ui/chart"
3+
4+
const config = {
5+
bitcoin: {
6+
label: "Bitcoin",
7+
color: "#2563eb",
8+
}
9+
} satisfies ChartConfig
10+
11+
export function BalanceChart() {
12+
const data = [
13+
{ month: "January", bitcoin: 186, },
14+
{ month: "February", bitcoin: 305, },
15+
{ month: "March", bitcoin: 237, },
16+
{ month: "April", bitcoin: 73 },
17+
{ month: "May", bitcoin: 209 },
18+
{ month: "June", bitcoin: 214 },
19+
{ month: "July", bitcoin: 21 },
20+
{ month: "August", bitcoin: 32 },
21+
{ month: "September", bitcoin: 0 },
22+
{ month: "October", bitcoin: 0 },
23+
{ month: "November", bitcoin: 0 },
24+
{ month: "December", bitcoin: 0 },
25+
]
26+
27+
return (
28+
<ChartContainer config={config} className="min-h-[200px] w-full">
29+
<BarChart accessibilityLayer data={data}>
30+
<CartesianGrid vertical={false} />
31+
<XAxis
32+
dataKey="month"
33+
tickLine={false}
34+
tickMargin={10}
35+
axisLine={false}
36+
tickFormatter={(value: string) => value.slice(0, 3)}
37+
/>
38+
<YAxis
39+
dataKey="bitcoin"
40+
tickLine={false}
41+
tickMargin={10}
42+
axisLine={false}
43+
/>
44+
<Bar dataKey="bitcoin" fill="var(--color-bitcoin)" radius={4} />
45+
<ChartLegend content={<ChartLegendContent />} />
46+
</BarChart>
47+
</ChartContainer>
48+
)
49+
}

src/index.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,21 @@
126126
@apply bg-background text-foreground;
127127
}
128128
}
129+
130+
@layer base {
131+
:root {
132+
--chart-1: 12 76% 61%;
133+
--chart-2: 173 58% 39%;
134+
--chart-3: 197 37% 24%;
135+
--chart-4: 43 74% 66%;
136+
--chart-5: 27 87% 67%;
137+
}
138+
139+
.dark {
140+
--chart-1: 220 70% 50%;
141+
--chart-2: 160 60% 45%;
142+
--chart-3: 30 80% 55%;
143+
--chart-4: 280 65% 60%;
144+
--chart-5: 340 75% 55%;
145+
}
146+
}

src/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default function Layout() {
66
return (
77
<SidebarProvider>
88
<AppSidebar />
9-
<main className="flex flex-col px-2 py-2">
9+
<main className="flex-1 flex flex-col px-2 py-2">
1010
<div>
1111
<SidebarTrigger />
1212
</div>

src/pages/balances/BalancesPage.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BalanceChart } from "@/components/BalanceChart";
12
import { Breadcrumbs } from "@/components/Breadcrumbs";
23
import { PageTitle } from "@/components/PageTitle";
34

@@ -6,6 +7,10 @@ export default function BalancesPage() {
67
<>
78
<Breadcrumbs>Balances</Breadcrumbs>
89
<PageTitle>Balances</PageTitle>
10+
11+
<div className="flex max-h-[500px] max-w-[320px] py-4">
12+
<BalanceChart />
13+
</div>
914
</>
1015
)
1116
}

0 commit comments

Comments
 (0)