105 lines
2.6 KiB
TypeScript
105 lines
2.6 KiB
TypeScript
"use client"
|
|
|
|
import { GitCommitVertical, TrendingUp } from "lucide-react"
|
|
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"
|
|
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardFooter,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/components/ui/card"
|
|
import {
|
|
ChartContainer,
|
|
ChartTooltip,
|
|
ChartTooltipContent,
|
|
type ChartConfig,
|
|
} from "@/components/ui/chart"
|
|
import { formatCurrency } from "@/lib/formatters"
|
|
|
|
export const description = "Menampilkan volume transaksi per bulan."
|
|
|
|
const chartConfig = {
|
|
count: {
|
|
label: "Jumlah Transaksi",
|
|
color: "var(--chart-1)",
|
|
},
|
|
} satisfies ChartConfig
|
|
|
|
export function TransactionVolumeChart({
|
|
data,
|
|
title = "Volume Transaksi",
|
|
description = "Total jumlah pesanan yang diproses per bulan."
|
|
}: {
|
|
data: any[],
|
|
title?: string,
|
|
description?: string
|
|
}) {
|
|
return (
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle>{title}</CardTitle>
|
|
<CardDescription>{description}</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<ChartContainer config={chartConfig} className="aspect-auto h-[300px] w-full">
|
|
<LineChart
|
|
accessibilityLayer
|
|
data={data}
|
|
margin={{
|
|
left: 12,
|
|
right: 12,
|
|
}}
|
|
>
|
|
<CartesianGrid vertical={false} />
|
|
<XAxis
|
|
dataKey="month"
|
|
tickLine={false}
|
|
axisLine={false}
|
|
tickMargin={8}
|
|
tickFormatter={(value) => value.slice(0, 3)}
|
|
/>
|
|
<YAxis
|
|
tickLine={false}
|
|
axisLine={false}
|
|
tickMargin={8}
|
|
width={30}
|
|
/>
|
|
<ChartTooltip
|
|
cursor={false}
|
|
content={<ChartTooltipContent hideLabel />}
|
|
/>
|
|
<Line
|
|
dataKey="count"
|
|
type="natural"
|
|
stroke="var(--color-count)"
|
|
strokeWidth={2}
|
|
dot={({ cx, cy, payload }) => {
|
|
if (cx == null || cy == null) {
|
|
return null
|
|
}
|
|
|
|
const r = 24
|
|
|
|
return (
|
|
<GitCommitVertical
|
|
key={payload.month}
|
|
x={cx - r / 2}
|
|
y={cy - r / 2}
|
|
width={r}
|
|
height={r}
|
|
fill="hsl(var(--background))"
|
|
stroke="var(--color-count)"
|
|
/>
|
|
)
|
|
}}
|
|
/>
|
|
</LineChart>
|
|
</ChartContainer>
|
|
</CardContent>
|
|
</Card>
|
|
)
|
|
}
|