mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-26 14:16:08 +00:00
79 lines
2.2 KiB
TypeScript
79 lines
2.2 KiB
TypeScript
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardFooter,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/examples/base/ui/card"
|
|
import {
|
|
ChartContainer,
|
|
ChartTooltip,
|
|
ChartTooltipContent,
|
|
type ChartConfig,
|
|
} from "@/examples/base/ui/chart"
|
|
import { TrendingUpIcon } from "lucide-react"
|
|
import { PolarAngleAxis, PolarGrid, Radar, RadarChart } from "recharts"
|
|
|
|
const radarChartData = [
|
|
{ month: "January", desktop: 186, mobile: 80 },
|
|
{ month: "February", desktop: 305, mobile: 200 },
|
|
{ month: "March", desktop: 237, mobile: 120 },
|
|
{ month: "April", desktop: 73, mobile: 190 },
|
|
{ month: "May", desktop: 209, mobile: 130 },
|
|
{ month: "June", desktop: 214, mobile: 140 },
|
|
]
|
|
|
|
const radarChartConfig = {
|
|
desktop: {
|
|
label: "Desktop",
|
|
color: "var(--chart-1)",
|
|
},
|
|
mobile: {
|
|
label: "Mobile",
|
|
color: "var(--chart-2)",
|
|
},
|
|
} satisfies ChartConfig
|
|
|
|
export function ChartRadarExample() {
|
|
return (
|
|
<Card className="w-full">
|
|
<CardHeader className="items-center pb-4">
|
|
<CardTitle>Radar Chart - Multiple</CardTitle>
|
|
<CardDescription>
|
|
Showing total visitors for the last 6 months
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="pb-0">
|
|
<ChartContainer
|
|
config={radarChartConfig}
|
|
className="mx-auto aspect-square max-h-[250px]"
|
|
>
|
|
<RadarChart data={radarChartData}>
|
|
<ChartTooltip
|
|
cursor={false}
|
|
content={<ChartTooltipContent indicator="line" />}
|
|
/>
|
|
<PolarAngleAxis dataKey="month" />
|
|
<PolarGrid />
|
|
<Radar
|
|
dataKey="desktop"
|
|
fill="var(--color-desktop)"
|
|
fillOpacity={0.6}
|
|
/>
|
|
<Radar dataKey="mobile" fill="var(--color-mobile)" />
|
|
</RadarChart>
|
|
</ChartContainer>
|
|
</CardContent>
|
|
<CardFooter className="flex-col gap-2">
|
|
<div className="flex items-center gap-2 leading-none font-medium">
|
|
Trending up by 5.2% this month <TrendingUpIcon className="size-4" />
|
|
</div>
|
|
<div className="text-muted-foreground flex items-center gap-2 leading-none">
|
|
January - June 2024
|
|
</div>
|
|
</CardFooter>
|
|
</Card>
|
|
)
|
|
}
|