mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-11-03 03:18:52 +00:00
Upstream sync from shadcn-ui/ui (1686 commits since last merge base). Key changes: - packages/shadcn upgraded to 4.1.0 (CLI font transformers, scaffold from github, chart colors) - apps/v4 replaces apps/www as the primary docs/registry app - Font system: 25+ heading font registries, font markers utility, @supports override - Chart improvements: recharts v3 compat, radial chart fixes - templates/ updated with monorepo variants (astro, vite, react-router, start) - skills/shadcn AI skill definitions added - deprecated/ removed (auth, auth-firebase, cli, www) Preserved Hanzo-only paths: app/, pkg/, demo/, docs/, template/next/
122 lines
3.4 KiB
TypeScript
122 lines
3.4 KiB
TypeScript
"use client"
|
|
|
|
import { TrendingUp } from "lucide-react"
|
|
import { PolarAngleAxis, PolarGrid, Radar, RadarChart } from "recharts"
|
|
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardFooter,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/registry/new-york-v4/ui/card"
|
|
import {
|
|
ChartContainer,
|
|
ChartTooltip,
|
|
ChartTooltipContent,
|
|
type ChartConfig,
|
|
} from "@/registry/new-york-v4/ui/chart"
|
|
|
|
export const description = "A radar chart with a custom label"
|
|
|
|
const chartData = [
|
|
{ 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 chartConfig = {
|
|
desktop: {
|
|
label: "Desktop",
|
|
color: "var(--chart-1)",
|
|
},
|
|
mobile: {
|
|
label: "Mobile",
|
|
color: "var(--chart-2)",
|
|
},
|
|
} satisfies ChartConfig
|
|
|
|
export function ChartRadarLabelCustom() {
|
|
return (
|
|
<Card>
|
|
<CardHeader className="items-center pb-4">
|
|
<CardTitle>Radar Chart - Custom Label</CardTitle>
|
|
<CardDescription>
|
|
Showing total visitors for the last 6 months
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="pb-0">
|
|
<ChartContainer
|
|
config={chartConfig}
|
|
className="mx-auto aspect-square max-h-[250px]"
|
|
>
|
|
<RadarChart
|
|
data={chartData}
|
|
margin={{
|
|
top: 10,
|
|
right: 10,
|
|
bottom: 10,
|
|
left: 10,
|
|
}}
|
|
>
|
|
<ChartTooltip
|
|
cursor={false}
|
|
content={<ChartTooltipContent indicator="line" />}
|
|
/>
|
|
<PolarAngleAxis
|
|
dataKey="month"
|
|
tick={({ x, y, textAnchor, index, ...props }) => {
|
|
const data = chartData[index]
|
|
const yValue = typeof y === "number" ? y : 0
|
|
|
|
return (
|
|
<text
|
|
x={x}
|
|
y={yValue + (index === 0 ? -10 : 0)}
|
|
textAnchor={textAnchor}
|
|
fontSize={13}
|
|
fontWeight={500}
|
|
{...props}
|
|
>
|
|
<tspan>{data.desktop}</tspan>
|
|
<tspan className="fill-muted-foreground">/</tspan>
|
|
<tspan>{data.mobile}</tspan>
|
|
<tspan
|
|
x={x}
|
|
dy={"1rem"}
|
|
fontSize={12}
|
|
className="fill-muted-foreground"
|
|
>
|
|
{data.month}
|
|
</tspan>
|
|
</text>
|
|
)
|
|
}}
|
|
/>
|
|
|
|
<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 text-sm">
|
|
<div className="flex items-center gap-2 leading-none font-medium">
|
|
Trending up by 5.2% this month <TrendingUp className="h-4 w-4" />
|
|
</div>
|
|
<div className="flex items-center gap-2 leading-none text-muted-foreground">
|
|
January - June 2024
|
|
</div>
|
|
</CardFooter>
|
|
</Card>
|
|
)
|
|
}
|