Documentation menu
Getting Started
Components
Primitives
- Agent Thinking
- Alert
- Alert Dialog
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Command
- Command Palette
- Context Menu
- Data Table
- Dialog
- Dropdown Menu
- Empty
- Field
- Glow Cloud
- Input
- Label
- Medication Schedule
- Period Tabs
- Popover
- Rainbow Button
- Scroll Area
- Select
- Selectable Card
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Tag
- Textarea
- Timeline
- Tooltip
- Use Count Up
Charts and metrics
Patterns
- Confirm Button
- Date Picker
- Embedded
- Empty State
- Entity Drawer
- Error Boundary
- Field Row
- File Dropzone
- Form Dialog
- Kv
- List Editor
- List Page
- Live Time
- Mini Table
- Money
- Note Field
- Note Text
- Page Card
- Page Header
- Page Tabs
- Page Toolbar
- Person Cell
- Picture Field
- Print Card
- Range Switcher
- Row Actions
- Search Input
- Search Select
- Selected Box
- Signature Pad
- Status Badge
- Sub Nav Layout
- Suggest Input
- Tab Icons
- Table Footer
- Theme Accent Picker
- Time Picker
- View All Link
Dashboard cards
Advanced
Device frames
Website widgets
Website screens
Website panels
Charts and metrics
Radar Chart
Compares series across several axes.
import { RadarChart } from "@/registry/vcare/ui/radar-chart"
const data = [
{ area: "Strength", now: 62, goal: 80 }, { area: "Mobility", now: 74, goal: 85 }, { area: "Balance", now: 58, goal: 75 },
{ area: "Endurance", now: 69, goal: 80 }, { area: "Pain free", now: 81, goal: 90 },
]
export default function RadarChartDemo() {
return (
<RadarChart
className="mx-auto h-72 max-w-md"
data={data}
angleKey="area"
showLegend
series={[{ key: "now", label: "This week" }, { key: "goal", label: "Goal" }]}
/>
)
}Installation
npx shadcn@latest add @vcare/radar-chartOr install directly from the URL: https://ui.vcarehms.com/r/radar-chart.json
- Install the dependencies:
npm i recharts - Add the registry items it uses: chart, format, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/radar-chart.tsx
import * as React from 'react';
import { PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart as RechartsRadarChart } from 'recharts';
import { cn } from '@/registry/vcare/lib/utils';
import { formatNumber } from '@/registry/vcare/lib/format';
import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, type ChartConfig } from '@/registry/vcare/ui/chart';
export interface RadarSeries {
/** Key in each data row. */
key: string;
label: string;
/** Any CSS color. Defaults to chart-1 through chart-5 in order. */
color?: string;
}
export interface RadarChartProps extends Omit<React.ComponentProps<typeof ChartContainer>, 'config' | 'children'> {
data: Record<string, unknown>[];
/** Key of the category label in each row, one per spoke. */
angleKey: string;
series: RadarSeries[];
/** "filled" shades the area, "line" draws only the outline, "dots" adds a dot at every vertex. */
variant?: 'filled' | 'line' | 'dots';
/** Shape of the background grid rings. */
grid?: 'polygon' | 'circle' | 'none';
/** Show the category label at the end of each spoke. */
showAngleLabels?: boolean;
/** Show value ticks along the vertical spoke. */
showRadiusAxis?: boolean;
showLegend?: boolean;
showTooltip?: boolean;
/** Recharts domain for the value axis, e.g. [0, 100]. Defaults to [0, "auto"]. */
domain?: React.ComponentProps<typeof PolarRadiusAxis>['domain'];
valueFormatter?: (value: number) => string;
/** Animate polygons after hydration and when data changes. Respects reduced motion. */
animate?: boolean;
animationDuration?: number;
/** Extra breathing room for long labels around the chart. */
chartMargin?: { top?: number; right?: number; bottom?: number; left?: number };
}
const reducedMotionQuery = '(prefers-reduced-motion: reduce)';
function subscribeToReducedMotion(onChange: () => void) {
const query = window.matchMedia(reducedMotionQuery);
query.addEventListener('change', onChange);
return () => query.removeEventListener('change', onChange);
}
function getReducedMotionSnapshot() {
return window.matchMedia(reducedMotionQuery).matches;
}
function getReducedMotionServerSnapshot() {
return true;
}
/** A radar chart on shadcn's chart primitives: filled, outlined, or dotted, with one polygon per series. */
function RadarChart({
data,
angleKey,
series,
variant = 'filled',
grid = 'polygon',
showAngleLabels = true,
showRadiusAxis = false,
showLegend = false,
showTooltip = true,
domain,
valueFormatter = (value) => formatNumber(value, { format: 'compact' }),
animate = true,
animationDuration = 500,
chartMargin = { top: 8, right: 24, bottom: 8, left: 24 },
className,
...props
}: RadarChartProps) {
const reducedMotion = React.useSyncExternalStore(subscribeToReducedMotion, getReducedMotionSnapshot, getReducedMotionServerSnapshot);
const config = Object.fromEntries(
series.map((s, index) => [s.key, { label: s.label, color: s.color ?? `var(--chart-${(index % 5) + 1})` }]),
) satisfies ChartConfig;
return (
<ChartContainer data-slot="radar-chart" config={config} className={cn('aspect-auto h-64 w-full', className)} {...props}>
<RechartsRadarChart data={data} margin={chartMargin}>
{grid !== 'none' ? <PolarGrid gridType={grid} /> : null}
<PolarAngleAxis dataKey={angleKey} tickLine={false} axisLine={false} tick={showAngleLabels ? { fill: 'var(--muted-foreground)' } : false} />
<PolarRadiusAxis
angle={90}
domain={domain}
axisLine={false}
tick={showRadiusAxis ? { fill: 'var(--muted-foreground)' } : false}
tickFormatter={valueFormatter}
/>
{showTooltip ? (
<ChartTooltip
cursor={false}
content={
<ChartTooltipContent
indicator="dot"
formatter={(value, name, item) => (
<div className="flex w-full items-center gap-2">
<span className="size-2 shrink-0 rounded-[2px]" style={{ backgroundColor: item.color }} />
<span className="text-muted-foreground flex-1">{config[name as string]?.label ?? name}</span>
<span className="font-mono font-medium tabular-nums">{valueFormatter(Number(value))}</span>
</div>
)}
/>
}
/>
) : null}
{showLegend ? <ChartLegend content={<ChartLegendContent />} /> : null}
{series.map((s) => {
const color = `var(--color-${s.key})`;
return (
<Radar
key={s.key}
dataKey={s.key}
stroke={color}
strokeWidth={2}
fill={color}
fillOpacity={variant === 'filled' ? 0.25 : 0}
dot={variant === 'dots' ? { r: 3, fill: color, strokeWidth: 0 } : false}
activeDot={{
r: 4,
fill: color,
stroke: 'var(--background)',
strokeWidth: 2,
}}
isAnimationActive={animate && !reducedMotion}
animationDuration={animationDuration}
animationEasing="ease-out"
/>
);
})}
</RechartsRadarChart>
</ChartContainer>
);
}
export { RadarChart };Usage
import { RadarChart } from "@/components/ui/radar-chart"Exports
RadarChart
Dependencies
recharts@^3.11.1(npm)@vcare/chart(registry)@vcare/format(registry)@vcare/utils(registry)
Raw item: /r/radar-chart.json