sabo/src/components/dashboard/chart-area-interactive.tsx
When to use
- Visualize KPIs and time-series within dashboard sections.
Usage
Styling tip
- Define series colors via
ChartContainerconfig for light/dark theme parity.
Key features
- Theme-aware colors: Define colors via
ChartConfigfor automatic light/dark mode support - Recharts integration: Uses Recharts components (AreaChart, LineChart, BarChart) inside
ChartContainer - Interactive: Supports tooltips, legends, and click handlers
- Responsive: Container queries adjust sizing based on available space
Steps
1
Create chart config
Define series with labels and colors. Colors can be simple strings or theme-specific objects:
2
Prepare data
Start with static arrays. Later, fetch from Supabase or your API. Ensure keys match
ChartConfig series names.3
Format axes and tooltips
Use Recharts’
tickFormatter for axes and Tooltip content formatters:4
Add interactivity
Enable tooltips, legends, and click handlers for drill-down:
Troubleshooting
- Colors not changing with theme
- Ensure you’re using
var(--color-{series})in Recharts components
- Ensure you’re using
- Chart not responsive
- Wrap in
ChartContainerwithclassNameheight/width
- Wrap in
- Data not showing
- Verify
dataKeyprops match your data object keys exactly
- Verify