Custom components in Recharts 3
The
Customized wrapper is deprecatedStarting from Recharts 3.x, you can render custom components directly without the Customized wrapper. The wrapper will be removed in version 4.0.Render custom components directly
In Recharts 3.x and later, add custom elements anywhere in your chart:https://github.com/recharts/recharts/blob/main/src/component/Customized.tsx:22-28
Custom shapes
Custom dots on lines
Replace default dots with custom shapes:cx,cy: Center coordinatesr: Radiusfill,stroke: Colorsvalue: Data valuepayload: Complete data pointindex: Point index
Custom bar shapes
Create custom shapes for bars:Custom labels
Custom axis tick labels
Create custom tick components:Custom label list
Add labels to data points:Custom tooltips
See the Tooltips and legends guide for detailed tooltip customization.Custom legends
See the Tooltips and legends guide for detailed legend customization.Accessing chart context
Custom components can access chart data and layout using hooks.Access chart dimensions
Custom annotations
Threshold line
Draw a horizontal line at a specific value:Reference area
Highlight a specific range:Custom active shapes
Animated active dot
Custom active bar
SVG patterns and gradients
Gradient fills
Pattern fills
Custom chart backgrounds
Interactive custom components
Clickable annotations
Best practices
Coordinate systemsRemember that SVG coordinates start at the top-left (0, 0). Positive Y goes down, not up.
Migration from Recharts 2
If upgrading from Recharts 2.x:https://github.com/recharts/recharts/blob/main/src/component/Customized.tsx:23-27