Overview
Chart components provide visual elements designed to work with charting libraries like Recharts for creating interactive data visualizations.Components
ActiveDot
An animated SVG component that renders an active data point indicator on charts. Features a scale animation on mount and customizable appearance. Props:| Prop | Type | Default | Description |
|---|---|---|---|
x | number | - | Required. X-coordinate position |
y | number | - | Required. Y-coordinate position |
stroke | string | - | Required. Stroke color |
size | number | 32 | Total size of the SVG (width and height) |
strokeWidth | number | 8 | Width of the circle stroke |
fill | string | - | Fill color for the circle |
className | string | - | Custom CSS classes for the SVG element |
- Animated scale effect on mount via CSS animation
- Automatically centers the dot at the specified coordinates
- Client-side component (uses ‘use client’ directive)
- Customizable size and stroke properties
Animation
TheActiveDot component includes a built-in scale animation that triggers when the component mounts. The animation is defined via the animate-active-dot CSS class.
The component uses a ref to apply the transform style after mount:
Positioning
The component automatically calculates the proper SVG positioning based on thex, y, and size props:
- SVG is positioned at
x - radiusandy - radiusto center the dot - Circle radius accounts for stroke width:
radius - strokeWidth / 2 - ViewBox is set to match the size for proper scaling
Use Cases
- Active data point indicators in line charts
- Hover state indicators in area charts
- Interactive tooltips on scatter plots
- Current value markers in time series visualizations
Styling
The component accepts aclassName prop for custom styling. The SVG and circle elements can be targeted:
Related Components
For complete chart solutions, combine with:- Recharts library components (LineChart, AreaChart, etc.)
- Table components for data display
- Loader components for async data states