Radar Chart
bklit-ui/radar-chartFreeComponent
A composable radar/spider chart with multiple data series
Install it
npx shadcn@latest add https://bklit.com/r/radar-chart.jsonSource
1"use client";23import { Group } from "@visx/group";4import { ParentSize } from "@visx/responsive";5import { scaleLinear } from "@visx/scale";6import type { Transition } from "motion/react";7import { type ReactNode, useCallback, useState } from "react";8import { cn } from "@/lib/utils";9import {10 defaultRadarColors,11 type RadarContextValue,12 type RadarData,13 type RadarMetric,14 RadarProvider,15} from "./radar-context";1617export interface RadarChartProps {18 /** Data array - each item represents a data series (polygon) */19 data: RadarData[];20 /** Metrics to display on the radar */21 metrics: RadarMetric[];22 /** Chart size in pixels. If not provided, uses parent container size */23 size?: number;24 /** Number of concentric grid circles. Default: 5 */25 levels?: number;26 /** Margin around the chart. Default: 60 */27 margin?: number;28 /** Enable animations. Default: true */29 animate?: boolean;30 /** Enter animation budget in ms. Default: 1100 */31 enterDurationMs?: number;32 /** Scales stagger timing (1 = default). */33 staggerScale?: number;34 /** Motion enter transition (spring or cubic-bezier tween). */35 enterTransition?: Transition;36 /** Changes when motion settings change — replays enter animations. */37 motionReplayKey?: string;38 /** Controlled hover state - index of hovered area */39 hoveredIndex?: number | null;40 /** Callback when hover state changes */41 onHoverChange?: (index: number | null) => void;42 /** Additional class name for the container */43 className?: string;44 /** Child components (RadarGrid, RadarAxis, RadarLabels, RadarArea) */45 children: ReactNode;46}4748interface RadarChartInnerProps {49 width: number;50 height: number;51 data: RadarData[];52 metrics: RadarMetric[];53 levels: number;54 margin: number;55 animate: boolean;56 enterDurationMs: number;57 staggerScale: number;58 enterTransition?: Transition;59 motionReplayKey: string;60 children: ReactNode;61 hoveredIndexProp?: number | null;62 onHoverChange?: (index: number | null) => void;63}6465function RadarChartInner({66 width,67 height,68 data,69 metrics,70 levels,71 margin,72 animate,73 enterDurationMs,74 staggerScale,75 enterTransition,76 motionReplayKey,77 children,78 hoveredIndexProp,79 onHoverChange,80}: RadarChartInnerProps) {81 const [internalHoveredIndex, setInternalHoveredIndex] = useState<82 number | null83 >(null);8485 // Use controlled or uncontrolled hover state86 const isControlled = hoveredIndexProp !== undefined;87// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from bklit-ui
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Area Chartarea-chart | bklit-ui | Components | Free | 4 deps · 14 files | |
| Chart Backgroundbackground | bklit-ui | Components | Free | 2 deps · 3 files | |
| Bar Chartbar-chart | bklit-ui | Components | Free | 4 deps · 13 files | |
| Bar Depthbar-depth | bklit-ui | Components | Free | 1 dep | |
| Candlestick Chartcandlestick-chart | bklit-ui | Components | Free | 4 deps · 4 files | |
| Chart Animationchart-animation | bklit-ui | Components | Free | 1 dep · 7 files | |
| Chart Contextchart-context | bklit-ui | Components | Free | 5 deps · 12 files | |
| Chart Series Layerchart-series | bklit-ui | Components | Free | 3 deps · 15 files |
