recharts
- Version 3.11.3
- Published
- 8.95 MB
- 10 dependencies
- MIT license
Install
npm i rechartsyarn add rechartspnpm add rechartsOverview
React charts
Index
Variables
Functions
- Area()
- AreaChart()
- AreaRevealShape()
- Bar()
- BarChart()
- Brush()
- CartesianGrid()
- ComposedChart()
- createCentricChart()
- createHorizontalChart()
- createRadialChart()
- createVerticalChart()
- Curve()
- Customized()
- DefaultLegendContent()
- DefaultTooltipContent()
- Dot()
- ErrorBar()
- FunnelChart()
- getNiceTickValues()
- getRelativeCoordinate()
- interpolate()
- Label()
- LabelList()
- linearGradient()
- LineChart()
- LineDrawShape()
- matchByDataKey()
- pattern()
- PieChart()
- PolarAngleAxis()
- PolarRadiusAxis()
- Polygon()
- Radar()
- RadarChart()
- RadialBar()
- RadialBarChart()
- Rectangle()
- ReferenceArea()
- ReferenceDot()
- ReferenceLine()
- Sankey()
- ScatterChart()
- Sector()
- SunburstChart()
- Tooltip()
- Trapezoid()
- Treemap()
- useActiveTooltipCoordinate()
- useActiveTooltipDataPoints()
- useActiveTooltipLabel()
- useCartesianChartLayout()
- useCartesianScale()
- useChartHeight()
- useChartLayout()
- useChartWidth()
- useIsTooltipActive()
- useMargin()
- useOffset()
- usePlotArea()
- usePolarChartLayout()
- useRechartsTheme()
- useXAxisDomain()
- useXAxisInverseDataSnapScale()
- useXAxisInverseScale()
- useXAxisInverseTickSnapScale()
- useXAxisScale()
- useXAxisTicks()
- useYAxisDomain()
- useYAxisInverseDataSnapScale()
- useYAxisInverseScale()
- useYAxisInverseTickSnapScale()
- useYAxisScale()
- useYAxisTicks()
- XAxis()
- YAxis()
- ZAxis()
- ZIndexLayer()
Classes
Interfaces
Type Aliases
- ActiveDotProps
- ActiveDotType
- ActiveLabel
- ActiveShape
- AnimationController
- AnimationHandle
- AnimationInterpolateFn
- AnimationItem
- AnimationMatchBy
- AnimationMatchByProp
- AreaProps
- AreaRevealShapeProps
- AxisDomain
- AxisDomainItem
- AxisDomainTypeInput
- AxisId
- AxisInterval
- AxisRange
- BandPosition
- BarProps
- BarShapeProps
- BarStackProps
- BaseLineType
- BaseTickContentProps
- BaseValue
- BrushProps
- BrushTravellerType
- CancelableTimeout
- CartesianAxisProps
- CartesianDataPoint
- CartesianGridProps
- CartesianLayout
- CartesianPosition
- ChartOffset
- CrossProps
- CursorDefinition
- CurveProps
- CurveType
- CustomizedProps
- DataKey
- DefaultLegendContentProps
- DotItemDotProps
- DotProps
- DotType
- EasingInput
- ErrorBarDirection
- ErrorBarProps
- FunnelProps
- FunnelTrapezoidItem
- GridLineType
- GridLineTypeFunctionProps
- HorizontalAlignmentType
- IfOverflow
- ImplicitLabelListType
- ImplicitLabelType
- InternalRadarProps
- InverseScaleFunction
- LabelContentType
- LabelListProps
- LabelListPropsWithPosition
- LabelPosition
- LabelProps
- LayerProps
- LayoutType
- LegendContentType
- LegendProps
- LegendType
- LineDrawShapeProps
- LineProps
- MinPointSize
- MouseHandlerDataParam
- MousePointer
- NiceTicksAlgorithm
- NoCentric
- NoFunnel
- NoRadial
- NumberDomain
- OnAnimationStateUpdate
- Orientation
- PieLabel
- PieLabelLine
- PieLabelRenderProps
- PieProps
- PieSectorDataItem
- PieSectorShapeProps
- PieShape
- PlotArea
- PolarAngleAxisProps
- PolarCoordinate
- PolarGridProps
- PolarLayout
- PolarRadiusAxisProps
- PolygonProps
- RadarProps
- RadialBarDataItem
- RadialBarProps
- RechartsFill
- RechartsFillDefinitionProps
- RechartsGradientStop
- RechartsLinearGradient
- RechartsPattern
- RectangleProps
- RectRadius
- ReferenceAreaProps
- ReferenceDotProps
- ReferenceLineProps
- ReferenceLineSegment
- RenderableText
- SankeyElementType
- SankeyLinkOptions
- SankeyNodeOptions
- SankeyProps
- SankeyVerticalAlign
- ScaleFunction
- ScatterCustomizedShape
- ScatterProps
- ScatterShapeProps
- SectorProps
- SizeType
- StackId
- StackOffsetType
- SurfaceProps
- SymbolsProps
- SymbolType
- SyncMethod
- TextAnchor
- TextBackgroundProps
- TextProps
- TextVerticalAnchor
- TickOrientation
- TickProp
- TooltipContentProps
- TooltipContentType
- TooltipIndex
- TooltipItemSorter
- TooltipPayload
- TooltipProps
- TooltipTrigger
- TooltipValueType
- TouchPointer
- TrapezoidProps
- TreemapContentType
- TypedCentricChartContext
- TypedHorizontalChartContext
- TypedRadialChartContext
- TypedVerticalChartContext
- UniqueOption
- Unit
- VerticalAlignmentType
- ViewBox
- WithFillObject
- XAxisOrientation
- XAxisPadding
- XAxisProps
- XAxisTickContentProps
- YAxisOrientation
- YAxisPadding
- YAxisProps
- YAxisTickContentProps
- YAxisWidth
Namespaces
Variables
variable AnimationControllerProvider
const AnimationControllerProvider: any;Allows overriding the default AnimationController that Recharts uses internally to drive animations. The default one uses requestAnimationFrame-based TimeoutController, and ticks through the animations as time moves forward.
Why would you want to use this? Several reasons: - Unit tests are an excellent use (Recharts itself has ton of tests with mock TimeoutController) - If you want to animate charts back and forth (Recharts only animates forward) - If you want to replace requestAnimationFrame with something else - Perhaps a manual animation controls (https://recharts.github.io does this) - If you want to maybe animate charts based on mouse movement, or page scroll position, instead of time
If you don't use this provider then all charts use the default requestAnimationFrame and default animation logic.
If you use this component then all charts inside use your custom animationController.
See Also
3.9
Modifiers
@public
variable autoPalette
const autoPalette: readonly string[];Categorical series colors that follow the CSS
color-schemeof the page.Each entry pairs the same entry of lightPalette and darkPalette in a CSS
light-dark()value, so the browser picks the light or the dark color. See autoTheme for how to set thecolor-scheme.Use it to give explicit colors to graphical items that would otherwise share one theme color, for example
<Scatter fill={autoPalette[1]} />.light-dark()needs Chrome 123, Firefox 120, or Safari 17.5. Older browsers ignore these values, see autoTheme.See Also
3.11
Modifiers
@public
variable autoTheme
const autoTheme: RechartsTheme;Theme that follows the CSS
color-schemeof the page.It has the colors of lightTheme and darkTheme: every color that differs between the two is a CSS
light-dark()value, such aslight-dark(#2373e6, #5396ff). The browser picks the light or dark color from thecolor-schemeof the element it is applied to. Switching between light and dark needs no React state and no re-render, and server-rendered pages show the right colors from the first paint.- To follow the operating system, set
:root { color-scheme: light dark; }. - To follow your own toggle, setcolor-scheme: lightorcolor-scheme: darkon<html>or on any wrapper. If your toggle only sets a class, add one CSS rule, for example.dark { color-scheme: dark; }. - Without anycolor-scheme, browsers use the light colors.Like the other built-in themes, it does not paint the page background. Pair it with a page whose background follows the same
color-scheme.Exported SVG and PNG images keep the colors of the color scheme that was active when they were taken.
light-dark()needs Chrome 123, Firefox 120, or Safari 17.5. Older browsers do not understand the value and ignore it: shapes fall back to the SVG defaults, which are a black fill and no stroke, and Tooltip and Legend lose their theme colors. If you support older browsers, use lightTheme and darkTheme instead, or a theme with CSSvar()values.See Also
3.11
Modifiers
@public
variable BarStack
const BarStack: ComponentType<BarStackProps>;BarStackContext 3.6
Modifiers
@public
variable CartesianAxis
const CartesianAxis: React.ForwardRefExoticComponent<any>;Modifiers
@public
Deprecated
This component is not meant to be used directly in app code. Use XAxis or YAxis instead.
Starting from Recharts v4.0 we will make this component internal only.
variable Cell
const Cell: FunctionComponent<Props>;Cell component used to define colors and styles of chart elements.
This component is now deprecated and will be removed in Recharts 4.0.
Please use the
shapeprop orcontentprop on the respective chart components to customize the rendering of chart elements instead of usingCell.See Also
Modifiers
@public
Deprecated
CellReader
variable Cross
const Cross: React.FC<any>;Renders a crosshair as an SVG path with one horizontal and one vertical line. It is used as the default tooltip cursor in ScatterChart.
All coordinates and dimensions are in pixels, rather than chart data values. The vertical line runs from
(x, top)to(x, top + height), and the horizontal line runs from(left, y)to(left + width, y). Settop,left,width, andheightto define the extent of the lines;xandyposition their intersection.Use SVG presentation attributes such as
stroke,strokeWidth, andstrokeDasharrayto style the lines. Setstroketo make the path visible;filldoes not color the lines.Modifiers
@public
variable darkPalette
const darkPalette: readonly string[];Categorical series colors for a #18181b background.
Order matters. Graphical items take colors from the front of this list (by sorted dataKey), so a chart with N series always gets the first N entries. The order is tuned so that every prefix stays distinguishable in typical vision and under protanopia, deuteranopia and tritanopia, with the widest separation in the first 4-8 entries where most charts live.
Entries 1-8 share one band of lightness and chroma, so no series looks heavier or more important than another. Entries 9-12 step outside that band on purpose, because twelve hues at one lightness cannot all stay apart under color vision deficiency.
Every entry has at least 4.5:1 contrast against the background as a stroke, the WCAG contrast for text, so a label in the series color stays readable. Painted as an opaque fill (
fillOpacity1), every entry keeps the same contrast (WCAG 1.4.11).Entry N is the same hue family in the light and dark palettes, so a series keeps its identity when the theme changes. Comments show stroke contrast.
See Also
3.11
Modifiers
@public
variable darkTheme
const darkTheme: RechartsTheme;Dark mode theme
See Also
3.11
Modifiers
@public
variable DefaultZIndexes
const DefaultZIndexes: { readonly grid: -100; readonly barBackground: -50; readonly area: 100; readonly cursorRectangle: 200; readonly bar: 300; readonly line: 400; readonly axis: 500; readonly scatter: 600; readonly activeBar: 1000; readonly cursorLine: 1100; readonly activeDot: 1200; readonly labelBackground: 1900; readonly label: 2000;};A collection of all default zIndex values used by Recharts.
You can reuse these, or you can define your own.
Modifiers
@public
variable emptyTheme
const emptyTheme: RechartsTheme;Theme that has no presets, and leaves everything to browser defaults. This does not create beautiful charts! But it's useful if you want to start from scratch.
Same idea as
clear.cssand others.See Also
3.11
Modifiers
@public
variable Funnel
const Funnel: { <DataPointType = any, DataValueType = any>( outsideProps: Props<DataPointType, DataValueType> ): ReactElement; (outsideProps: Props<any, any>): ReactElement;};Modifiers
@public
variable Global
const Global: { devToolsEnabled: boolean; isSsr: boolean };Modifiers
@public
variable gradients
const gradients: { readonly fadeDown: { readonly x1: 0; readonly y1: 0; readonly x2: 0; readonly y2: 1; readonly stops: readonly [ { readonly offset: 0; readonly opacity: 1 }, { readonly offset: 1; readonly opacity: 0.2 } ]; }; readonly fadeUp: { readonly x1: 0; readonly y1: 1; readonly x2: 0; readonly y2: 0; readonly stops: readonly [ { readonly offset: 0; readonly opacity: 1 }, { readonly offset: 1; readonly opacity: 0.2 } ]; }; readonly fadeRight: { readonly x1: 0; readonly y1: 0; readonly x2: 1; readonly y2: 0; readonly stops: readonly [ { readonly offset: 0; readonly opacity: 1 }, { readonly offset: 1; readonly opacity: 0.2 } ]; }; readonly fadeLeft: { readonly x1: 1; readonly y1: 0; readonly x2: 0; readonly y2: 0; readonly stops: readonly [ { readonly offset: 0; readonly opacity: 1 }, { readonly offset: 1; readonly opacity: 0.2 } ]; };};Built-in linear gradients. Each of them fades the base color of the fill, so they work with any color. Each of them is a plain RechartsLinearGradient value. Use them with linearGradient:
fill={{ definition: linearGradient(gradients.fadeDown) }}.3.11
Modifiers
@public
variable Layer
const Layer: React.ForwardRefExoticComponent<any>;Creates an SVG group element to group other SVG elements.
Useful if you want to apply transformations or styles to a set of elements without affecting other elements in the SVG.
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/g
Modifiers
@public
variable Legend
const Legend: React.MemoExoticComponent<(outsideProps: Props) => any>;Modifiers
@public
variable lightPalette
const lightPalette: readonly string[];Categorical series colors for a #fff background.
Order matters. Graphical items take colors from the front of this list (by sorted dataKey), so a chart with N series always gets the first N entries. The order is tuned so that every prefix stays distinguishable in typical vision and under protanopia, deuteranopia and tritanopia, with the widest separation in the first 4-8 entries where most charts live.
Entries 1-8 share one band of lightness and chroma, so no series looks heavier or more important than another. Entries 9-12 step outside that band where they can, because twelve hues at one lightness cannot all stay apart under color vision deficiency: Purple is darker and Teal is less saturated. At 4.5:1 the band already sits close to the lightest a color can be, so they cannot step outside it upward.
Every entry has at least 4.5:1 contrast against the background as a stroke, the WCAG contrast for text, so a label in the series color stays readable. Painted as an opaque fill (
fillOpacity1), every entry keeps the same contrast (WCAG 1.4.11).Entry N is the same hue family in the light and dark palettes, so a series keeps its identity when the theme changes. Comments show stroke contrast.
See Also
3.11
Modifiers
@public
variable lightTheme
const lightTheme: RechartsTheme;Light mode theme
See Also
3.11
Modifiers
@public
variable Line
const Line: { <DataPointType = any, ValueAxisType = any>( props: Props<DataPointType, ValueAxisType> ): ReactElement; (props: Props<any, any>): ReactElement;};LabelListContext ErrorBarContext CartesianChartContext
Modifiers
@public
variable matchAppend
const matchAppend: string;Match animation items sequentially: previous item 0 pairs with next item 0, previous item 1 pairs with next item 1, and so on. When the new array is longer, the extra items have no match and animate in from their default position. When the new array is shorter, the ancient items are simply dropped.
This is useful when new data is appended at the end of the array, and you want existing points to stay in place while new points animate in.
Example 1
import { matchAppend } from 'recharts'; <Line animationMatchBy={matchAppend} />
3.9
See Also
Modifiers
@public
variable matchByIndex
const matchByIndex: string;Match animation items by their array index (the default behavior).
Previous items are paired with next items based on their position in the array, with proportional stretching when array lengths differ. When going from 5 to 15 items, each old point "covers" approximately 3 new points; when shrinking, some old points are skipped.
Example 1
import { matchByIndex } from 'recharts'; <Line animationMatchBy={matchByIndex} />
3.9
See Also
Modifiers
@public
variable patterns
const patterns: { readonly diagonal: { readonly width: 8; readonly height: 8; readonly rotation: 45; readonly path: 'M0 4H8'; readonly strokeWidth: 3; }; readonly crosshatch: { readonly width: 8; readonly height: 8; readonly rotation: 45; readonly path: readonly ['M0 4H8', 'M4 0V8']; readonly strokeWidth: 1.5; }; readonly horizontal: { readonly width: 8; readonly height: 8; readonly path: 'M0 4H8'; readonly strokeWidth: 3; }; readonly vertical: { readonly width: 8; readonly height: 8; readonly path: 'M4 0V8'; readonly strokeWidth: 3; }; readonly grid: { readonly width: 8; readonly height: 8; readonly path: readonly ['M0 4H8', 'M4 0V8']; readonly strokeWidth: 1.5; }; readonly dots: RechartsPattern; readonly zigzag: { readonly width: 8; readonly height: 8; readonly path: 'M0 5L2 3L4 5L6 3L8 5'; readonly strokeWidth: 1.5; }; readonly circle: RechartsPattern; readonly cross: RechartsPattern; readonly diamond: RechartsPattern; readonly square: RechartsPattern; readonly star: RechartsPattern; readonly triangle: RechartsPattern; readonly wye: RechartsPattern;};Built-in patterns. Each of them is a plain RechartsPattern value. Use them with pattern:
fill={{ definition: pattern(patterns.diagonal) }}.circle,cross,diamond,square,star,triangle, andwyedraw the same shapes as Symbols, in staggered rows.dotsis the same pattern ascircle.3.11
Modifiers
@public
variable Pie
const Pie: { <DataPointType = any, DataValueType = any>( outsideProps: Props<DataPointType, DataValueType> ): ReactElement; (outsideProps: Props<any, any>): ReactElement;};Modifiers
@public
variable PolarGrid
const PolarGrid: { (propsWithFillObject: Props): React.JSX.Element | null; displayName: string;};PolarViewBoxContext
Modifiers
@public
variable RechartsThemeProvider
const RechartsThemeProvider: any;Applies the provided theme to all charts in the children tree.
See Also
3.11
Modifiers
@public
variable ResponsiveContainer
const ResponsiveContainer: React.ForwardRefExoticComponent<any>;The
ResponsiveContainercomponent is a container that adjusts its width and height based on the size of its parent element. It is used to create responsive charts that adapt to different screen sizes.This component uses the API to monitor changes to the size of its parent element. If you need to support older browsers that do not support this API, you may need to include a polyfill.
The parent element must have a size of its own: the container measures itself and passes that size to the chart, so a parent whose height comes from its content leaves the chart with nothing to measure.
See Also
ResponsiveContainerContext
Modifiers
@public
variable Scatter
const Scatter: { <DataPointType = any, ValueAxisType = any>( props: Props<DataPointType, ValueAxisType> ): ReactElement; (props: Props<any, any>): ReactElement;};LabelListContext ErrorBarContext CellReader CartesianChartContext
Modifiers
@public
variable Surface
const Surface: React.ForwardRefExoticComponent<any>;Renders an SVG element.
All charts already include a Surface component, so you would not normally use this directly.
https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg
Modifiers
@public
variable Symbols
const Symbols: { (props: SymbolsProps): React.JSX.Element; registerSymbol: (key: string, factory: D3SymbolType) => void;};Renders a symbol from a set of predefined shapes.
Modifiers
@public
variable Text
const Text: React.ForwardRefExoticComponent<any>;Modifiers
@public
Functions
function Area
Area: <DataPointType = any, ValueAxisType = any>( props: Props<DataPointType, ValueAxisType>) => ReactElement;LabelListContext CartesianChartContext
Modifiers
@public
function AreaChart
AreaChart: <DataPointType = any>( props: CartesianChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext CartesianViewBoxContext CartesianChartContext
Modifiers
@public
function AreaRevealShape
AreaRevealShape: (props: AreaRevealShapeProps) => React.ReactElement | null;The default shape for Area that reveals the chart with a left-to-right (or top-to-bottom) clip-path animation on entrance, and renders the plain curve otherwise.
This component renders the complete Area visual: the filled area curve, the stroke curve, and (for range areas) the baseline stroke curve. During entrance animation, all curves are wrapped in a clip-path that progressively reveals the area.
This is the built-in entrance animation for Area. It is automatically used when no custom
shapeprop is provided. You can import and reuse it as a starting point for custom shapes.Example 1
import { Area, AreaRevealShape } from 'recharts';// Use the default shape explicitly (same as providing no shape prop)<Area dataKey="value" shape={AreaRevealShape} />See Also
3.9
Modifiers
@public
function Bar
Bar: <DataPointType = any, ValueAxisType = any>( props: Props<DataPointType, ValueAxisType>) => ReactElement;ErrorBarContext LabelListContext CellReader CartesianChartContext BarStackContext
Modifiers
@public
function BarChart
BarChart: <DataPointType = any>( props: CartesianChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext CartesianViewBoxContext CartesianChartContext
Modifiers
@public
function Brush
Brush: typeof Brush;Renders a scrollbar that allows the user to zoom and pan in the chart along its XAxis. It also allows you to render a small overview of the chart inside the brush that is always visible and shows the full data set so that the user can see where they are zoomed in.
If a chart is synchronized with other charts using the
syncIdprop on the chart, the brush will also synchronize the zooming and panning between all synchronized charts.See Also
CartesianChartContext
Modifiers
@public
function CartesianGrid
CartesianGrid: typeof CartesianGrid;Renders background grid with lines and fill colors in a Cartesian chart.
CartesianChartContext
Modifiers
@public
function ComposedChart
ComposedChart: <DataPointType = any>( props: CartesianChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext CartesianViewBoxContext CartesianChartContext
Modifiers
@public
function createCentricChart
createCentricChart: <TData, TCategorical = string, TNumerical = number>() => < TComponents extends Record<string, any>>( components: NoRadial<TComponents>) => TypedCentricChartContext<TData, TCategorical, TNumerical, TComponents>;Creates a typed context for centric Polar charts.
**Motivation:** Recharts components fall back to
anyby default. While explicit typing using Generics works per-component, it becomes tedious and error-prone across an entire chart.This Chart Helper allows you to perfectly align your data properties and ensure all your charts and axes work in harmony. Once you define the helper with your generic requirements, all returned components strictly enforce your data structure, catching
dataKeytypos and shape errors early.**Layout Binding:** Curries chart definitions to strictly bind
layout="centric"prop behavior statically onto components. By wrapping the chart implementations, it completely masks thelayoutprop on initialization to prevent regressions. EvaluatesTComponentsgenerics at compile-time to reject radial-only elements natively (RadialBar,Pie, etc.)Example 1
// 1. Lock in the Generics: Data = MyDataconst TypedCentric = createCentricChart<MyData, string, number>()({RadarChart,Radar,});// 2. `layout` is permanently bound to "centric".// 3. Passing `Pie` or `RadialBar` into the components map will explicitly trigger a TS error.3.8
See Also
Modifiers
@public
function createHorizontalChart
createHorizontalChart: <TData, TCategorical = string, TNumerical = number>() => < TComponents extends Record<string, any>>( components: NoFunnel<TComponents>) => TypedHorizontalChartContext<TData, TCategorical, TNumerical, TComponents>;Creates a typed context for horizontal Cartesian charts.
**Motivation:** Recharts components fall back to
anyby default. While explicit typing using Generics (e.g.<Area<MyDataType, number>>) works per-component, it becomes tedious and error-prone across an entire chart.This Chart Helper allows you to perfectly align your data properties and ensure all your charts, axes, and lines work in harmony. Once you define the helper with your generic requirements, all returned components strictly enforce your data structure, catching
dataKeytypos and shape errors early.**Layout Binding:** Curries the chart definition to statically bind the
layout="horizontal"property at the component level. By strippinglayoutfrom the configuration options of generated wrapper components, developers avoid accidentally overriding chart alignments. EvaluatesTComponentsgenerics at compile-time to reject strictly vertical components natively (Funnel,FunnelChart) from being passed.Example 1
// 1. Lock in the Generics: Data = MyData, X-Axis = string, Y-Axis = numberconst TypedCharts = createHorizontalChart<MyData, string, number>()({AreaChart,Area,XAxis,YAxis,});// 2. TypedCharts.AreaChart is now strictly horizontal.// 3. TypedCharts.Area strictly expects string/number keys matching MyData.3.8
See Also
Modifiers
@public
function createRadialChart
createRadialChart: <TData, TCategorical = string, TNumerical = number>() => < TComponents extends Record<string, any>>( components: NoCentric<TComponents>) => TypedRadialChartContext<TData, TCategorical, TNumerical, TComponents>;Creates a typed context for radial Polar charts.
**Motivation:** Recharts components fall back to
anyby default. While explicit typing using Generics works per-component, it becomes tedious and error-prone across an entire chart.This Chart Helper allows you to perfectly align your data properties and ensure all your charts and layers work in harmony. Once you define the helper with your generic requirements, all returned components strictly enforce your data structure, catching
dataKeytypos and shape errors early.**Layout Binding:** Curries chart definitions to strictly bind
layout="radial"prop behavior statically onto components. By wrapping the chart implementations, it completely masks thelayoutprop on initialization to prevent runtime faults. EvaluatesTComponentsgenerics at compile-time to reject centric-only elements natively (Radar,RadarChart, etc.)Example 1
// 1. Lock in the Generics: Data = MyDataconst TypedRadial = createRadialChart<MyData, string, number>()({RadialBarChart,RadialBar,});// 2. `layout` is permanently bound to "radial".// 3. Passing `Radar` or `RadarChart` into the components map will explicitly trigger a TS error.3.8
See Also
Modifiers
@public
function createVerticalChart
createVerticalChart: <TData, TCategorical = string, TNumerical = number>() => < TComponents extends Record<string, any>>( components: TComponents) => TypedVerticalChartContext<TData, TCategorical, TNumerical, TComponents>;Creates a typed context for vertical Cartesian charts.
**Motivation:** Recharts components fall back to
anyby default. While explicit typing using Generics (e.g.<Area<MyDataType, number>>) works per-component, it becomes tedious and error-prone across an entire chart.This Chart Helper allows you to perfectly align your data properties and ensure all your charts, axes, and lines work in harmony. Once you define the helper with your generic requirements, all returned components strictly enforce your data structure, catching
dataKeytypos and shape errors early.**Layout Binding:** Curries the chart definition to statically bind the
layout="vertical"property at the component level. By strippinglayoutfrom the configuration options of generated wrapper components, developers avoid accidentally overriding chart alignments. Natively supports strictly vertical components likeFunnelandFunnelChart.Example 1
// 1. Lock in the Generics: Data = MyData, X-Axis = number, Y-Axis = stringconst TypedCharts = createVerticalChart<MyData, number, string>()({BarChart,Bar,Funnel,XAxis,YAxis,});// 2. TypedCharts.BarChart is now strictly vertical.// 3. `Funnel` evaluates safely inside vertical contexts exclusively and enforces MyData limits.3.8
See Also
Modifiers
@public
function Curve
Curve: (props: Props) => React.JSX.Element;Modifiers
@public
function Customized
Customized: typeof Customized;Customized component used to be necessary to render custom elements in Recharts 2.x. Starting from Recharts 3.x, all charts are able to render arbitrary elements anywhere, and Customized is no longer needed.
Example 1
Before:
<Customized component={<MyCustomComponent />} />Example 2
After:
<MyCustomComponent />Modifiers
@public
Deprecated
Just render your components directly. Will be removed in 4.0
function DefaultLegendContent
DefaultLegendContent: (outsideProps: Props) => React.JSX.Element | null;This component is by default rendered inside the Legend component. You would not use it directly.
You can use this component to customize the content of the legend, or you can provide your own completely independent content.
Modifiers
@public
function DefaultTooltipContent
DefaultTooltipContent: (props: Props) => React.JSX.Element;This component is by default rendered inside the Tooltip component. You would not use it directly.
You can use this component to customize the content of the tooltip, or you can provide your own completely independent content.
Modifiers
@public
function Dot
Dot: (props: Props) => React.JSX.Element;Renders a dot in the chart.
This component accepts X and Y coordinates in pixels. If you need to position the rectangle based on your chart's data, consider using the ReferenceDot component instead.
Parameter props
Modifiers
@public
function ErrorBar
ErrorBar: typeof ErrorBar;ErrorBar renders whiskers to represent error margins on a chart.
It must be a child of a graphical element.
ErrorBar expects data in one of the following forms: - Symmetric error bars: a single error value representing both lower and upper bounds. - Asymmetric error bars: an array of two values representing lower and upper bounds separately. First value is the lower bound, second value is the upper bound.
The values provided are relative to the main data value. For example, if the main data value is 10 and the error value is 2, the error bar will extend from 8 to 12 for symmetric error bars.
In other words, what ErrorBar will render is: - For symmetric error bars: [value - errorVal, value + errorVal] - For asymmetric error bars: [value - errorVal[0], value + errorVal[1]]
In stacked or ranged Bar charts, ErrorBar will use the higher data value as the reference point for calculating the error bar positions.
ErrorBarContext
Modifiers
@public
function FunnelChart
FunnelChart: <DataPointType = any>( props: CartesianChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext CartesianViewBoxContext CartesianChartContext
Modifiers
@public
function getNiceTickValues
getNiceTickValues: ( [min, max]: NumberDomain, tickCount?: number, allowDecimals?: boolean, niceTicksMode?: NiceTicksAlgorithm) => number[];Calculate the ticks of an interval. Ticks can appear outside the interval if it makes them more rounded and nice.
Parameter tuple
of [min,max] min: The minimum value, max: The maximum value
Parameter tickCount
The count of ticks. An interval with 0 strictly inside it always returns at least 3 ticks because 0 itself is always one of them.
Parameter allowDecimals
Allow the ticks to be decimals or not
Parameter niceTicksMode
The algorithm to use for calculating nice ticks. array of ticks
Modifiers
@public
function getRelativeCoordinate
getRelativeCoordinate: { (event: MousePointer): RelativePointer; (event: TouchPointer): RelativePointer[];};Computes relative element coordinates from mouse or touch event.
The output coordinates are relative to the top-left corner of the active element (= currentTarget), where the top-left corner is (0, 0). Moving right, the x-coordinate increases, and moving down, the y-coordinate increases.
The coordinates are rounded to the nearest integer and account for CSS transform scale. So element that's scaled will return the same coordinates as element that's not scaled.
In other words: you zoom in or out, numbers stay the same.
This function works with both HTML elements and SVG elements.
It works with both Mouse and Touch events. For Touch events, it returns an array of coordinates, one for each touch point. For Mouse events, it returns a single coordinate object.
Parameter event
The mouse or touch event from React event handlers (works with both HTML and SVG elements)
Returns
Coordinates relative to the top-left corner of the element. Single object for Mouse events, array of objects for Touch events.
Example 1
// In an HTML element event handler. Legend passes the native event as the 3rd argument.<Legend onMouseMove={(_data, _i, e) => {// These coordinates are relative to the top-left corner of the Legend elementconst { relativeX, relativeY } = getRelativeCoordinate(e);console.log(`Mouse at Legend position: (${relativeX}, ${relativeY})`);}}>Example 2
// In an SVG element event handler. Area is an SVG element, and passes the event as second argument.<Area onMouseMove={(_, e) => {const { relativeX, relativeY } = getRelativeCoordinate(e);console.log(`Mouse at Area position: (${relativeX}, ${relativeY})`);// Here you can call usePlotArea to convert to chart coordinates}}>Example 3
// In a chart root touch handler. Chart root passes the event as second argument.<LineChart onTouchMove={(_, e) => {const touchPoints = getRelativeCoordinate(e);touchPoints.forEach(({ relativeX, relativeY }, index) => {console.log(`Touch point ${index} at LineChart position: (${relativeX}, ${relativeY})`);});}}>3.8
Modifiers
@public
function interpolate
interpolate: { ( start: number | null | undefined, end: number, animationElapsedTime: number ): number; (start: number, end: null, animationElapsedTime: number): null; (start: number, end: undefined, animationElapsedTime: number): undefined; (start: number, end: number, animationElapsedTime: number): number; (start: number, end: number, animationElapsedTime: number): number; (start: number, end: number, animationElapsedTime: number): number;};Function to interpolate between two numbers. If both start and end are numbers, it calculates the interpolated value based on the parameter animationElapsedTime (0 to 1). If either start or end is not a number, it returns the end value directly.
You will typically use this function when implementing custom animations.
animationElapsedTimecan be outside the (0, 1) range, depending on easing.This one interpolates only numbers; if you want to interpolate colors or strings then perhaps see .
Parameter start
the starting value (when animationElapsedTime=0)
Parameter end
the final value (when animationElapsedTime=1)
Parameter animationElapsedTime
interpolation factor; values in [0, 1] interpolate between start and end, and values outside that range extrapolate
3.9
Modifiers
@public
function Label
Label: typeof Label;CartesianViewBoxContext PolarViewBoxContext CartesianLabelContext PolarLabelContext
Modifiers
@public
function LabelList
LabelList: typeof LabelList;LabelListContext
Modifiers
@public
function linearGradient
linearGradient: ( gradient: RechartsLinearGradient) => ComponentType<RechartsFillDefinitionProps>;Turns a RechartsLinearGradient into a fill definition. Stops without a color use the base color.
Call it outside of components, so that the definition stays the same between renders.
Parameter gradient
the gradient to draw
Returns
a component to use as the
definitionof a RechartsFill 3.11Example 1
const fade = linearGradient(gradients.fadeDown); <Bar dataKey="uv" fill={{ definition: fade }} />
Modifiers
@public
function LineChart
LineChart: <DataPointType = any>( props: CartesianChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext CartesianViewBoxContext CartesianChartContext
Modifiers
@public
function LineDrawShape
LineDrawShape: (props: LineDrawShapeProps) => React.ReactElement | null;The default shape for Line. During the entrance animation, the line is progressively revealed using the
strokeDasharraySVG attribute: the visible portion grows from 0 to the full path length asanimationElapsedTimeprogresses from 0 to 1.This is the built-in shape for Line. It is automatically used when no custom
shapeprop is provided. You can import and reuse it as a starting point for custom shapes, or use it as a reference for building your own.The animation progress props (
animationElapsedTime,isAnimating,isEntrance) are available for custom shapes that want to add their own effects on top.Example 1
import { Line, LineDrawShape } from 'recharts';// Use the default shape explicitly (same as providing no shape prop)<Line dataKey="value" shape={LineDrawShape} />See Also
3.9
Modifiers
@public
function matchByDataKey
matchByDataKey: ( dataKey: DataKey<Record<string, unknown>>) => AnimationMatchBy<{ payload?: unknown }>;Create a matching function that pairs items by a data key from their payload.
Useful for time-series or streaming charts where new data points are added to one end and old points are removed from the other. This ensures existing points animate smoothly to their new positions instead of shifting by index.
Parameter dataKey
The key to look up in each item's payload (e.g., 'timestamp', 'date', 'id')
Returns
An AnimationMatchBy function that can be passed to the animationMatchBy prop
Example 1
import { matchByDataKey } from 'recharts'; <Line animationMatchBy={matchByDataKey('timestamp')} /> <Bar animationMatchBy={matchByDataKey('name')} /> <Pie animationMatchBy={matchByDataKey('id')} />
3.9
See Also
Modifiers
@public
function pattern
pattern: (value: RechartsPattern) => ComponentType<RechartsFillDefinitionProps>;Turns a RechartsPattern into a fill definition: a repeating texture over the base color. The texture defaults to the
pageBackgroundcolor from the theme, or white when no theme is set.Call it outside of components, so that the definition stays the same between renders.
Parameter value
the pattern to draw
Returns
a component to use as the
definitionof a RechartsFill 3.11Example 1
const stripes = pattern(patterns.diagonal); <Bar dataKey="uv" fill={{ definition: stripes }} />
Modifiers
@public
function PieChart
PieChart: <DataPointType = any>( props: PolarChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext PolarViewBoxContext PolarChartContext
Modifiers
@public
function PolarAngleAxis
PolarAngleAxis: typeof PolarAngleAxis;PolarLabelContext PolarViewBoxContext
Modifiers
@public
function PolarRadiusAxis
PolarRadiusAxis: typeof PolarRadiusAxis;PolarLabelContext PolarViewBoxContext
Modifiers
@public
function Polygon
Polygon: (props: Props) => React.JSX.Element;Renders a polygon shape from an array of x/y coordinates, closing the outline into a filled shape by default. If the given points contain a gap (an invalid or missing coordinate) and
connectNullsis not set, the outline is split into separate, unclosed subpaths around that gap instead of forming a single closed shape. Used internally by polar components such as Radar and PolarGrid to draw chart shapes. Accepts standard SVG presentation attributes (e.g.stroke,fill,strokeWidth) for styling, since it wraps a native SVG path element.Modifiers
@public
function Radar
Radar: typeof Radar;PolarChartContext LabelListContext
Modifiers
@public
function RadarChart
RadarChart: <DataPointType = any>( props: PolarChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext PolarViewBoxContext PolarChartContext
Modifiers
@public
function RadialBar
RadialBar: typeof RadialBar;PolarChartContext LabelListContext CellReader
Modifiers
@public
function RadialBarChart
RadialBarChart: <DataPointType = any>( props: PolarChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext PolarViewBoxContext PolarChartContext
Modifiers
@public
function Rectangle
Rectangle: (props: Props) => React.JSX.Element;Renders a rectangle element. Unlike the , this component supports rounded corners and animation.
This component accepts X and Y coordinates in pixels. If you need to position the rectangle based on your chart's data, consider using the ReferenceArea component instead.
Parameter rectangleProps
Modifiers
@public
function ReferenceArea
ReferenceArea: typeof ReferenceArea;Draws a rectangular area on the chart to highlight a specific range.
This component, unlike Rectangle or , is aware of the cartesian coordinate system, so you specify the area by using data coordinates instead of pixels.
ReferenceArea will calculate the pixels based on the provided data coordinates.
If you prefer to render rectangles using pixels rather than data coordinates, consider using the Rectangle component instead.
CartesianLabelContext CartesianChartContext
Modifiers
@public
function ReferenceDot
ReferenceDot: typeof ReferenceDot;Draws a circle on the chart to highlight a specific point.
This component, unlike Dot or , is aware of the cartesian coordinate system, so you specify its center by using data coordinates instead of pixels.
ReferenceDot will calculate the pixels based on the provided data coordinates.
If you prefer to render dots using pixels rather than data coordinates, consider using the Dot component instead.
CartesianLabelContext CartesianChartContext
Modifiers
@public
function ReferenceLine
ReferenceLine: typeof ReferenceLine;Draws a line on the chart connecting two points.
This component, unlike , is aware of the cartesian coordinate system, so you specify the dimensions by using data coordinates instead of pixels.
ReferenceLine will calculate the pixels based on the provided data coordinates.
If you prefer to render using pixels rather than data coordinates, consider using the instead.
CartesianLabelContext CartesianChartContext
Modifiers
@public
function Sankey
Sankey: typeof Sankey;Flow diagram in which the width of the arrows is proportional to the flow rate. It is typically used to visualize energy or material or cost transfers between processes.
ResponsiveContainerContext TooltipEntrySettings
Modifiers
@public
function ScatterChart
ScatterChart: <DataPointType = any>( props: CartesianChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;ResponsiveContainerContext CartesianViewBoxContext CartesianChartContext
Modifiers
@public
function Sector
Sector: (props: Props) => React.JSX.Element;Renders a sector (pie-slice or donut-segment shape) from center coordinates, inner/outer radius, and start/end angles. Used by polar components such as Pie, RadialBar, and PolarGrid, and as the radial cursor shape shown by Tooltip on polar charts.
Modifiers
@public
function SunburstChart
SunburstChart: (outsideProps: SunburstChartProps) => React.JSX.Element;The sunburst is a hierarchical chart, similar to a Treemap, plotted in polar coordinates. Sunburst charts effectively convey the hierarchical relationships and proportions within each level. It is easy to see all the middle layers in the hierarchy, which might get lost in other visualizations. For some datasets, the radial layout may be more visually appealing and intuitive than a traditional Treemap.
ResponsiveContainerContext TooltipEntrySettings
Modifiers
@public
function Tooltip
Tooltip: ( outsideProps: TooltipProps<ValueType, NameType>) => React.JSX.Element | null;The Tooltip component displays a floating box with data values when hovering over or clicking on chart elements.
It can be configured to show information for individual data points or for all points at a specific axis coordinate. The appearance and content of the tooltip can be customized via props.
See Also
CartesianChartContext PolarChartContext TooltipEntrySettings
Modifiers
@public
function Trapezoid
Trapezoid: (props: Props) => React.JSX.Element;Modifiers
@public
function Treemap
Treemap: (outsideProps: Props) => React.JSX.Element;The Treemap chart is used to visualize hierarchical data using nested rectangles.
ResponsiveContainerContext RechartsThemeContext TooltipEntrySettings
Modifiers
@public
function useActiveTooltipCoordinate
useActiveTooltipCoordinate: () => Coordinate | undefined;Returns the Cartesian
x+ycoordinates of the active Tooltip.Returns undefined if there is no active user interaction or if used outside a chart context.
Recharts only allows one Tooltip per chart, so this hook does not take any parameters. Weird things may happen if you have multiple Tooltip components in the same chart so please don't do that.
Returns
{Coordinate | undefined} The coordinate of the active Tooltip, or undefined. 3.7
Modifiers
@public
function useActiveTooltipDataPoints
useActiveTooltipDataPoints: <T = unknown>() => readonly T[];Returns the currently active data points being displayed in the Tooltip. Active means that it is currently visible; this hook will return
undefinedif there is no current interaction.This follows the
<Tooltip />props, if the Tooltip element is present in the chart. If there is no<Tooltip />then this hook will follow the default Tooltip props.Data point is whatever you pass as an input to the chart using the
data={}prop.This returns an array because a chart can have multiple graphical items in it (multiple Lines for example) and tooltip with
shared={true}will display all items at the same time.Returns undefined when used outside a chart context.
Returns
Data points that are currently visible in a Tooltip
3.1
Modifiers
@public
function useActiveTooltipLabel
useActiveTooltipLabel: () => ActiveLabel;Returns the active tooltip label. The label is one of the values from the chart data, and is used to display in the tooltip content.
Returns undefined if there is no active user interaction or if used outside a chart context
Returns
ActiveLabel 3.0
Modifiers
@public
function useCartesianChartLayout
useCartesianChartLayout: () => CartesianLayout | undefined;Returns the chart layout only for Cartesian charts.
Returns
horizontalorverticalfor Cartesian charts. Returnsundefinedfor non-Cartesian charts or outside chart context.3.9
Returns
{CartesianLayout | undefined} The Cartesian chart layout, or
undefined.Modifiers
@public
function useCartesianScale
useCartesianScale: ( dataPoint: CartesianDataPoint, xAxisId?: AxisId, yAxisId?: AxisId) => Coordinate | undefined;Converts a data point (in data coordinates) to pixel coordinates.
This hook is useful for positioning annotations, custom shapes, or other elements at specific data points on the chart. It uses the axis scales to convert data values to their corresponding pixel positions within the chart area.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist, or if the data point cannot be converted (e.g., if the data values are outside the axis domains).This is a convenience hook that combines useXAxisScale and useYAxisScale together in a single call.
Parameter dataPoint
The data point with x and y values in data coordinates.
Parameter xAxisId
The
xAxisIdof the X-axis. Defaults to0if not provided.Parameter yAxisId
The
yAxisIdof the Y-axis. Defaults to0if not provided.Returns
The pixel x,y coordinates, or
undefinedif conversion is not possible. 3.8Example 1
// Position a marker at data point { x: 'Page C', y: 2500 }const pixelCoords = useCartesianScale({ x: 'Page C', y: 2500 });if (pixelCoords) {return <circle cx={pixelCoords.x} cy={pixelCoords.y} r={5} fill="red" />;}Modifiers
@public
function useChartHeight
useChartHeight: () => number | undefined;Returns the height of the chart in pixels.
If you are using chart with hardcoded
heightprops, then the height returned will be the same as theheightprop on the main chart element.If you are using a chart with a
ResponsiveContainer, the height will be the size of the chart as the ResponsiveContainer has decided it would be.If the chart has any axes or legend, the
heightwill be the size of the chart including the axes and legend. Meaning: adding axes and legend will not change the height.The dimensions do not scale, meaning as user zoom in and out, the height number will not change as the chart gets visually larger or smaller.
Returns
undefinedif used outside a chart context.Returns
{number | undefined} The height of the chart in pixels, or
undefinedif not in a chart context.Modifiers
@public
function useChartLayout
useChartLayout: () => LayoutType | undefined;Returns the chart layout as configured by the chart.
Cartesian charts use
horizontalorvertical. Polar charts usecentricorradial.Returns
undefinedif used outside a chart context.Returns
{LayoutType | undefined} The chart layout, or
undefinedif not in a chart context.3.9
Modifiers
@public
Deprecated
this hook mixes cartesian and polar layouts together; prefer to use useCartesianChartLayout and usePolarChartLayout instead, which give you better type safety.
function useChartWidth
useChartWidth: () => number | undefined;Returns the width of the chart in pixels.
If you are using chart with hardcoded
widthprop, then the width returned will be the same as thewidthprop on the main chart element.If you are using a chart with a
ResponsiveContainer, the width will be the size of the chart as the ResponsiveContainer has decided it would be.If the chart has any axes or legend, the
widthwill be the size of the chart including the axes and legend. Meaning: adding axes and legend will not change the width.The dimensions do not scale, meaning as user zoom in and out, the width number will not change as the chart gets visually larger or smaller.
Returns
undefinedif used outside a chart context.Returns
{number | undefined} The width of the chart in pixels, or
undefinedif not in a chart context.Modifiers
@public
function useIsTooltipActive
useIsTooltipActive: () => boolean;Returns true if the Tooltip is currently active (visible).
Returns false if the Tooltip is not active or if used outside a chart context.
Recharts only allows one Tooltip per chart, so this hook does not take any parameters. Weird things may happen if you have multiple Tooltip components in the same chart so please don't do that.
Returns
{boolean} True if the Tooltip is active, false otherwise. 3.7
Modifiers
@public
function useMargin
useMargin: () => Margin | undefined;Margin is the empty space around the chart. Excludes axes and legend and brushes and the like. This is declared by the user in the chart props. If you are interested in the space occupied by axes, legend, or brushes, use useOffset instead, which also includes calculated widths and heights of axes and legends.
Returns
undefinedif used outside a chart context.Returns
{Margin | undefined} The margin of the chart in pixels, or
undefinedif not in a chart context.Modifiers
@public
function useOffset
useOffset: () => ChartOffset | undefined;Returns the offset of the chart in pixels.
Offset defines the blank space between the chart and the plot area. This blank space is occupied by supporting elements like axes, legends, and brushes.
The offset includes:
- Margins - Width and height of the axes - Width and height of the legend - Brush height
If you are interested in the margin alone, use useMargin instead.
The offset is independent of charts position on the page, meaning it does not change as the chart is scrolled or resized.
It is also independent of the scale and zoom, meaning that as the user zooms in and out, the numbers will not change as the chart gets visually larger or smaller.
This hook must be used within a chart context (inside a
<LineChart>,<BarChart>, etc.). This hook returnsundefinedif used outside a chart context.Returns
Offset of the chart in pixels, or undefined if used outside a chart context. 3.1
Modifiers
@public
function usePlotArea
usePlotArea: () => PlotArea | undefined;Plot area is the area where the actual chart data is rendered. This means: bars, lines, scatter points, etc.
The plot area is calculated based on the chart dimensions and the offset.
Plot area
widthandheightare the dimensions in pixels;xandyare the coordinates of the top-left corner of the plot area relative to the chart container.They are also independent of the scale and zoom, meaning that as the user zooms in and out, the plot area dimensions will not change as the chart gets visually larger or smaller.
This hook must be used within a chart context (inside a
<LineChart>,<BarChart>, etc.). This hook returnsundefinedif used outside a chart context.Returns
Plot area of the chart in pixels, or undefined if used outside a chart context. 3.1
Modifiers
@public
function usePolarChartLayout
usePolarChartLayout: () => PolarLayout | undefined;Returns the chart layout only for Polar charts.
Returns
centricorradialfor Polar charts. Returnsundefinedfor non-Polar charts or outside chart context.Returns
{PolarLayout | undefined} The Polar chart layout, or
undefined.3.9
Modifiers
@public
function useRechartsTheme
useRechartsTheme: () => RechartsTheme | undefined;Reads the currently active theme in the children tree. Returns the theme as-is, without modifications and without defaults.
Can return undefined if used outside of Recharts context, or if no theme is set.
See Also
3.11
Modifiers
@public
function useXAxisDomain
useXAxisDomain: ( xAxisId?: AxisId) => NumberDomain | CategoricalDomain | undefined;Returns the calculated domain of an X-axis.
The domain can be numerical:
[min, max], or categorical:['a', 'b', 'c'].The type of the domain is defined by the
typeprop of the XAxis.The values of the domain are calculated based on the data and the
dataKeyof the axis.If the chart has a Brush, the domain will be filtered to the brushed indexes if the hook is used outside a Brush context, and the full domain will be returned if the hook is used inside a Brush context.
Parameter xAxisId
The
xAxisIdof the X-axis. Defaults to0if not provided.Returns
The domain of the X-axis, or
undefinedif it cannot be calculated or if used outside a chart context. 3.2Modifiers
@public
function useXAxisInverseDataSnapScale
useXAxisInverseDataSnapScale: ( xAxisId?: AxisId) => InverseScaleFunction | undefined;Returns a function to convert pixel coordinates back to data values for an XAxis, but snapping to the closest data point.
This is similar to useXAxisInverseScale, but instead of returning the exact data value at the pixel position (interpolation), it returns the value of the closest data point.
This is useful for implementing interactions where you want to select the closest data point rather than an exact value or a tick.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist.Parameter xAxisId
The
xAxisIdof the XAxis. Defaults to0if not provided.Returns
An inverse scale function that maps pixel coordinates to the closest data value, or
undefined. 3.8Modifiers
@public
function useXAxisInverseScale
useXAxisInverseScale: (xAxisId?: AxisId) => InverseScaleFunction | undefined;Returns a function to convert pixel coordinates back to data values for an XAxis.
This is useful for implementing interactions like click-to-add-annotation, drag interactions, or tooltips that need to determine what data point corresponds to a mouse position.
For continuous (numerical) scales, returns an interpolated value. For categorical scales, returns the closest category in the domain - which is the same behaviour as useXAxisInverseDataSnapScale.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist.Parameter xAxisId
The
xAxisIdof the XAxis. Defaults to0if not provided.Returns
An inverse scale function that maps pixel coordinates to data values, or
undefined. 3.8Example 1
const xInverseScale = useXAxisInverseScale();if (xInverseScale) {const dataValue = xInverseScale(150); // Returns the data value at pixel x=150}Modifiers
@public
function useXAxisInverseTickSnapScale
useXAxisInverseTickSnapScale: ( xAxisId?: AxisId) => InverseScaleFunction | undefined;Returns a function to convert pixel coordinates back to data values for an XAxis, but snapping to the closest axis tick.
This is similar to useXAxisInverseScale, but instead of returning the exact data value at the pixel position (interpolation), it returns the value of the closest tick.
This is useful for implementing interactions where you want to select the closest tick rather than an exact value or a data point.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist.Parameter xAxisId
The
xAxisIdof the XAxis. Defaults to0if not provided.Returns
An inverse scale function that maps pixel coordinates to the closest tick value, or
undefined. 3.8Modifiers
@public
function useXAxisScale
useXAxisScale: (xAxisId?: AxisId) => ScaleFunction | undefined;Returns a function to convert data values to pixel coordinates for an XAxis.
This is useful for positioning annotations, custom shapes, or other elements at specific data points on the chart.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist.Parameter xAxisId
The
xAxisIdof the XAxis. Defaults to0if not provided.Returns
A scale function that maps data values to pixel coordinates, or
undefined. 3.8Example 1
const xScale = useXAxisScale();if (xScale) {const pixelX = xScale('Page A'); // Returns the pixel x-coordinate for 'Page A'}Modifiers
@public
function useXAxisTicks
useXAxisTicks: (xAxisId?: AxisId) => ReadonlyArray<TickItem> | undefined;Returns the ticks of an XAxis.
This hook is useful for accessing the calculated ticks of an XAxis. The ticks are the same as the ones rendered by the XAxis component.
Parameter xAxisId
The
xAxisIdof the XAxis. Defaults to0if not provided.Returns
An array of ticks, or
undefinedif the axis doesn't exist or hasn't been calculated yet. 3.8Modifiers
@public
function useYAxisDomain
useYAxisDomain: ( yAxisId?: AxisId) => NumberDomain | CategoricalDomain | undefined;Returns the calculated domain of a Y-axis.
The domain can be numerical:
[min, max], or categorical:['a', 'b', 'c'].The type of the domain is defined by the
typeprop of the YAxis.The values of the domain are calculated based on the data and the
dataKeyof the axis.Does not interact with Brushes, as Y-axes do not support brushing.
Parameter yAxisId
The
yAxisIdof the Y-axis. Defaults to0if not provided.Returns
The domain of the Y-axis, or
undefinedif it cannot be calculated or if used outside a chart context. 3.2Modifiers
@public
function useYAxisInverseDataSnapScale
useYAxisInverseDataSnapScale: ( yAxisId?: AxisId) => InverseScaleFunction | undefined;Returns a function to convert pixel coordinates back to data values for a YAxis, but snapping to the closest data point.
This is similar to useYAxisInverseScale, but instead of returning the exact data value at the pixel position (interpolation), it returns the value of the closest data point.
This is useful for implementing interactions where you want to select the closest data point rather than an exact value or a tick.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist.Parameter yAxisId
The
yAxisIdof the YAxis. Defaults to0if not provided.Returns
An inverse scale function that maps pixel coordinates to the closest data value, or
undefined. 3.8Modifiers
@public
function useYAxisInverseScale
useYAxisInverseScale: (yAxisId?: AxisId) => InverseScaleFunction | undefined;Returns a function to convert pixel coordinates back to data values for a YAxis.
This is useful for implementing interactions like click-to-add-annotation, drag interactions, or tooltips that need to determine what data point corresponds to a mouse position.
For continuous (numerical) scales, returns an interpolated value. For categorical scales, returns the closest category in the domain - which is the same behaviour as useYAxisInverseDataSnapScale.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist.Parameter yAxisId
The
yAxisIdof the YAxis. Defaults to0if not provided.Returns
An inverse scale function that maps pixel coordinates to data values, or
undefined. 3.8Example 1
const yInverseScale = useYAxisInverseScale();if (yInverseScale) {const dataValue = yInverseScale(200); // Returns the data value at pixel y=200}Modifiers
@public
function useYAxisInverseTickSnapScale
useYAxisInverseTickSnapScale: ( yAxisId?: AxisId) => InverseScaleFunction | undefined;Returns a function to convert pixel coordinates back to data values for a YAxis, but snapping to the closest axis tick.
This is similar to useYAxisInverseScale, but instead of returning the exact data value at the pixel position (interpolation), it returns the value of the closest tick.
This is useful for implementing interactions where you want to select the closest tick rather than an exact value or a data point.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist.Parameter yAxisId
The
yAxisIdof the YAxis. Defaults to0if not provided.Returns
An inverse scale function that maps pixel coordinates to the closest tick value, or
undefined. 3.8Modifiers
@public
function useYAxisScale
useYAxisScale: (yAxisId?: AxisId) => ScaleFunction | undefined;Returns a function to convert data values to pixel coordinates for a YAxis.
This is useful for positioning annotations, custom shapes, or other elements at specific data points on the chart.
This hook must be used within a chart context (inside a LineChart, BarChart, etc.). Returns
undefinedif used outside a chart context, or if the axes don't exist.Parameter yAxisId
The
yAxisIdof the YAxis. Defaults to0if not provided.Returns
A scale function that maps data values to pixel coordinates, or
undefined. 3.8Example 1
const yScale = useYAxisScale();if (yScale) {const pixelY = yScale(1500); // Returns the pixel y-coordinate for value 1500}Modifiers
@public
function useYAxisTicks
useYAxisTicks: (yAxisId?: AxisId) => ReadonlyArray<TickItem> | undefined;Returns the ticks of a YAxis.
This hook is useful for accessing the calculated ticks of a YAxis. The ticks are the same as the ones rendered by the YAxis component.
Parameter yAxisId
The
yAxisIdof the YAxis. Defaults to0if not provided.Returns
An array of ticks, or
undefinedif the axis doesn't exist or hasn't been calculated yet. 3.8Modifiers
@public
function XAxis
XAxis: <DataPointType = any, DataValueType = any>( props: Props<DataPointType, DataValueType>) => ReactElement;CartesianViewBoxContext CartesianLabelContext
Modifiers
@public
function YAxis
YAxis: <DataPointType = any, DataValueType = any>( props: Props<DataPointType, DataValueType>) => ReactElement;CartesianViewBoxContext CartesianLabelContext
Modifiers
@public
function ZAxis
ZAxis: typeof ZAxis;Virtual axis, does not render anything itself. Has no ticks, grid lines, or labels. Useful for dynamically setting Scatter point size, based on data.
CartesianViewBoxContext
Modifiers
@public
function ZIndexLayer
ZIndexLayer: ({ zIndex, children }: ZIndexLayerProps) => React.ReactNode;A layer that renders its children into a portal corresponding to the given zIndex. We can't use regular CSS
z-indexbecause SVG does not support it. So instead, we create separate DOM nodes for each zIndex layer and render the children into the corresponding DOM node using React portals.This component must be used inside a Chart component.
Parameter zIndex
numeric zIndex value, higher values are rendered on top of lower values
Parameter children
the content to render inside this zIndex layer
3.4
Modifiers
@public
Classes
class CSSTransitionAnimation
class CSSTransitionAnimation extends RechartsAnimation<string, NamedBezier> {}Animation handle representing a CSS transition. This animation requires only one render, and the actual transition is then handled by the browser.
3.9
Modifiers
@public
method getInterpolated
getInterpolated: () => string;Returns the final value of the animation (the
to).CSS transitions leave both interpolation and easing to the browser, so all we need to do here is return the final state and let browser handle the rest.
method nextAnimationUpdate
protected nextAnimationUpdate: (timeElapsed: number) => number;class JavascriptAnimation
class JavascriptAnimation extends RechartsAnimation<number, EasingFunction> {}Animation handle representing a Javascript-based animation. This animation requires one render cycle for each frame, and it calls setTimeout as quickly as possible
3.9
Modifiers
@public
method getInterpolated
getInterpolated: () => number;Returns value of the animation after its easing function had been applied. This value, unlike getProgress(), can escape the [0..1] range because this is entirely within the easing function control. Spring typically does this.
method nextAnimationUpdate
protected nextAnimationUpdate: () => number;Interfaces
interface AreaPointItem
interface AreaPointItem extends NullableCoordinate {}Modifiers
@public
interface BarRectangleItem
interface BarRectangleItem extends Omit<RectangleProps, 'fill'> {}Modifiers
@public
property background
background?: BarRectangleType;the coordinate of background rectangle
property fill
fill?: string;The color of the entry. A fill object in the props paints the entry with its definition.
property height
height: number;property originalDataIndex
originalDataIndex: number;Stable pre-filter index within the currently displayed data slice. Used for matching with activeIndex from tooltip and for BarStack clip-path indexing.
property parentViewBox
parentViewBox: CartesianViewBoxRequired;property payload
readonly payload?: any;property stackedBarStart
stackedBarStart: number;Chart range coordinate of the baseValue of the first bar in a stack.
property tooltipPosition
tooltipPosition: Coordinate;property value
value: number | [number, number];property width
width: number;property x
x: number;property y
y: number;interface CartesianTickItem
interface CartesianTickItem extends TickItem {}Modifiers
@public
interface CartesianViewBox
interface CartesianViewBox {}Modifiers
@public
interface CellProps
interface Props extends SVGProps<SVGElement> {}Modifiers
@public
interface Coordinate
interface Coordinate {}Modifiers
@public
interface CustomScaleDefinition
interface CustomScaleDefinition< Domain extends CategoricalDomainItem = CategoricalDomainItem> {}A subset of d3-scale. This is the external representation; This is the type that we expect from
axis.scaleprops, if users want to provide custom scales.The actual d3 scales have many more methods, but we don't need them all. Specifically we want to avoid all the setters - immutable API is preferred in Recharts and mutating state will lead to hard-to-debug issues.
See Also
ScaleType and RechartsScaleType for string shortcuts that you can use instead of this interface.
Modifiers
@public
property bandwidth
bandwidth?: () => number;Returns width of each band. Most scales are not banded, so this method is optional. Banded scales (like scaleBand from d3-scale) will implement this method.
property ticks
ticks?: (count: number | undefined) => ReadonlyArray<number>;Quantitative (continuous) scales provide a ticks method that returns representative values from the scale’s domain. Ordinal and band scales do not have this method.
An optional count argument requests more or fewer ticks. The number of ticks returned, however, is not necessarily equal to the requested count.
Parameter count
number of ticks
See Also
method copy
copy: () => CustomScaleDefinition<Domain>;Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa. We use this method in Recharts to ensure immutability - changes to the scale outside should not affect the internal state, as they won't trigger re-renders in React.
method domain
domain: { (): ReadonlyArray<Domain>; (newDomain: readonly Domain[]): this };Returns the scale's current domain. The domain could be: - in categorical scales: an array of strings or categories - in continuous scales: tuple of two numbers: [min, max]
Sets the domain of the scale.
method invert
invert: (value: number) => Domain | undefined;Given a value from the range, returns the corresponding value from the domain.
This method is optional, as not all scales provide an inverse mapping. Linear and time scales typically do, while band and ordinal scales may not.
method range
range: { (): ReadonlyArray<number>; (newRange: readonly number[]): this };Returns the scale’s current range.
Sets the range of the scale.
call signature
(input: Domain): number | undefined;Given an arbitrary input, returns the corresponding point derived from the output range if the input is in the scale's domain. If the input is not included in the domain, returns undefined.
Parameter input
interface DefaultTooltipContentProps
interface Props< TValue extends ValueType = ValueType, TName extends NameType = NameType> {}Modifiers
@public
property accessibilityLayer
accessibilityLayer?: boolean;property contentStyle
contentStyle?: CSSProperties;property formatter
formatter?: Formatter<TValue, TName>;property itemSorter
itemSorter?: TooltipItemSorter<TValue, TName>;property itemStyle
itemStyle?: CSSProperties;property label
label?: ReactNode;property labelClassName
labelClassName?: string;property labelFormatter
labelFormatter?: ( label: ReactNode, payload: ReadonlyArray<Payload<TValue, TName>>) => ReactNode;property labelStyle
labelStyle?: CSSProperties;property payload
payload?: ReadonlyArray<Payload<TValue, TName>>;property separator
separator?: string;property wrapperClassName
wrapperClassName?: string;interface HTMLMousePointer
interface HTMLMousePointer {}Simplified version of the MouseEvent so that we don't have to mock the whole thing in tests.
This is meant to represent the React.MouseEvent which is a wrapper on top of https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
Modifiers
@public
property clientX
clientX: number;property clientY
clientY: number;property currentTarget
currentTarget: HTMLElementTarget;interface HTMLTouchPointer
interface HTMLTouchPointer {}Modifiers
@public
property currentTarget
currentTarget: HTMLElementTarget;property touches
touches: ArrayLike<Pick<Touch, 'clientX' | 'clientY'>>;interface LabelListEntry
interface LabelListEntry<DataPointItem = any> {}Modifiers
@public
property fill
fill: string | undefined;property originalDataIndex
originalDataIndex?: number;Index of the data entry that this label belongs to. Some graphical items do not render every data entry (Bar skips bars without a size, for example), so this can differ from the position of the entry in the list. If undefined, the position in the list is the index.
property payload
payload: DataPointItem;Payload is the source data object for this entry. The shape of this depends on what the user has passed as the data prop to the chart.
property value
value: unknown;Value is what renders in the UI as the label content. If undefined, then the LabelList will pull it from the payload using the dataKey.
interface LegendPayload
interface LegendPayload {}Modifiers
@public
property color
color?: string;property dataKey
dataKey?: DataKey<any>;property dot
dot?: LegendPayloadDot;The dots of the graphical item, if it draws one of the predefined symbols at its data points. The legend icon then draws the same symbol, with the same colors as the dots.
property fill
fill?: RechartsFill;The fill object of the graphical item, if it paints its shapes with an SVG definition. The
recticon, and the icons of filled symbols, draw the same definition with the base color incolor. Inactive items draw the plain inactive color.3.11
property formatter
formatter?: Formatter;property inactive
inactive?: boolean;property legendIcon
legendIcon?: ReactElement<SVGElement>;property payload
payload?: object;Different graphical items put different information in the payload object so double check in runtime what are you getting here.
property type
type?: LegendType;property value
value: string | undefined;This is the text that will be displayed in the legend in the DOM. If undefined, the text will not be displayed, so the icon will be rendered without text.
interface LegendPayloadDot
interface LegendPayloadDot {}The dots that a graphical item draws at its data points, as the legend icon needs them.
3.11
Modifiers
@public
interface LinePointItem
interface LinePointItem {}Modifiers
@public
property payload
readonly payload?: any;property value
readonly value: number;property x
x: number | null;Line coordinates can have gaps in them. We have
connectNullsprop that allows to connect those gaps anyway. What it means is that some points can havenullx or y coordinates.
property y
y: number | null;interface Margin
interface Margin {}Modifiers
@public
interface Padding
interface Padding {}Modifiers
@public
interface RadarPoint
interface RadarPoint {}Modifiers
@public
interface RadialBarSectorProps
interface RadialBarSectorProps extends RadialBarDataItem, ShapeAnimationProps {}Modifiers
@public
interface RechartsTheme
interface RechartsTheme {}Styling presets for Recharts components. The theme can be used to customize the appearance of charts, including colors, fonts, and other visual properties.
See Also
3.11
Modifiers
@public
property axis
axis?: Styles1D;XAxis and YAxis and PolarAngleAxis and PolarRadiusAxis ticks and lines and children
property barBackground
barBackground?: Styles2D;Styles applied to Bar and RadialBar backgrounds.
property brush
brush?: Pick<Styles2D, 'fill' | 'stroke'>;Styles applied to the Brush background, slide, travellers, and text.
property chart
chart?: CSSProperties;Styles applied to the element that wraps the chart, the same element that the
styleprop of the chart styles. The Legend renders inside this element too, so a background here covers the Legend as well.The explicit
width,height, andstyleprops of the chart take precedence over these styles.widthandheightset a default size for every chart that does not set its own. Set both, or set one as a string (such as'100%') together withaspectRatio, otherwise the chart has no size and renders nothing.These are inline styles, so they also take precedence over CSS classes on the chart.
The built-in themes leave this empty: charts are transparent and the page shows through, and they have no default size.
If you paint
backgroundColorhere and leavepageBackgroundunset, Recharts usesbackgroundColoras thepageBackground. If you paint abackgroundshorthand or an image, setpageBackgroundyourself.
property cursor
cursor?: Styles2D;Styles applied to the cursor highlight shown with an active Tooltip.
property errorBar
errorBar?: Styles1D;ErrorBar lines.
property graphicalItems
graphicalItems: ReadonlyArray<GraphicalItemStyle>;Colors of main graphical elements (Area, Bar, Line, Treemap, etc.). Line, Area, Bar, Scatter, Radar, and RadialBar select an entry by sorting the unique string representations of the
dataKeyvalues currently present in the chart. The first entry is assigned to the first key in that sorted list, and the palette repeats when there are more keys than entries.Graphical items with the same
dataKeyshare a style. The assignment is independent of render order, but adding or removing a graphical item can change the assignment of the remaining items. The samedataKeycan also receive different entries in charts with different sets of graphical items.If this array has only one item in it then all graphical items will have the same color.
Sankey selects an entry for each node by the node's index in
data.nodes, and draws each link in the color of its source node, at reduced opacity.Treemap and SunburstChart give each top-level tile or first-ring sector the next entry by index, and all their descendants inherit that color.
The theme colors never mix with user colors. If Line, Area, Bar, Scatter, Radar, RadialBar, Pie, Funnel, Treemap, or SunburstChart sets its own
fillorstrokeprop, it ignores thefillandstrokeof its theme entry together, also in the active state. The rest of the theme entry still applies, including the otheractivestyles and thelabelstyles.Individual shapes of Bar, RadialBar, Scatter, Pie, Funnel, Treemap, Sankey, and SunburstChart, and individual point markers of Line, Area, and Radar can be styled from the data array. If a data entry defines its own
fillorstroke, then that shape ignores the themefillandstroketogether, and takes its colors only from its own styles and the explicit props of its graphical item. The rest of the theme still applies.Other style props and data properties (
fillOpacity,strokeOpacity,strokeWidth,strokeDasharray) override the matching theme value and keep the rest of the theme.Legend and Tooltip items inherit the same color.
property grid
grid?: Styles2D;CartesianGrid and PolarGrid.
Recharts grid allows fill color and fill opacity
property label
label?: LabelTheme;Styles of labels other than data labels: axis labels, labels of reference lines, areas and dots, and standalone
Labelcomponents.Data labels take their styles from GraphicalItemStyle.label instead.
property legend
legend?: { /** * CSS styles to be applied to the wrapper `div` element. */ wrapperStyle?: CSSProperties; /** * CSS styles of individual items inside the Legend, a `<span>` element. * These show the data label (name, or dataKey) and value. * * If a chart has multiple graphical items then the Legend renders multiple item * and each of them gets this itemStyle applied. * * Pie charts render multiple labels from a single data series. * * Note that this is different from {@link Tooltip}: * - in Tooltip: "labelStyle" styles the title / header * - in Tooltip: "itemStyle" styles the individual data points * - in Legend: "labelStyle" styles the individual data points * * Beware of the naming inconsistency! */ labelStyle?: CSSProperties; position?: LegendProps['position']; offset?: LegendProps['offset'];};property pageBackground
pageBackground?: string;The color directly behind the chart: the page, or
chart.backgroundColorif you paint one.Recharts never paints this as a background. It uses this color to draw gaps and halos that look like cut-outs: Treemap tile outlines, SunburstChart separators and the halo around its labels.
Any CSS color works, including
var()references.If this is not set, Recharts uses
chart.backgroundColorinstead. An explicitpageBackgroundalways wins.Each built-in theme is designed for one page background, and sets it here. For example,
darkThemeexpects a dark page and is not legible on a light one.autoThemeexpects a page background that follows the CSScolor-scheme.
property reference
reference?: Styles2D;ReferenceLine, ReferenceArea, and ReferenceDot.
property tooltip
tooltip?: { /** * CSS styles to be applied to the wrapper `div` element. */ contentStyle?: CSSProperties; /** * CSS styles of individual items inside the tooltip, a `<li>` element. * These show the data label (name, or dataKey) and value. * * If a chart has multiple graphical items then the Tooltip renders multiple item * and each of them gets this itemStyle applied. */ itemStyle?: CSSProperties; /** * CSS styles of the tooltip title. * Renders once on the top of tooltip and shows categorical axis value. * * Even if there are multiple graphical items in the chart, only one label gets rendered. * * Note that "Label" in tooltip is the header, which is different from {@link Legend} * where "labelStyle" are the individual items. */ labelStyle?: CSSProperties;};property typography
typography?: TextStyles;Sets styles for all text elements in Recharts, including Tooltip and Legend
interface RelativePointer
interface RelativePointer {}Coordinates relative to the top-left corner of the active element. Also include scale which means that element that's scaled will return the same coordinates as element that's not scaled.
Modifiers
@public
interface ResponsiveContainerProps
interface Props extends Omit< React.HTMLAttributes<HTMLDivElement>, 'id' | 'className' | 'style' | 'onResize' > {}Modifiers
@public
property aspect
aspect?: number;width / height. If specified, the height will be calculated by width / aspect.
property children
children: ReactNode;The content of the container. It can contain multiple charts, and then they will all share the same dimensions.
property className
className?: string | number;The HTML element's class name
property debounce
debounce?: number;If specified a positive number, debounced function will be used to handle the resize event. 0
property height
height?: Percent | number;The height of chart container. Can be a number or a percent string like "100%". '100%'
property id
id?: string | number;Unique identifier of this component. Used as an HTML attribute
id.
property initialDimension
initialDimension?: { width: number; height: number;};The initial width and height of the container. {"width":-1,"height":-1}
property maxHeight
maxHeight?: number;The maximum height of the container. It can be a number.
property minHeight
minHeight?: string | number;The minimum height of the container.
property minWidth
minWidth?: string | number;The minimum width of the container. 0
property onResize
onResize?: (width: number, height: number) => void;If specified provides a callback providing the updated chart width and height values.
property style
style?: CSSProperties;The style of the container.
property width
width?: Percent | number;The width of chart container. Can be a number or a percent string like "100%". '100%'
interface SankeyData
interface SankeyData {}Modifiers
@public
interface SankeyLinkProps
interface LinkProps extends SVGProps<SVGPathElement> {}Modifiers
@public
property index
index: number;property linkWidth
linkWidth: number;property payload
payload: Omit<SankeyLink, 'source' | 'target'> & { source: SankeyNode; target: SankeyNode;};property sourceControlX
sourceControlX: number;property sourceRelativeY
sourceRelativeY: number;property sourceX
sourceX: number;property sourceY
sourceY: number;property targetControlX
targetControlX: number;property targetRelativeY
targetRelativeY: number;property targetX
targetX: number;property targetY
targetY: number;interface SankeyNode
interface SankeyNode {}Modifiers
@public
property depth
depth: number;property dx
dx: number;property dy
dy: number;property name
name: string;property sourceLinks
sourceLinks: number[];property sourceNodes
sourceNodes: number[];property targetLinks
targetLinks: number[];property targetNodes
targetNodes: number[];property value
value: any;property x
x: number;property y
y: number;interface SankeyNodeProps
interface NodeProps extends Omit<SVGProps<SVGRectElement>, 'height' | 'width'> {}Modifiers
@public
interface ScatterPointItem
interface ScatterPointItem {}Scatter coordinates are nullable because sometimes the point value is out of the domain, and we can't compute a valid coordinate for it.
Scatter -> Symbol ignores points with null cx or cy so those won't render if using the default shapes. However: the points are exposed via various props and can be used in custom shapes so we keep them around.
Modifiers
@public
property cx
cx: number | undefined;The x coordinate of the point center in pixels.
property cy
cy: number | undefined;The y coordinate of the point center in pixels.
property height
height: number;Height of the point in pixels.
property node
node: ScatterPointNode;property payload
payload?: any;property size
size: number;ScatterPointItem size is an abstract number that is used to calculate the radius of the point. It's not the radius itself, but rather a value that is used to calculate the radius. Interacts with the zAxis range.
property tooltipPayload
tooltipPayload?: TooltipPayload;property tooltipPosition
tooltipPosition: Coordinate;property width
width: number;Width of the point in pixels.
property x
x: number | undefined;The x coordinate (in pixels) of the top-left corner of the rectangle that wraps the point.
property y
y: number | undefined;The y coordinate (in pixels) of the top-left corner of the rectangle that wraps the point.
interface ScatterPointNode
interface ScatterPointNode {}Modifiers
@public
interface SunburstChartProps
interface SunburstChartProps extends EventThrottlingProps {}Modifiers
@public
property children
children?: React.ReactNode;property className
className?: string;property cx
cx?: number;The x-coordinate of center in pixels. If undefined, it will be set to half of the chart width.
property cy
cy?: number;The y-coordinate of center in pixels. If undefined, it will be set to half of the chart height.
property data
data: SunburstData;The source data. Each element should be an object. The properties of each object represent the values of different data dimensions.
Use the
dataKeyprop to specify which properties to use.Example 1
data={[{ name: 'a', value: 12, fill: '#8884d8' }, { name: 'b', value: 5, fill: '#83a6ed' }]}
property dataKey
dataKey?: string;Decides how to extract value from the data.
property endAngle
endAngle?: number;Angle, in degrees, at which the chart should end.
property fill
fill?: string | RechartsFill;The fill of the sectors: a color, or a RechartsFill object with an SVG definition, such as a pattern or a gradient. A node in the data can set its own
fillthe same way. If the fill object has nocolor, the definition gets the color the sector would have without it.Example 1
<SunburstChart data={data} fill={{ color: '#8884d8', definition: pattern(patterns.dots) }} />
property height
height?: number | Percent;The height of chart container. Can be a number or a percent string like "100%".
See Also
property id
id?: string;property innerRadius
innerRadius?: number;The radius of the inner circle at the center of the chart.
property label
label?: ImplicitLabelListType;Renders one label for each sector. Options: -
true: renders default labels; -false: no labels are rendered; -object: the props of LabelList component; -ReactElement: a custom SVG label element, such as<text>or<g>. HTML elements such as<div>are not valid inside the chart SVG and may trigger React DOM warnings. -function: a render function of custom label.Explicit LabelList children render independently of this prop.
Example 1
<SunburstChart data={data} label={{ dataKey: 'name', background: true }} />
property nameKey
nameKey?: DataKey<any>;Name represents each sector in the tooltip. This allows you to extract the name from the data:
-
string: the name of the field in the data object; -number: the index of the field in the data; -function: a function that receives the data object and returns the name.
property onClick
onClick?: (node: SunburstData) => void;property onMouseEnter
onMouseEnter?: (node: SunburstData, e: React.MouseEvent) => void;property onMouseLeave
onMouseLeave?: (node: SunburstData, e: React.MouseEvent) => void;property outerRadius
outerRadius?: number;Outermost edge of the chart. Defaults to the max possible radius for a circle inscribed in the chart container
property padding
padding?: number;Distance between sectors.
property responsive
responsive?: boolean;If true, then it will listen to container size changes and adapt the SVG chart accordingly. If false, then it renders the chart at the specified width and height and will stay that way even if the container size changes.
This is similar to ResponsiveContainer but without the need for an extra wrapper component. The
responsiveprop also uses standard CSS sizing rules, instead of custom resolution logic (like ResponsiveContainer does). false
property ringPadding
ringPadding?: number;Padding between each hierarchical level.
property startAngle
startAngle?: number;Angle in degrees from which the chart should start.
property stroke
stroke?: string;property style
style?: CSSProperties;property textOptions
textOptions?: TextProps;An object with text options to control the appearance of the default chart labels. Shared SVG styles also apply to the
labelprop; explicit label props win.Deprecated
Prefer
labelfor new code. Text-specific options remain supported for default labels.
property width
width?: number | Percent;The width of chart container. Can be a number or a percent string like "100%".
See Also
interface SunburstData
interface SunburstData {}Modifiers
@public
property children
children?: SunburstData[];property fill
fill?: string | RechartsFill;A color, or a RechartsFill object with an SVG definition, such as a pattern or a gradient.
property name
name: string;property tooltipIndex
tooltipIndex?: TooltipIndex;property value
value?: number;index signature
[key: string]: any;interface SVGMousePointer
interface SVGMousePointer {}Simplified version of the MouseEvent for SVG elements.
Similar to MousePointer but uses SVGGraphicsElement properties instead of HTMLElement properties. SVG elements use getBBox() to get the intrinsic size instead of offsetWidth/offsetHeight.
Modifiers
@public
property clientX
clientX: number;property clientY
clientY: number;property currentTarget
currentTarget: SVGElementTarget;interface SVGTouchPointer
interface SVGTouchPointer {}Modifiers
@public
property currentTarget
currentTarget: SVGElementTarget;property touches
touches: ArrayLike<Pick<Touch, 'clientX' | 'clientY'>>;interface TickItem
interface TickItem {}Modifiers
@public
property coordinate
coordinate: number;property index
index: number;property offset
offset?: number;How far this tick is offset from the start of a category band. On axes that do not have bands, this will always be zero.
We never read offset internally in Recharts, but it has been part of the external API so let's keep it here for people who do use it.
property value
value: any;interface TimeoutController
interface TimeoutController {}TimeoutController is responsible for controlling the movement of time. Think of it as a clock.
Recharts default implementation uses requestAnimationFrame which works great in a browser. You may choose to override this which is especially useful if you want to control animations.
Why would you want to do this? - unit tests - animations based on something other than time: UI controls, page scroll, mouse movement ...
See Also
3.9
Modifiers
@public
method setTimeout
setTimeout: (callback: CallbackType, delay?: number) => CancelableTimeout;Sets a timeout that executes a callback after a specified delay. Allows setting multiple timeouts and provides a way to cancel them independently.
Note that this one function has two different time systems! The input (delay - parameter of setTimeout) - is relative - it means "wait for this long" -
The output (now - parameter of the callback) is absolute; it means "this is the time now"
Parameter callback
The function to execute after the delay. Receives the current absolute time in milliseconds as an argument.
Parameter delay
(optional) - The duration of time in milliseconds to wait before executing the callback. Defaults to 0.
interface TooltipPayloadEntry
interface Payload< TValue extends ValueType = ValueType, TName extends NameType = NameType> extends Omit<SVGProps<SVGElement>, 'name'> {}Modifiers
@public
property chartType
chartType?: string;property className
className?: string;property color
color?: string;property dataKey
dataKey?: DataKey<any>;property fill
fill?: string;property formatter
formatter?: Formatter<TValue, TName>;property graphicalItemId
graphicalItemId: string;The id of the graphical item that the data point belongs to
property hide
hide?: boolean;property name
name?: TName;property nameKey
nameKey?: DataKey<any>;property payload
payload?: any;property stroke
stroke?: string;property strokeDasharray
strokeDasharray?: string | number;property strokeWidth
strokeWidth?: number | string;property type
type?: TooltipType;property unit
unit?: ReactNode;property value
value?: TValue;interface TreemapNode
interface TreemapNode {}This is what is returned from
squarify, the final treemap data structure that gets rendered and is stored inModifiers
@public
property children
children: ReadonlyArray<TreemapNode> | null;property depth
depth: number;property height
height: number;property index
index: number;property name
name: string;property root
root?: TreemapNode;property tooltipIndex
tooltipIndex: TooltipIndex;property value
value: number;property width
width: number;property x
x: number;property y
y: number;index signature
[k: string]: unknown;interface TreemapProps
interface Props< DataPointType extends TreemapDataType = TreemapDataType, DataValueType = any> extends DataConsumer<DataPointType, DataValueType>, EventThrottlingProps {}Modifiers
@public
property animationBegin
animationBegin?: number;Specifies when the animation should begin, the unit of this option is ms. 0
property animationDuration
animationDuration?: AnimationDuration;Specifies the duration of animation, the unit of this option is ms. 1500
property animationEasing
animationEasing?: EasingInput;The type of easing function. 'linear'
property animationId
animationId?: number;Deprecated
unused prop, doesn't do anything, use
keyinstead
property aspectRatio
aspectRatio?: number;The treemap will try to keep every single rectangle's aspect ratio near the aspectRatio given. 1.618033988749895
property children
children?: ReactNode;property className
className?: string;property colorPanel
colorPanel?: ReadonlyArray<string>;property content
content?: TreemapContentType;If set to a React element, the option is the customized React element of rendering the content. Use an SVG element or component, such as
<text>or<g>. HTML elements such as<div>are not valid inside the chart SVG and may trigger React DOM warnings. If set to a function, the function will be called to render the content.
property data
data?: ReadonlyArray<DataPointType>;The source data. Each element should be an object. The properties of each object represent the values of different data dimensions.
Use the
dataKeyprop to specify which properties to use.If the
childrenproperty is present on an element, it will be treated as a nested treemap.
property dataKey
dataKey?: DataKey<DataPointType, DataValueType>;Decides how to extract the value of this Treemap from the data: -
string: the name of the field in the data object; -number: the index of the field in the data; -function: a function that receives the data object and returns the value of this Treemap.
property fill
fill?: string | RechartsFill;The fill of the tiles: a color, or a RechartsFill object with an SVG definition, such as a pattern or a gradient. A node in the data can set its own
fillthe same way. If the fill object has nocolor, the definition gets the color the tile would have without it.Example 1
<Treemap fill={{ definition: pattern(patterns.diagonal) }} />
property height
height?: number | Percent;The height of chart container. Can be a number or a percent string like "100%".
property id
id?: string;property isAnimationActive
isAnimationActive?: boolean | 'auto';If set false, animation of treemap will be disabled. If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility. 'auto'
property isUpdateAnimationActive
isUpdateAnimationActive?: boolean | 'auto';property label
label?: ImplicitLabelListType;Renders one label for each tile, through the shared LabelList. Options: -
trueor undefined: renders the node names on the tiles where they fit; -false: no labels are rendered; - object: the props of LabelList component; - ReactElement: a custom SVG label element, such as<text>or<g>; - function: a render function of custom label.<LabelList>children render in addition to these labels. Setlabel={false}to show only the children. The node names are not drawn whencontentrenders the tiles.
property nameKey
nameKey?: DataKey<DataPointType, DataValueType>;Name represents each sector in the tooltip. This allows you to extract the name from the data:
-
string: the name of the field in the data object; -number: the index of the field in the data; -function: a function that receives the data object and returns the name.
property nestIndexContent
nestIndexContent?: | React.ReactElement | ((item: TreemapNode, i: number) => ReactNode);property nodeGap
nodeGap?: number;The gap between the nodes.
Adds spacing between sibling nodes at the same depth level. This does not inset children from their parent boundary. 0 3.9
property nodeInset
nodeInset?: number;The inset between a parent node and its child nodes.
Insets a parent node's available area before laying out its children. This creates space between a parent boundary and its child nodes. 0 3.9
property onAnimationEnd
onAnimationEnd?: () => void;The customized event handler of animation end
property onAnimationStart
onAnimationStart?: () => void;The customized event handler of animation start
property onClick
onClick?: (node: TreemapNode) => void;property onMouseEnter
onMouseEnter?: ( node: TreemapNode, e: React.MouseEvent<SVGGraphicsElement>) => void;property onMouseLeave
onMouseLeave?: ( node: TreemapNode, e: React.MouseEvent<SVGGraphicsElement>) => void;property stroke
stroke?: string;property style
style?: React.CSSProperties;property type
type?: 'flat' | 'nest';The type of treemap to render.
- 'flat': Renders the entire treemap at once, with all leaf nodes visible. - 'nest': Renders an interactive, nested treemap. Clicking on a parent node will "zoom in" to show its children, and a breadcrumb navigation will be displayed to allow navigating back up the hierarchy.
'flat'
property width
width?: number | Percent;The width of chart container. Can be a number or a percent string like "100%".
interface ZAxisProps
interface Props<DataPointType = any, DataValueType = any> extends Omit<BaseAxisProps<DataPointType, DataValueType>, 'domain'> {}Modifiers
@public
property domain
domain?: AxisDomain;Specify the domain of axis when the axis is a number axis.
If undefined, then the domain is calculated based on the data and dataKeys.
The length of domain should be 2, and we will validate the values in domain.
Each element in the array can be a number, 'auto', 'dataMin', 'dataMax', a string like 'dataMin - 20', 'dataMax + 100', or a function that accepts a single argument and returns a number.
If any element of domain is set to be 'auto', comprehensible scale ticks will be calculated, and the final domain of axis is generated by the ticks. If a function, receives '[dataMin, dataMax]', and must return a computed domain as '[min, max]'.
Example 1
<ZAxis type="number" domain={['dataMin', 'dataMax']} />
Example 2
<ZAxis type="number" domain={[0, 'dataMax']} />
Example 3
<ZAxis type="number" domain={['auto', 'auto']} />
Example 4
<ZAxis type="number" domain={[0, 'dataMax + 1000']} />
Example 5
<ZAxis type="number" domain={['dataMin - 100', 'dataMax + 100']} />
Example 6
<ZAxis type="number" domain={[dataMin => (0 - Math.abs(dataMin)), dataMax => (dataMax * 2)]} />
Example 7
<ZAxis type="number" domain={([dataMin, dataMax]) => { const absMax = Math.max(Math.abs(dataMin), Math.abs(dataMax)); return [-absMax, absMax]; }} />
Example 8
<ZAxis type="number" domain={[0, 100]} allowDataOverflow />
property range
range?: AxisRange;The range of axis. Unlike other axes, the range of z-axis is not informed by chart dimensions.
property scale
scale?: | ScaleType | CustomScaleDefinition | CustomScaleDefinition<string> | CustomScaleDefinition<number> | CustomScaleDefinition<Date>;Scale function determines how data values are mapped to visual values. In other words, decided the mapping between data domain and coordinate range.
If undefined, or 'auto', the scale function is created internally according to the type of axis and data.
You can define a custom scale, either as a string shortcut to a d3 scale, or as a complete scale definition object.
Example 1
Example 2
import { scaleLog } from 'd3-scale'; const scale = scaleLog().base(Math.E); <ZAxis scale={scale} />
property type
type?: 'number' | 'category';The type of axis.
category: Treats data as distinct values. Each value is in the same distance from its neighbors, regardless of their actual numeric difference.number: Treats data as continuous range. Values that are numerically closer are placed closer together on the axis.
property zAxisId
zAxisId?: AxisId;The unique id of z-axis.
Type Aliases
type ActiveDotProps
type ActiveDotProps = DotProps & { payload: any; index: number; dataKey: DataKey<any> | undefined; cx: number | undefined; cy: number | undefined; r: number | string | undefined; fill: string; strokeWidth: number | string; stroke: string; value: any;};Modifiers
@public
type ActiveDotType
type ActiveDotType = /** * true | false will turn the default activeDot on and off, respectively */ | boolean /** * activeDot can be a custom React Component. * It should return an SVG element because we are in SVG context - HTML won't work here. * Unfortunately, if you write a regular old functional component and have it return SVG element, * its default, inferred return type is `JSX.Element` and so if this return type was `SVGElement` * then it would look like a type error (even when doing the right thing). * So instead here we have ReactNode return type which is invalid in runtime * (remember, we are in SVG context so HTML elements won't work, we need SVGElement). * But better than forcing everyone to re-type their components I guess. */ | ((props: ActiveDotProps) => ReactNode) /** * activeDot can be an object; props from here will be appended to the default active dot. * Set `symbol` to draw one of the predefined symbols instead of a circle, and `r` to change its size. * * @example <Line activeDot={{ symbol: 'diamond', r: 8 }} /> */ | (WithFillObject<Partial<ActiveDotProps>> & DotSymbolOption) /** * activeDot can be an element; it will get cloned and will receive new extra props. * I do not recommend this way! Use React component instead, that way you get more predictable props. */ | ReactElement<SVGProps<SVGElement>> /** * activeDot can be one of the predefined symbols, the same as in Legend and Scatter. * The symbol is rendered using the {@link Symbols} component, sized to fit the default active dot. * To change the size, use the object form: `activeDot={{ symbol: 'diamond', r: 8 }}`. * * @example <Line activeDot="diamond" /> */ | SymbolType;This is the type of
activeDotprop on: - Area - Line - RadarModifiers
@public
type ActiveLabel
type ActiveLabel = string | number | undefined;Modifiers
@public
type ActiveShape
type ActiveShape<PropsType = Record<string, unknown>, ElementType = SVGElement> = | ReactElement<Partial<PropsType> & SVGProps<ElementType>> | ((props: PropsType, index?: string | number) => ReactNode) | WithFillObject<Partial<PropsType> & SVGProps<ElementType>> | boolean;Modifiers
@public
type AnimationController
type AnimationController = ( timeoutController: TimeoutController, animationHandle: AnimationHandle, listener: OnAnimationStateUpdate) => CancelableTimeout;AnimationController accepts the animation state machine (= RechartsAnimation) plus a timeout controller, and manages the animation by calling the tick method of the animation state machine at the right time.
One controller is only responsible for one animation. Every new animation will create a new controller.
The animation state machine is responsible for calculating the animation progress and calling the onAnimationStart and onAnimationEnd callbacks at the right time, while the AnimationController is responsible for calling the tick method of the animation state machine.
See Also
3.9
Modifiers
@public
type AnimationHandle
type AnimationHandle = JavascriptAnimation | CSSTransitionAnimation;Recharts animation state machine.
Possible transitions are: -
init: starting state -onAnimationStartexecutes -inittopending-animationBeginduration begins -pendingtoactive-animationDurationduration begins, timer ticks decide the progress -activetocompleted-onAnimationEndexecutesThe state always moves in this direction, cannot move backwards.
The animation queue is static and consists of four elements: -
onAnimationStart: function that is called when the animation is created -animationBegin: delay betweenonAnimationStartand the transition - the transition itself, takesanimationDurationms to finish -onAnimationEnd: function that is called when the animation is moving fromactivetocompletedSee Also
3.9
Modifiers
@public
type AnimationInterpolateFn
type AnimationInterpolateFn< ItemType, LayoutType extends CartesianLayout | PolarLayout> = ( items: ReadonlyArray<AnimationItem<ItemType>> | null, animationElapsedTime: number, layout: LayoutType) => ReadonlyArray<ItemType>;A function that interpolates animation items at a given time. This function receives an array of changes, and must "unwrap" them and interpolate appropriate values and return the result which Recharts will then render.
Parameter items
The tagged animation items describing what changed, or
nullon the very first render (entrance animation). Each item is self-describing: -{ status: 'matched', prev, next }— interpolate betweenprevandnext-{ status: 'added', next }— animate in from a computed entry position -{ status: 'removed', prev }— animate out to a computed exit positionAt
animationElapsedTime = 1, removed items should be excluded from the result.Parameter animationElapsedTime
A normalized time value (0 = start, 1 = end)
Parameter layout
of the chart, useful for deciding the direction of animation
Returns
The interpolated items at time animationElapsedTime
3.9
See Also
Modifiers
@public
type AnimationItem
type AnimationItem<T> = | { readonly status: 'matched'; readonly prev: T; readonly next: T; } | { readonly status: 'added'; readonly next: T; } | { readonly status: 'removed'; readonly prev: T; };A tagged union describing the status of an item during animation.
-
matched: item exists in both previous and next data — interpolate between positions -added: item is new (no previous position) — animate in -removed: item was in previous data but not in next — animate out3.9
See Also
Modifiers
@public
type AnimationMatchBy
type AnimationMatchBy<T> = (item: T, index: number) => string | number | null;A function that extracts a key from an animation item for matching purposes. Items in the previous and next arrays that return the same key are considered the same logical item and will animate between their positions.
Parameter item
The chart item (e.g., a bar rectangle, a line point, a pie sector)
Parameter index
The index of the item in the array
Returns
A string or number key, or null if the item cannot be matched
3.9
See Also
Modifiers
@public
type AnimationMatchByProp
type AnimationMatchByProp<T> = | typeof matchByIndex | typeof matchAppend | AnimationMatchBy<T>;The union of all accepted
animationMatchByprop values: a built-in sentinel string, or a custom matching function.3.9
See Also
Modifiers
@public
type AreaProps
type Props<DataPointType, ValueAxisType> = AreaSvgProps & AreaProps<DataPointType, ValueAxisType>;Modifiers
@public
type AreaRevealShapeProps
type AreaRevealShapeProps = CurveProps & ShapeAnimationProps & { layout?: LayoutType; isRange?: boolean; };Modifiers
@public
type AxisDomain
type AxisDomain = | ReadonlyArray<string> | ReadonlyArray<number> | Readonly<[AxisDomainItem, AxisDomainItem]> | (( [dataMin, dataMax]: NumberDomain, allowDataOverflow: boolean ) => NumberDomain);The domain of axis. This is the definition
Numeric domain is always defined by an array of exactly two values, for the min and the max of the axis. Categorical domain is defined as array of all possible values.
Can be specified in many ways: - array of numbers - with special strings like 'dataMin' and 'dataMax' - with special string math like 'dataMin - 100' - with keyword 'auto' - or a function - array of functions - or a combination of the above
Modifiers
@public
type AxisDomainItem
type AxisDomainItem = | string | number | ((d: number) => string | number) | 'auto' | 'dataMin' | 'dataMax';Modifiers
@public
type AxisDomainTypeInput
type AxisDomainTypeInput = 'number' | 'category' | 'auto';The type of axis.
category: Treats data as distinct values. Each value is in the same distance from its neighbors, regardless of their actual numeric difference.number: Treats data as continuous range. Values that are numerically closer are placed closer together on the axis.auto: the type is inferred based on the chart layout.This is external type - users will provide this type in props. Internally we will evaluate it to either 'category' or 'number' based on the layout, before sending it to the store.
Modifiers
@public
type AxisId
type AxisId = string | number;Modifiers
@public
type AxisInterval
type AxisInterval = | number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd' | 'equidistantPreserveStart' | 'equidistantPreserveEnd';Defines how ticks are placed and whether / how tick collisions are handled. 'preserveStart' keeps the left tick on collision and ensures that the first tick is always shown. 'preserveEnd' keeps the right tick on collision and ensures that the last tick is always shown. 'preserveStartEnd' keeps the left tick on collision and ensures that the first and last ticks always show. 'equidistantPreserveStart' selects a number N such that every nTh tick will be shown without collision. 'equidistantPreserveEnd' selects a number N such that every nTh tick will be shown, ensuring the last tick is always visible.
Modifiers
@public
type AxisRange
type AxisRange = readonly [number, number];Modifiers
@public
type BandPosition
type BandPosition = 'start' | 'middle' | 'end';Position within a band for banded scales. In scales that are not banded, this parameter is ignored.
Modifiers
@public
type BarProps
type Props<DataPointType = any, ValueAxisType = any> = Partial<BarEvents> & BarProps<DataPointType, ValueAxisType> & Omit<BarSvgProps, keyof BarEvents | 'fill'>;Modifiers
@public
type BarShapeProps
type BarShapeProps = BarRectangleItem & ShapeAnimationProps & { isActive: boolean; index: number; };Modifiers
@public
type BarStackProps
type BarStackProps = { /** * When two Bars have the same axisId and same stackId, then the two Bars are stacked in the chart. * This prop sets the stack ID for all Bar components inside this BarStack component. * If undefined, a unique id will be generated automatically. * * When both BarStack and individual Bar components have stackId defined, * the BarStack's stackId wins, and the individual Bar's stackId is ignored. */ stackId?: StackId; /** * Radius applies only once to all bars inside of this stack group, * as if they were one huge bar. * Meaning that if you have three bars stacked together, and you set * radius to 10, only the outer corners of the entire stack will be rounded: the middle bars will have square corners. * * Unless! The edge bars are smaller than the radius value, in which case the bars at the edge get a lot of radius * and the middle one gets a little bit of radius. * * You may want to combine this with setting individual Bar components' radius to their own values for best effect. * `Bar.radius` prop will round corners of individual bars, while `BarStack.radius` will round corners of the entire stack. * * If you provide a single number, it applies to all four corners. * If you provide an array of four numbers, they apply to top-left, top-right, bottom-right, bottom-left corners respectively. * * @defaultValue 0 */ radius?: RectRadius; children?: ReactNode;};Modifiers
@public
type BaseLineType
type BaseLineType = number | ReadonlyArray<NullableCoordinate>;Modifiers
@public
type BaseTickContentProps
type BaseTickContentProps = { angle: number; className?: string; fill: string | undefined; height?: number | string; index: number; name?: string; stroke: string; payload: CartesianTickItem; textAnchor: TextAnchor; tickFormatter: TickFormatter | undefined; verticalAnchor: TextVerticalAnchor; visibleTicksCount: number; width?: number | string; x: number | string; y: number | string;};Modifiers
@public
type BaseValue
type BaseValue = number | 'dataMin' | 'dataMax';Modifiers
@public
type BrushProps
type Props = Omit<SVGProps<SVGElement>, 'onChange' | 'onDragEnd' | 'ref' | 'fill'> & BrushProps;Modifiers
@public
type BrushTravellerType
type BrushTravellerType = | ReactElement<SVGElement> | ((props: TravellerProps) => ReactElement<SVGElement>);Modifiers
@public
type CancelableTimeout
type CancelableTimeout = () => void;A function that, when called, cancels the timeout.
3.9
Modifiers
@public
type CartesianAxisProps
type Props = Omit< PresentationAttributesAdaptChildEvent<any, SVGElement>, 'viewBox' | 'scale' | 'ref'> & CartesianAxisProps;Modifiers
@public
type CartesianDataPoint
type CartesianDataPoint = { x: number | string; y: number | string;};Data point with x and y values that can be converted to pixel coordinates. The x and y values should be in the same format as your chart data.
Modifiers
@public
type CartesianGridProps
type Props = AcceptedSvgProps & CartesianGridProps;Modifiers
@public
type CartesianLayout
type CartesianLayout = 'horizontal' | 'vertical';Modifiers
@public
type CartesianPosition
type CartesianPosition = | 'top' | 'left' | 'right' | 'bottom' | 'center' | 'insideLeft' | 'insideRight' | 'insideTop' | 'insideBottom' | 'insideTopLeft' | 'insideBottomLeft' | 'insideTopRight' | 'insideBottomRight' | { x: number | Percent; y: number | Percent; };Modifiers
@public
type ChartOffset
type ChartOffset = { /** * Distance from the top edge of the chart to the top edge of the plot area. */ readonly top: number; /** * Distance from the bottom edge of the chart to the bottom edge of the plot area. * Note that this is not a coordinate, this is a distance. * Meaning, `offset.bottom` could be 0 in a perfectly fine big chart. */ readonly bottom: number; /** * Distance from the left edge of the chart to the left edge of the plot area. */ readonly left: number; /** * Distance from the right edge of the chart to the right edge of the plot area. * Note that this is not a coordinate, this is a distance. * Meaning, `offset.right` could be 0 in a perfectly fine big chart. */ readonly right: number;};Defines the blank space between the chart and the plot area. This blank space is occupied by supporting elements like axes, legends, and brushes. This also includes any margins that might be applied to the chart.
Modifiers
@public
type CrossProps
type Props = SVGProps<SVGPathElement> & CrossProps;Modifiers
@public
type CursorDefinition
type CursorDefinition = | boolean | ReactElement | WithFillObject<SVGProps<SVGElement>>;If set false, no cursor will be drawn when tooltip is active. If set an object, the option is the configuration of cursor. If set a React element, the option is the custom react element of drawing cursor
Modifiers
@public
type CurveProps
type Props = Omit< PresentationAttributesWithProps<CurveProps, SVGPathElement>, | 'fill' | 'type' | 'points' | 'onClick' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseDown' | 'onMouseUp' | 'onMouseMove' | 'onMouseOver' | 'onMouseOut'> & CurveMouseEvents & CurveProps;Modifiers
@public
type CurveType
type CurveType = | 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter' | CurveFactory;Modifiers
@public
type CustomizedProps
type Props<P, C extends Comp<P>> = P & { /** * Render your components directly, without Customized wrapper. Will be removed in 4.0 * @deprecated * @example Before: `<Customized component={<MyCustomComponent />} />` * @example After: `<MyCustomComponent />` */ component: C;};Modifiers
@public
type DataKey
type DataKey<DataPointType, DataValueType = any> = TypedDataKey< DataPointType, DataValueType>;Extracts values from data objects.
Modifiers
@public
type DefaultLegendContentProps
type Props = DefaultLegendContentProps & Omit< PresentationAttributesForHTML<LegendPayload, ReactElement>, keyof DefaultLegendContentProps >;Modifiers
@public
type DotItemDotProps
type DotItemDotProps = SVGPropsNoEvents<Omit<DotProps, 'points' | 'ref'>> & { points: ReadonlyArray<DotPoint>; index: number; payload: any; dataKey: DataKey<any> | undefined; value: any;};Inside the dot event handlers we provide extra information about the dot point that the Dot component itself does not need but users might find useful.
Modifiers
@public
type DotProps
type Props = Omit< PresentationAttributesWithProps<DotProps, SVGCircleElement>, 'fill'> & DotProps;Modifiers
@public
type DotType
type DotType = /** * true | false will turn the default dot on and off, respectively */ | boolean /** * dot can be a custom React Component. * It should return an SVG element because we are in SVG context - HTML won't work here. * Unfortunately, if you write a regular old functional component and have it return SVG element, * its default, inferred return type is `JSX.Element` and so if this return type was `SVGElement` * then it would look like a type error (even when doing the right thing). * So instead here we have ReactNode return type which is invalid in runtime * (remember, we are in SVG context so HTML elements won't work, we need SVGElement). * But better than forcing everyone to re-type their components I guess. * * Not that when a function, or a component is used, the props received are {@link DotItemDotProps} * which contain some extra information compared to {@link DotProps}. */ | ((props: DotItemDotProps) => ReactNode) /** * dot can be an object; props from here will be appended to the default dot. * Set `symbol` to draw one of the predefined symbols instead of a circle, and `r` to change its size. * * @example <Line dot={{ symbol: 'diamond', r: 6 }} /> */ | (Partial<DotProps> & DotSymbolOption) /** * dot can be an element; it will get cloned and will receive new extra props. * I do not recommend this way! Use React component instead, that way you get more predictable props. */ | ReactElement<SVGProps<SVGElement>> /** * dot can be one of the predefined symbols, the same as in Legend and Scatter. * The symbol is rendered using the {@link Symbols} component, sized to fit the default dot. * To change the size, use the object form: `dot={{ symbol: 'diamond', r: 6 }}`. * The legend icon shows the same symbol, unless `legendType` says otherwise. * * @example <Line dot="diamond" /> */ | SymbolType;This is the type of
dotprop on: - Area - Line - RadarModifiers
@public
type EasingInput
type EasingInput = NamedBezier | 'spring' | EasingFunction;Modifiers
@public
type ErrorBarDirection
type ErrorBarDirection = 'x' | 'y';So usually the direction is decided by the chart layout. Horizontal layout means error bars are vertical means direction=y Vertical layout means error bars are horizontal means direction=x
Except! In Scatter chart, error bars can go both ways.
So this property is only ever used in Scatter chart, and ignored elsewhere.
Modifiers
@public
type ErrorBarProps
type Props = SVGProps<SVGLineElement> & ErrorBarProps;Modifiers
@public
type FunnelProps
type Props<DataPointType = any, DataValueType = any> = FunnelSvgProps & FunnelProps<DataPointType, DataValueType>;Modifiers
@public
type FunnelTrapezoidItem
type FunnelTrapezoidItem = Omit<TrapezoidProps, 'fill'> & TrapezoidViewBox & { /** * The color of the entry. A fill object in the props paints the entry with its definition. */ fill?: string; value?: number | string; payload?: any; tooltipPosition: Coordinate; name: string; labelViewBox: TrapezoidViewBox; parentViewBox: CartesianViewBoxRequired; val: number | ReadonlyArray<number>; tooltipPayload: TooltipPayload; };Modifiers
@public
type GridLineType
type GridLineType = | SVGProps<SVGLineElement> | ReactElement<SVGElement> | ((props: GridLineTypeFunctionProps) => ReactElement<SVGElement>) | boolean;Modifiers
@public
type GridLineTypeFunctionProps
type GridLineTypeFunctionProps = Omit<LineItemProps, 'key'> & { key: LineItemProps['key'] | undefined; offset: ChartOffsetInternal;};The <CartesianGrid horizontal
Modifiers
@public
type HorizontalAlignmentType
type HorizontalAlignmentType = 'center' | 'left' | 'right';Modifiers
@public
type IfOverflow
type IfOverflow = 'hidden' | 'visible' | 'discard' | 'extendDomain';Modifiers
@public
type ImplicitLabelListType
type ImplicitLabelListType = boolean | LabelContentType | Props;This is the type accepted for the
labelprop on various graphical items. It accepts:boolean: true = labels show, false = labels don't show React element: will be cloned with extra props function: is used as <Label content={function} />, so this will be called once for each individual label (so typically once for each data point) object: the props to be passed to a LabelList component
Modifiers
@public
type ImplicitLabelType
type ImplicitLabelType = | boolean | string | number | ReactElement<SVGElement> | ((props: any) => RenderableText | ReactElement) | (Props & { dataKey?: DataKey<any>; });Modifiers
@public
type InternalRadarProps
type InternalRadarProps = RadarPropsWithDotFill & RadarComposedData;Modifiers
@public
type InverseScaleFunction
type InverseScaleFunction = (pixelValue: number) => unknown;A function that converts pixel coordinates back to data values.
Parameter pixelValue
The pixel coordinate to convert.
Returns
The closest data value in the domain.
Modifiers
@public
type LabelContentType
type LabelContentType = | ReactElement | ((props: Props) => RenderableText | ReactElement);Modifiers
@public
type LabelListProps
type Props = Omit<SvgTextProps, 'children'> & LabelListProps;Modifiers
@public
type LabelListPropsWithPosition
type LabelListPropsWithPosition = LabelListProps & { position: LabelListProps['position'];};Modifiers
@public
type LabelPosition
type LabelPosition = CartesianLabelPosition | PolarLabelPosition;Modifiers
@public
type LabelProps
type Props = Omit<SVGProps<SVGTextElement>, 'viewBox'> & LabelProps;Modifiers
@public
type LayerProps
type Props = SVGAttributes<SVGGElement> & LayerProps;Modifiers
@public
type LayoutType
type LayoutType = CartesianLayout | PolarLayout;Modifiers
@public
Deprecated
use either
CartesianLayoutorPolarLayoutinstead. Mixing both charts families leads to ambiguity in the type system. These two layouts share very few properties, so it is best to keep them separate.
type LegendContentType
type ContentType = ReactElement | ((props: Props) => ReactNode);Modifiers
@public
type LegendProps
type Props = Omit< DefaultLegendContentProps, 'payload' | 'ref' | 'verticalAlign' | 'layout'> & { /** * Renders the content of the legend. * * This should return HTML elements, not SVG elements. * * - If not set, the {@link DefaultLegendContent} component is used. * - If set to a React element, this element will be cloned and extra props will be passed in. * - If set to a function, the function will be called and should return HTML elements. * * @example <Legend content={CustomizedLegend} /> * @example <Legend content={renderLegend} /> */ content?: ContentType; /** * The layout of legend items inside the legend container. * * When `auto` then the layout is decided based on the `position` prop: * - in `left`|`right` positions, the layout is vertical * - otherwise horizontal * - if position is undefined, also horizontal * * `auto` value is new since 3.10 * * @defaultValue auto */ layout?: CartesianLayout | 'auto'; /** * CSS styles to be applied to the wrapper `div` element. */ wrapperStyle?: CSSProperties; /** * Width of the legend. * Accept CSS style string values like `100%` or `fit-content`, or number values like `400`. */ width?: number | string; /** * Height of the legend. * Accept CSS style string values like `100%` or `fit-content`, or number values like `400`. */ height?: number | string; payloadUniqBy?: UniqueOption<LegendPayload>; onBBoxUpdate?: (box: ElementOffset | null) => void; /** * If portal is defined, then Legend will use this element as a target * for rendering using React Portal. * * If this is undefined then Legend renders inside the recharts-wrapper element. * * @see {@link https://react.dev/reference/react-dom/createPortal} */ portal?: HTMLElement | null; /** * Sorts Legend items. Defaults to `value` which means it will sort alphabetically * by the label. * * If `null` is provided then the payload is not sorted. Be aware that without sort, * the order of items may change between renders! * * @defaultValue value */ itemSorter?: LegendItemSorter | null; /** * @deprecated use `position` instead which has more options, is more flexible and has more intuitive default styles. * * @description The alignment of the whole Legend container: * * - `bottom`: shows the Legend below chart, and chart height reduces automatically to make space for it. * - `top`: shows the Legend above chart, and chart height reduces automatically. * - `middle`: shows the Legend in the middle of chart, covering other content, and chart height remains unchanged. * The exact behavior changes depending on `align` prop. * * @defaultValue bottom * @see {@link https://recharts.github.io/examples/LegendPosition/ Legend position playground} */ verticalAlign?: VerticalAlignmentType; /** * The position of the legend relative to the chart. * If this is defined, it overrides `align` and `verticalAlign`. * * @since 3.10 */ position?: CartesianPosition; /** * The offset to the specified `position`. Direction of the offset depends on the position. * * @since 3.10 */ offset?: number;};Modifiers
@public
type LegendType
type LegendType = | 'circle' | 'cross' | 'diamond' | 'line' | 'plainline' | 'rect' | 'square' | 'star' | 'triangle' | 'wye' | 'none';Modifiers
@public
type LineDrawShapeProps
type LineDrawShapeProps = Omit<CurveProps, 'pathRef'> & ShapeAnimationProps & { /** * CurveProps use Ref which includes the object plus callback. * Here in LineDrawShape we have to read from it so we only allow the object - but we keep `Curve.ref` the same * for backwards compatibility. * LineDrawShape is new since 3.9 so there's no backwards to go. */ pathRef: RefObject<SVGPathElement>; /** * The computed visible length of the SVG path during entrance animation, in pixels. * - When a number: the shape should apply stroke-dasharray to reveal exactly this many pixels. * - When null or undefined: no entrance-driven stroke-dasharray should be applied. * * This value is computed by `useAnimatedLineLength` in the parent component. */ visibleLength?: number | null; };Modifiers
@public
type LineProps
type Props<DataPointType = any, ValueAxisType = any> = LineSvgProps & LineProps<DataPointType, ValueAxisType>;Modifiers
@public
type MinPointSize
type MinPointSize = | number | ((value: number | undefined | null, index: number) => number);Modifiers
@public
type MouseHandlerDataParam
type MouseHandlerDataParam = { /** * Index of the active tick in the current chart. Only works with number-indexed one-dimensional data charts, * like Line, Area, Bar, Pie, etc. * * Doesn't work with two-dimensional data charts like Treemap, Sankey. But one day it will which is why the TooltipIndex type is here. */ activeTooltipIndex: number | TooltipIndex | undefined; isTooltipActive: boolean; /** * Exactly the same as activeTooltipIndex - this was also duplicated in recharts@2 so let's keep both properties for better backwards compatibility. */ activeIndex: number | TooltipIndex | undefined; /** * The category or domain value of the active tooltip entry. */ activeLabel: ActiveLabel; activeDataKey: DataKey<any> | undefined; activeCoordinate: Coordinate | undefined;};Despite the name, this type is used for all event types, not just mouse events.
Modifiers
@public
type MousePointer
type MousePointer = HTMLMousePointer | SVGMousePointer;Recharts accepts mouse events from both HTML and SVG elements.
Modifiers
@public
type NiceTicksAlgorithm
type NiceTicksAlgorithm = 'none' | 'auto' | 'adaptive' | 'snap125';Controls how Recharts calculates "nice" tick values for numerical axes.
-
'none': Recharts does not apply any tick-rounding algorithm; tick positions are determined entirely by d3, evenly spaced but not rounded to human-friendly numbers. There is no domain-extension logic applied in this mode.-
'auto'*(default)*: Recharts automatically decides whether and how to apply tick niceties based on the domain definition. When the domain contains an'auto'keyword, Recharts uses the'adaptive'algorithm and may extend the domain slightly to produce clean tick labels. Otherwise, it applies the same algorithm while keeping ticks within the fixed domain. This mirrors the default behavior from Recharts v2.-
'adaptive': Always applies the space-efficient algorithm (getAdaptiveStep), which fills the available range as densely as possible while still rounding steps to reasonable numbers (e.g. 10, 20, 25). May produce less "round-looking" labels than'snap125', but wastes less space. The domain-extension logic still applies when the domain contains an'auto'keyword.-
'snap125': Always applies the round-numbers algorithm (getSnap125Step), which snaps step sizes to values from the set {1, 2, 2.5, 5} × 10ⁿ. Produces very human-friendly labels (e.g. 0, 5, 10, 15, 20) but may leave blank space at the edges of the chart. The domain-extension logic still applies when the domain contains an'auto'keyword.See Also
Modifiers
@public
type NoCentric
type NoCentric<T> = 'Radar' extends keyof T ? never : 'RadarChart' extends keyof T ? never : T;Modifiers
@public
type NoFunnel
type NoFunnel<T> = 'Funnel' extends keyof T ? never : 'FunnelChart' extends keyof T ? never : T;Modifiers
@public
type NoRadial
type NoRadial<T> = 'RadialBar' extends keyof T ? never : 'RadialBarChart' extends keyof T ? never : 'Pie' extends keyof T ? never : 'PieChart' extends keyof T ? never : T;Modifiers
@public
type NumberDomain
type NumberDomain = readonly [min: number, max: number];NumberDomain is an evaluated AxisDomain. Unlike AxisDomain, it has no variety - it's a tuple of two number. This is after all the keywords and functions were evaluated and what is left is [min, max].
Know that the min, max values are not guaranteed to be nice numbers - values like -Infinity or NaN are possible.
There are also
categoryaxes that have different things than numbers in their domain.Modifiers
@public
type OnAnimationStateUpdate
type OnAnimationStateUpdate = (newState: number | string) => void;It's actually always the case that JavaScript-based animations produce numbers, and CSS transition-based animations always produce strings, but it's so much easier to just have them together than to deal with all the generics.
See Also
3.9
Modifiers
@public
type Orientation
type Orientation = XAxisOrientation | YAxisOrientation;The orientation of the axis in correspondence to the chart
Modifiers
@public
type PieLabel
type PieLabel = | boolean | LabelListPropsWithPosition | Partial<PieLabelRenderProps> | ((props: PieLabelRenderProps) => ReactNode | ReactElement<SVGElement>) | ReactElement<SVGElement>;The
labelprop in Pie accepts a variety of alternatives.Modifiers
@public
type PieLabelLine
type PieLabelLine = | ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | SVGProps<SVGPathElement> | boolean;Modifiers
@public
type PieLabelRenderProps
type PieLabelRenderProps = Omit<SVGPropsNoEvents<PieSvgAttributes>, 'offset'> & Omit<PieSectorDataItem, 'offset'> & PieLabelExtraProps & Coordinate;Modifiers
@public
type PieProps
type Props<DataPointType = any, DataValueType = any> = PieSvgAttributes & PieProps<DataPointType, DataValueType>;Modifiers
@public
type PieSectorDataItem
type PieSectorDataItem = PiePresentationProps & PieCoordinate & PieSectorData & { cornerRadius: number | undefined; };We spread the data object into the sector data item, so we can't really know what is going to be inside.
This type represents our best effort, but it all depends on the input data and what is inside of it.
https://github.com/recharts/recharts/issues/6380 https://github.com/recharts/recharts/discussions/6375
Modifiers
@public
type PieSectorShapeProps
type PieSectorShapeProps = PieSectorDataItem & ShapeAnimationProps & { [DATA_ITEM_INDEX_ATTRIBUTE_NAME]: number; [DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: GraphicalItemId; isActive: boolean; index: number; } & SVGProps<SVGPathElement>;Modifiers
@public
type PieShape
type PieShape = ActiveShape<PieSectorShapeProps, SVGPathElement>;Modifiers
@public
type PlotArea
type PlotArea = { /** * The width of the plot area. * This will be the same as `chartWidth - offset.left - offset.right` */ readonly width: number; /** * The height of the plot area. * This will be the same as `chartHeight - offset.top - offset.bottom` */ readonly height: number; /** * The x coordinate of the top-left corner of the plot area. * This will be the same as `offset.left` */ readonly x: number; /** * The y coordinate of the top-left corner of the plot area. * This will be the same as `offset.top` */ readonly y: number;};Plot area is the area where the actual chart data is rendered. This means: bars, lines, scatter points, etc.
Modifiers
@public
type PolarAngleAxisProps
type Props<DataPointType = any, DataValueType = any> = AxisSvgProps & PolarAngleAxisProps<DataPointType, DataValueType>;Modifiers
@public
type PolarCoordinate
type PolarCoordinate = Coordinate & { angle: number; startAngle: number; endAngle: number; clockWise: boolean; cx: number; cy: number; innerRadius: number; outerRadius: number; radius: number;};Modifiers
@public
type PolarGridProps
type Props = Omit<SVGProps<SVGLineElement>, 'fill'> & PolarGridProps;Modifiers
@public
type PolarLayout
type PolarLayout = 'centric' | 'radial';Modifiers
@public
type PolarRadiusAxisProps
type Props<DataPointType = any, DataValueType = any> = AxisSvgProps & PolarRadiusAxisProps<DataPointType, DataValueType>;Modifiers
@public
type PolygonProps
type Props = Omit<SVGProps<SVGPolygonElement>, 'points' | 'fill'> & PolygonProps;Modifiers
@public
type RadarProps
type Props<DataPointType = any, DataValueType = any> = Omit< SVGProps<SVGGraphicsElement>, 'onMouseEnter' | 'onMouseLeave' | 'points' | 'ref' | 'fill'> & RadarProps<DataPointType, DataValueType>;Modifiers
@public
type RadialBarDataItem
type RadialBarDataItem = Omit<SectorProps, 'fill'> & PolarViewBoxRequired & TooltipTriggerInfo & { /** * The color of the entry. A fill object in the props paints the entry with its definition. */ fill?: string; value?: any; payload?: any; background?: Omit<SectorProps, 'fill'> & { fill?: string; }; };Modifiers
@public
type RadialBarProps
type RadialBarProps<DataPointType = any, DataValueType = any> = Omit< PresentationAttributesAdaptChildEvent<RadialBarDataItem, SVGElement>, 'ref' | keyof InternalRadialBarProps<DataPointType, DataValueType>> & Omit<InternalRadialBarProps<DataPointType, DataValueType>, 'sectors'>;Modifiers
@public
type RechartsFill
type RechartsFill = { /** * The solid base color. Recharts uses it wherever it needs a plain color: Tooltip and labels. * The definition gets it as its `color` prop. * * If undefined, the base color comes from the theme, so you can add a pattern or gradient * and keep the theme colors. A fill object without `color` does not count as a color of its own, * so the graphical item keeps the theme `stroke` too. */ color?: string; /** * A component that renders an SVG paint server, such as a `<linearGradient>` or a `<pattern>`. * Put the `id` it receives on the root element. * * It is a regular component rendered inside the chart, so it can call hooks, including Recharts hooks. * Define it outside of other components: a new component on every render redraws the definition every time. * * Legend icons draw the same definition, with their own `id`, and give it their size as `bounds`. * A definition sized in pixels, such as a `<pattern>` with `patternUnits="userSpaceOnUse"`, * can read `bounds` to fit the small icon. * * @example * const Sunset = ({ id, color }: RechartsFillDefinitionProps) => ( * <radialGradient id={id}> * <stop offset={0} stopColor="#ffc658" /> * <stop offset={1} stopColor={color} /> * </radialGradient> * ); * <Bar dataKey="uv" fill={{ color: '#ff7300', definition: Sunset }} /> */ definition: ComponentType<RechartsFillDefinitionProps>;};A fill of a graphical item that paints its shapes with an SVG paint server, such as a gradient or a pattern.
Recharts renders the
definitionin<defs>with a unique id, and paints the shapes withurl(#id). Tooltip and labels use the solidcolor.Use linearGradient or pattern to make a definition from the built-in gradients and patterns, or write your own component.
Example 1
<Bar dataKey="uv" fill={{ definition: pattern(patterns.diagonal) }} />
Example 2
<Bar dataKey="uv" fill={{ color: 'blue', definition: linearGradient(gradients.fadeDown) }} />
3.11
Modifiers
@public
type RechartsFillDefinitionProps
type RechartsFillDefinitionProps = { /** * Put this `id` on the root element of the definition. The shapes paint with `url(#id)`. */ id: string; /** * The base color of the fill: the `color` of the fill object, or the theme color of the graphical item. */ color: string | undefined; /** * The size of the area the definition paints, in SVG units, when the definition paints one area of known size, * such as a Legend icon. Undefined when it paints shapes of different sizes, such as every bar of a series. * * Use it to adapt to small areas: {@link pattern} scales its tiles down so that a few of them fit. */ bounds?: { width: number; height: number; };};Props of a RechartsFill
definitioncomponent.3.11
Modifiers
@public
type RechartsGradientStop
type RechartsGradientStop = { /** * Position of the stop along the gradient, from 0 to 1. */ offset: number; /** * Color of the stop. If undefined, the stop uses the base color of the fill. */ color?: string; /** * Opacity of the stop, from 0 to 1. * @defaultValue 1 */ opacity?: number;};A stop of a RechartsLinearGradient.
3.11
Modifiers
@public
type RechartsLinearGradient
type RechartsLinearGradient = { /** * @defaultValue 0 */ x1?: number; /** * @defaultValue 0 */ y1?: number; /** * @defaultValue 0 */ x2?: number; /** * @defaultValue 1 */ y2?: number; stops: ReadonlyArray<RechartsGradientStop>;};A linear gradient, drawn in the bounding box of each shape. Turn it into a fill definition with linearGradient.
The coordinates go from 0 to 1 across the bounding box of the shape, the same as in SVG
objectBoundingBoxunits. Because of that, an angled gradient looks skewed on narrow shapes.3.11
Modifiers
@public
type RechartsPattern
type RechartsPattern = { /** * Width of one tile, in pixels. */ width: number; /** * Height of one tile, in pixels. */ height: number; /** * Rotation of the whole pattern, in degrees. * @defaultValue 0 */ rotation?: number; /** * Texture color. * If undefined, the texture uses the `pageBackground` color from the theme, or white when no theme is set. * That way one pattern works for every series, and in light and dark themes. */ color?: string; /** * Opacity of the texture, from 0 to 1. * @defaultValue 0.5 */ opacity?: number; /** * SVG path data of the texture, in tile coordinates. * If `strokeWidth` is set, the paths are stroked with the texture color. Otherwise they are filled. */ path: string | ReadonlyArray<string>; strokeWidth?: number;};A repeating texture, drawn over the base color of the fill. It is a plain value, so it can be stored as JSON.
Use one of the built-in patterns, adjust one by spreading it (
{ ...patterns.dots, width: 6 }), or write your ownpath. Turn it into a fill definition with pattern. For a texture that SVG paths can't draw, write your owndefinitioncomponent.3.11
Modifiers
@public
type RectangleProps
type Props = Omit<SVGProps<SVGPathElement>, 'radius' | 'fill'> & RectangleProps;Modifiers
@public
type RectRadius
type RectRadius = number | [number, number, number, number];Modifiers
@public
type ReferenceAreaProps
type Props< XValueType extends ReferenceCoordinateValue = any, YValueType extends ReferenceCoordinateValue = any> = Omit< SVGPropsAndEvents<RectangleProps>, 'width' | 'height' | 'x' | 'y' | 'fill'> & ReferenceAreaProps<XValueType, YValueType>;Modifiers
@public
type ReferenceDotProps
type Props< XValueType extends ReferenceCoordinateValue = any, YValueType extends ReferenceCoordinateValue = any> = Omit<DotProps, 'cx' | 'cy' | 'clipDot' | 'dangerouslySetInnerHTML' | 'fill'> & ReferenceDotProps<XValueType, YValueType>;Modifiers
@public
type ReferenceLineProps
type Props< XValueType extends ReferenceCoordinateValue = any, YValueType extends ReferenceCoordinateValue = any> = Omit<SVGProps<SVGLineElement>, 'viewBox'> & ReferenceLineProps<XValueType, YValueType>;This excludes
viewBoxprop from svg for two reasons: 1. The components wants viewBox of object type, and svg wants string - so there's a conflict, and the component will throw if it gets string 2. Internally the component callssvgPropertiesNoEventswhich filters the viewBox away anywayModifiers
@public
type ReferenceLineSegment
type ReferenceLineSegment = readonly [ { x?: number | string; y?: number | string; }, { x?: number | string; y?: number | string; }];Single point that defines one end of a segment. These coordinates are in data space, meaning that you should provide values that correspond to the data domain of the axes. So you would provide a value of
Page Ato indicate the data valuePage Aand then recharts will convert that to pixels.Likewise for numbers. If your x-axis goes from 0 to 100, and you want the line to end at 50, you would provide
50here.Modifiers
@public
type RenderableText
type RenderableText = string | number | boolean | null | undefined;Modifiers
@public
type SankeyElementType
type SankeyElementType = 'node' | 'link';Modifiers
@public
type SankeyLinkOptions
type SankeyLinkOptions = | ReactElement<SVGProps<SVGPathElement>> | ((props: LinkProps) => ReactElement<SVGProps<SVGPathElement>>) | SVGProps<SVGPathElement>;Modifiers
@public
type SankeyNodeOptions
type SankeyNodeOptions = | ReactElement<SVGProps<SVGRectElement>> | ((props: NodeProps) => ReactNode) | RectangleProps;Modifiers
@public
type SankeyProps
type Props = Omit<SVGProps<SVGSVGElement>, keyof SankeyProps> & SankeyProps;Modifiers
@public
type SankeyVerticalAlign
type SankeyVerticalAlign = 'justify' | 'top';Modifiers
@public
type ScaleFunction
type ScaleFunction = ( value: unknown, options?: { position?: BandPosition; }) => number | undefined;A function that converts data values to pixel coordinates.
Parameter value
The data value to convert (number, string, or category).
Parameter options
Optional configuration for banded scales.
Parameter
options.position - Position within a band: 'start', 'middle', or 'end'.
Returns
The pixel coordinate, or
undefinedif the value is not in the domain.Modifiers
@public
type ScatterCustomizedShape
type ScatterCustomizedShape = | ActiveShape<ScatterShapeProps & InnerSymbolsProp, SVGPathElement> | SymbolType;Modifiers
@public
type ScatterProps
type Props<DataPointType = any, ValueAxisType = any> = BaseScatterSvgProps & ScatterProps<DataPointType, ValueAxisType>;Modifiers
@public
type ScatterShapeProps
type ScatterShapeProps = ScatterPointItem & ShapeAnimationProps & { isActive: boolean; index: number; [DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: GraphicalItemId; };Modifiers
@public
type SectorProps
type Props = Omit< SVGProps<SVGPathElement>, 'cx' | 'cy' | 'dangerouslySetInnerHTML' | 'fill'> & Partial<SectorProps>;SVG cx, cy are
string | number | undefined, but internally we usenumberso let's override the types here.Modifiers
@public
type SizeType
type SizeType = 'area' | 'diameter';Modifiers
@public
type StackId
type StackId = string | number;Externally, we accept both strings and numbers as stack IDs
Modifiers
@public
type StackOffsetType
type StackOffsetType = | 'sign' | 'expand' | 'none' | 'wiggle' | 'silhouette' | 'positive';Determines how values are stacked:
-
noneis the default, it adds values on top of each other. No smarts. Negative values will overlap. -expandmake it so that the values always add up to 1 - so the chart will look like a rectangle. -wiggleandsilhouettetries to keep the chart centered. -signstacks positive values above zero and negative values below zero. Similar tononebut handles negatives. -positiveignores all negative values, and then behaves like `none`.See Also
https://d3js.org/d3-shape/stack#stack-offsets (note that the
divergingoffset in d3 is namedsignin recharts)
Modifiers
@public
type SurfaceProps
type Props = Omit<SVGProps<SVGSVGElement>, 'viewBox'> & SurfaceProps;Modifiers
@public
type SymbolsProps
type SymbolsProps = Omit<SVGProps<SVGPathElement>, 'type' | 'fill'> & InnerSymbolsProp;Modifiers
@public
type SymbolType
type SymbolType = | 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';Modifiers
@public
type SyncMethod
type SyncMethod = | 'index' | 'value' | ((ticks: ReadonlyArray<TickItem>, data: MouseHandlerDataParam) => number);Allows customisation of how the charts will synchronize tooltips and brushes. Default: index
'index': other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. 'value': will try to match other charts values custom function: will receive two arguments and should return an index of the active tick in the current chart: argument 1: ticks from the current chart argument 2: active tooltip state from the other chart
Modifiers
@public
type TextAnchor
type TextAnchor = 'start' | 'middle' | 'end' | 'inherit';Modifiers
@public
type TextBackgroundProps
type TextBackgroundProps = Omit< SVGProps<SVGRectElement>, 'x' | 'y' | 'width' | 'height' | 'ref' | 'children' | 'transform'> & { /** * Space between the text and the edge of the background, in pixels. * A number applies the same padding on all sides, an object sets horizontal and vertical padding separately. * * @defaultValue { x: 4, y: 2 } */ padding?: | number | { x?: number; y?: number; }; /** * zIndex layer of the background in a `Label` or `LabelList` inside a chart. * `Text` used on its own ignores it and draws the background right before the text, * because `Text` has no zIndex either. Without knowing which layer the text renders in, * a background in any other layer could end up above its own text, so right before the text is the only safe place. * In a label with a nonzero zIndex, 0 becomes -1, because layer 0 renders inside the label's own layer. * * @defaultValue 100 below the label zIndex, which is `DefaultZIndexes.labelBackground` for default labels */ zIndex?: number;};Props of the shape that is drawn behind the text. Accepts the usual SVG
<rect>attributes, such asfill,fillOpacity,stroke,rxandclassName. Straight text uses a rectangle; text on a path uses a stroked copy of that path. The position and size are measured from the rendered text.3.11
Modifiers
@public
type TextProps
type Props = Omit<SVGProps<SVGTextElement>, 'textAnchor' | 'verticalAnchor'> & TextProps;Modifiers
@public
type TextVerticalAnchor
type TextVerticalAnchor = 'start' | 'middle' | 'end';Modifiers
@public
type TickOrientation
type TickOrientation = 'left' | 'right' | 'middle';Modifiers
@public
type TickProp
type TickProp<T> = TextProps | ReactElement | ((props: T) => ReactNode) | boolean;Modifiers
@public
type TooltipContentProps
type TooltipContentProps< TValue extends ValueType = ValueType, TName extends NameType = NameType> = TooltipProps<TValue, TName> & { label?: string | number; payload: TooltipPayload; coordinate: Coordinate | undefined; active: boolean; accessibilityLayer: boolean; activeIndex: TooltipIndex | undefined;};Modifiers
@public
type TooltipContentType
type ContentType< TValue extends ValueType = ValueType, TName extends NameType = NameType> = ReactElement | ((props: TooltipContentProps<TValue, TName>) => ReactNode);Modifiers
@public
type TooltipIndex
type TooltipIndex = string | null;null means no active index string means: whichever index from the chart data it is. Different charts have different requirements on data shapes, and are also responsible for providing a function that will accept this index and return data.
Modifiers
@public
type TooltipItemSorter
type TooltipItemSorter< TValue extends ValueType = ValueType, TName extends NameType = NameType> = | 'dataKey' | 'value' | 'name' | ((item: Payload<TValue, TName>) => number | string | undefined);Modifiers
@public
type TooltipPayload
type TooltipPayload = ReadonlyArray<TooltipPayloadEntry>;This is what Tooltip renders.
Modifiers
@public
type TooltipProps
type TooltipProps< TValue extends ValueType = ValueType, TName extends NameType = NameType> = Omit<DefaultTooltipContentProps<TValue, TName>, PropertiesReadFromContext> & { /** * If true, then Tooltip is always displayed, once an activeIndex is set by mouse over, or programmatically. * If false, then Tooltip is never displayed. * If undefined, Recharts will control when the Tooltip displays. This includes mouse and keyboard controls. */ active?: boolean; /** * This option allows the tooltip to extend beyond the viewBox of the chart itself. * @defaultValue {"x":false,"y":false} */ allowEscapeViewBox?: AllowInDimension; /** * Specifies the duration of animation, the unit of this option is ms. * @defaultValue 400 */ animationDuration?: AnimationDuration; /** * The type of easing function. * @defaultValue ease */ animationEasing?: EasingInput; /** * Tooltip always attaches itself to the "Tooltip" axis. Which axis is it? Depends on the layout: * - horizontal layout -> X axis * - vertical layout -> Y axis * - radial layout -> radial axis * - centric layout -> angle axis * * Tooltip will use the default axis for the layout, unless you specify an axisId. * * @defaultValue 0 */ axisId?: AxisId; /** * Renders the content of the tooltip. * * This should return HTML elements, not SVG elements. * * - If not set, the {@link DefaultTooltipContent} component is used. * - If set to a React element, this element will be cloned and extra props will be passed in. * - If set to a function, the function will be called and should return HTML elements. * * @see {@link https://recharts.github.io/en-US/examples/CustomContentOfTooltip/ Example with custom content} */ content?: ContentType<TValue, TName>; /** * CSS styles to be applied to the wrapper `div` element. * @defaultValue {} */ contentStyle?: CSSProperties; /** * If set false, no cursor will be drawn when tooltip is active. * If set a object, the option is the configuration of cursor. * If set a React element, the option is the custom react element of drawing cursor. * @defaultValue true */ cursor?: CursorDefinition; defaultIndex?: number | TooltipIndex; /** * When an item of the payload has value null or undefined, this item won't be displayed. * @defaultValue true */ filterNull?: boolean; /** * Function to customize the value in the tooltip. * If you return an array, the first entry will be the formatted "value", and the second entry will be the formatted "name" * * @example <Tooltip formatter={(value) => typeof value === 'number' ? new Intl.NumberFormat('ar', { numberingSystem: 'arab' }).format(value) : String(value)} /> */ formatter?: ( value: TValue, name: TName, item: TooltipPayloadEntry, index: number, payload: TooltipPayload ) => ReactNode | [ReactNode, ReactNode]; /** * If true, the tooltip will display information about hidden series. * Defaults to false. * Interacting with the hide property of Area, Bar, Line, Scatter. * * @defaultValue false */ includeHidden?: boolean | undefined; /** * If set false, animation of tooltip will be disabled. * If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility. * @defaultValue auto */ isAnimationActive?: boolean | 'auto'; /** * Sorts tooltip items. * Defaults to 'name' which means it sorts alphabetically by graphical item `name` property. * @defaultValue name */ itemSorter?: TooltipItemSorter; /** * CSS styles of individual items inside the tooltip, a `<li>` element. * These show the data label (name, or dataKey) and value. * * If a chart has multiple graphical items then the Tooltip renders multiple item * and each of them gets this itemStyle applied. * * @defaultValue {} */ itemStyle?: CSSProperties; /** * The formatter function of label in tooltip. * * @example <Tooltip labelFormatter={(label) => typeof label === 'number' ? new Intl.NumberFormat('ar', { numberingSystem: 'arab' }).format(label) : label} /> */ labelFormatter?: (label: ReactNode, payload: TooltipPayload) => ReactNode; /** * CSS styles of the tooltip title. * Renders once on the top of tooltip and shows categorical axis value. * * Even if there are multiple graphical items in the chart, only one label gets rendered. * * Note that "Label" in tooltip is the header, which is different from {@link Legend} * where "labelStyle" are the individual items. * * @defaultValue {} */ labelStyle?: CSSProperties; /** * The offset size between the position of tooltip and the mouse cursor position. * When a number is provided, the same offset is applied to both x and y axes. * * When a Coordinate object is provided, you can specify different offsets for each axis (x and y as numbers) * @defaultValue 10 */ offset?: number | Coordinate; payloadUniqBy?: UniqueOption<TooltipPayloadEntry>; /** * If portal is defined, then Tooltip will use this element as a target * for rendering using React Portal: https://react.dev/reference/react-dom/createPortal * * If this is undefined then Tooltip renders inside the recharts-wrapper element. */ portal?: HTMLElement | null; /** * If this field is set, the tooltip will be displayed at the specified position * regardless of the mouse position. * * You can set a single field (x or y) and let the other field be calculated automatically based * on the mouse position. */ position?: Partial<Coordinate>; /** * @defaultValue {"x":false,"y":false} */ reverseDirection?: AllowInDimension; /** * The separator between name and value. * @defaultValue ' : ' */ separator?: string; /** * Defines whether the tooltip is reacting to the current data point, * or to all data points at the current axis coordinate. * * - `true`: tooltip will appear on top of all bars on an axis tick. * - `false`: tooltip will appear on individual bars. * * Different chart types allow different modes, and have different defaults. * * @see {@link https://github.com/recharts/recharts/wiki/Tooltip-event-type-and-shared-prop Tooltip event type and shared prop wiki page} */ shared?: boolean; /** * If `hover` then the Tooltip shows on mouse enter and hides on mouse leave. * * If `click` then the Tooltip shows after clicking and stays active. * * @defaultValue hover */ trigger?: TooltipTrigger; /** * @defaultValue false */ useTranslate3d?: boolean; /** * CSS styles to be applied to the wrapper `div` element. */ wrapperStyle?: CSSProperties;};Modifiers
@public
type TooltipTrigger
type TooltipTrigger = 'hover' | 'click';Modifiers
@public
type TooltipValueType
type ValueType = number | string | ReadonlyArray<number | string>;Modifiers
@public
type TouchPointer
type TouchPointer = HTMLTouchPointer | SVGTouchPointer;Modifiers
@public
type TrapezoidProps
type Props = Omit<SVGProps<SVGPathElement>, 'fill'> & TrapezoidProps;Modifiers
@public
type TreemapContentType
type TreemapContentType = ReactNode | ((props: TreemapNode) => React.ReactElement);Modifiers
@public
type TypedCentricChartContext
type TypedCentricChartContext<TData, TCategorical, TNumerical, TComponents> = { RadarChart: React.ComponentType<Omit<PolarChartProps<TData>, 'layout'>>;} & Omit< { [K in keyof TComponents]: K extends 'PolarAngleAxis' ? React.ComponentType<PolarAngleAxisProps<TData, TCategorical>> : K extends 'PolarRadiusAxis' ? React.ComponentType<PolarRadiusAxisProps<TData, TNumerical>> : K extends 'RadialBar' ? React.ComponentType<RadialBarProps<TData, TNumerical>> : K extends 'Radar' ? React.ComponentType<RadarProps<TData, TNumerical>> : K extends 'Pie' ? React.ComponentType<PieProps<TData, TNumerical>> : K extends 'Tooltip' ? React.ComponentType< TooltipProps< Extract<TNumerical, ValueType>, Extract<keyof TData, NameType> > > : TComponents[K]; }, 'RadialBar' | 'RadialBarChart' | 'Pie' | 'PieChart'>;Modifiers
@public
type TypedHorizontalChartContext
type TypedHorizontalChartContext<TData, TCategorical, TNumerical, TComponents> = { AreaChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; BarChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; LineChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; ComposedChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; ScatterChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>;} & Omit< { [K in keyof TComponents]: K extends 'XAxis' ? React.ComponentType<XAxisProps<TData, TCategorical>> : K extends 'YAxis' ? React.ComponentType<YAxisProps<TData, TNumerical>> : K extends 'ZAxis' ? React.ComponentType<ZAxisProps<TData, TNumerical>> : K extends 'Area' ? React.ComponentType<AreaProps<TData, TNumerical>> : K extends 'Bar' ? React.ComponentType<BarProps<TData, TNumerical>> : K extends 'Line' ? React.ComponentType<LineProps<TData, TNumerical>> : K extends 'Scatter' ? React.ComponentType<ScatterProps<TData, TNumerical>> : K extends 'Tooltip' ? React.ComponentType< TooltipProps< Extract<TNumerical, ValueType>, Extract<keyof TData, NameType> > > : TComponents[K]; }, 'Funnel' | 'FunnelChart'>;Modifiers
@public
type TypedRadialChartContext
type TypedRadialChartContext<TData, TCategorical, TNumerical, TComponents> = { RadialBarChart: React.ComponentType<Omit<PolarChartProps<TData>, 'layout'>>; PieChart: React.ComponentType<Omit<PolarChartProps<TData>, 'layout'>>;} & Omit< { [K in keyof TComponents]: K extends 'PolarAngleAxis' ? React.ComponentType<PolarAngleAxisProps<TData, TNumerical>> : K extends 'PolarRadiusAxis' ? React.ComponentType<PolarRadiusAxisProps<TData, TCategorical>> : K extends 'RadialBar' ? React.ComponentType<RadialBarProps<TData, TNumerical>> : K extends 'Radar' ? React.ComponentType<RadarProps<TData, TNumerical>> : K extends 'Pie' ? React.ComponentType<PieProps<TData, TNumerical>> : K extends 'Tooltip' ? React.ComponentType< TooltipProps< Extract<TNumerical, ValueType>, Extract<keyof TData, NameType> > > : TComponents[K]; }, 'Radar' | 'RadarChart'>;Modifiers
@public
type TypedVerticalChartContext
type TypedVerticalChartContext<TData, TCategorical, TNumerical, TComponents> = { AreaChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; BarChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; LineChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; ComposedChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; ScatterChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>; FunnelChart: React.ComponentType<Omit<CartesianChartProps<TData>, 'layout'>>;} & { [K in keyof TComponents]: K extends 'XAxis' ? React.ComponentType<XAxisProps<TData, TNumerical>> : K extends 'YAxis' ? React.ComponentType<YAxisProps<TData, TCategorical>> : K extends 'ZAxis' ? React.ComponentType<ZAxisProps<TData, TNumerical>> : K extends 'Area' ? React.ComponentType<AreaProps<TData, TNumerical>> : K extends 'Bar' ? React.ComponentType<BarProps<TData, TNumerical>> : K extends 'Line' ? React.ComponentType<LineProps<TData, TNumerical>> : K extends 'Scatter' ? React.ComponentType<ScatterProps<TData, TNumerical>> : K extends 'Funnel' ? React.ComponentType<FunnelProps<TData, TNumerical>> : K extends 'Tooltip' ? React.ComponentType< TooltipProps< Extract<TNumerical, ValueType>, Extract<keyof TData, NameType> > > : TComponents[K];};Modifiers
@public
type UniqueOption
type UniqueOption<T> = boolean | UniqueFunc<T>;This is configuration option that decides how to filter for unique values only:
-
falsemeans "no filter" -truemeans "use recharts default filter" - function means "use return of this function as the default key"Modifiers
@public
type Unit
type Unit = string | number;A unit to be appended to a value
Modifiers
@public
type VerticalAlignmentType
type VerticalAlignmentType = 'top' | 'bottom' | 'middle';Modifiers
@public
type ViewBox
type ViewBox = CartesianViewBoxRequired | PolarViewBoxRequired;Modifiers
@public
type WithFillObject
type WithFillObject<T> = Omit<T, 'fill'> & { /** * A color, or a {@link RechartsFill} object with an SVG definition, such as a pattern or a gradient. */ fill?: string | RechartsFill;};The object form of a shape option, where
fillcan be a RechartsFill object too. Recharts renders these options with its shape components, which paint fill objects with their own definition.3.11
Modifiers
@public
type XAxisOrientation
type XAxisOrientation = 'top' | 'bottom';Modifiers
@public
type XAxisPadding
type XAxisPadding = | { left?: number; right?: number; } | 'gap' | 'no-gap';Modifiers
@public
type XAxisProps
type Props<DataPointType = any, DataValueType = any> = Omit< PresentationAttributesAdaptChildEvent<TickItem, SVGTextElement>, 'scale' | 'ref' | 'height'> & XAxisProps<DataPointType, DataValueType>;Modifiers
@public
type XAxisTickContentProps
type XAxisTickContentProps = BaseTickContentProps & { orientation: XAxisOrientation; padding: XAxisPadding | undefined;};Modifiers
@public
type YAxisOrientation
type YAxisOrientation = 'left' | 'right';Modifiers
@public
type YAxisPadding
type YAxisPadding = | { top?: number; bottom?: number; } | 'gap' | 'no-gap';Modifiers
@public
type YAxisProps
type Props<DataPointType = any, DataValueType = any> = Omit< PresentationAttributesAdaptChildEvent<TickItem, SVGTextElement>, 'scale' | 'ref'> & YAxisProps<DataPointType, DataValueType>;Modifiers
@public
type YAxisTickContentProps
type YAxisTickContentProps = BaseTickContentProps & { orientation: YAxisOrientation; padding: YAxisPadding | undefined;};Modifiers
@public
type YAxisWidth
type YAxisWidth = number | 'auto';Modifiers
@public
Namespaces
namespace Brush
namespace Brush {}variable displayName
var displayName: string;namespace CartesianGrid
namespace CartesianGrid {}variable displayName
var displayName: string;namespace Customized
namespace Customized {}variable displayName
var displayName: string;namespace ErrorBar
namespace ErrorBar {}variable displayName
var displayName: string;namespace Label
namespace Label {}variable displayName
var displayName: string;namespace LabelList
namespace LabelList {}variable displayName
var displayName: string;namespace PolarAngleAxis
namespace PolarAngleAxis {}variable displayName
var displayName: string;namespace PolarRadiusAxis
namespace PolarRadiusAxis {}variable displayName
var displayName: string;namespace Radar
namespace Radar {}variable displayName
var displayName: string;namespace RadialBar
namespace RadialBar {}variable displayName
var displayName: string;namespace ReferenceArea
namespace ReferenceArea {}variable displayName
var displayName: string;namespace ReferenceDot
namespace ReferenceDot {}variable displayName
var displayName: string;namespace ReferenceLine
namespace ReferenceLine {}variable displayName
var displayName: string;namespace Sankey
namespace Sankey {}variable displayName
var displayName: string;namespace ZAxis
namespace ZAxis {}variable displayName
var displayName: string;Package Files (100)
- types/animation/AnimatedItems.d.ts
- types/animation/AnimationController.d.ts
- types/animation/AnimationHandle.d.ts
- types/animation/easing.d.ts
- types/animation/matchBy.d.ts
- types/animation/timeoutController.d.ts
- types/animation/useAnimationController.d.ts
- types/cartesian/Area.d.ts
- types/cartesian/AreaRevealShape.d.ts
- types/cartesian/Bar.d.ts
- types/cartesian/BarStack.d.ts
- types/cartesian/Brush.d.ts
- types/cartesian/CartesianAxis.d.ts
- types/cartesian/CartesianGrid.d.ts
- types/cartesian/ErrorBar.d.ts
- types/cartesian/Funnel.d.ts
- types/cartesian/Line.d.ts
- types/cartesian/LineDrawShape.d.ts
- types/cartesian/ReferenceArea.d.ts
- types/cartesian/ReferenceDot.d.ts
- types/cartesian/ReferenceLine.d.ts
- types/cartesian/Scatter.d.ts
- types/cartesian/XAxis.d.ts
- types/cartesian/YAxis.d.ts
- types/cartesian/ZAxis.d.ts
- types/cartesian/getCartesianPosition.d.ts
- types/chart/AreaChart.d.ts
- types/chart/BarChart.d.ts
- types/chart/ComposedChart.d.ts
- types/chart/FunnelChart.d.ts
- types/chart/LineChart.d.ts
- types/chart/PieChart.d.ts
- types/chart/RadarChart.d.ts
- types/chart/RadialBarChart.d.ts
- types/chart/Sankey.d.ts
- types/chart/ScatterChart.d.ts
- types/chart/SunburstChart.d.ts
- types/chart/Treemap.d.ts
- types/chart/types.d.ts
- types/component/Cell.d.ts
- types/component/Cursor.d.ts
- types/component/Customized.d.ts
- types/component/DefaultLegendContent.d.ts
- types/component/DefaultTooltipContent.d.ts
- types/component/Label.d.ts
- types/component/LabelList.d.ts
- types/component/Legend.d.ts
- types/component/ResponsiveContainer.d.ts
- types/component/Text.d.ts
- types/component/Tooltip.d.ts
- types/container/Layer.d.ts
- types/container/Surface.d.ts
- types/context/chartLayoutContext.d.ts
- types/fill/RechartsFill.d.ts
- types/fill/fillDefinitions.d.ts
- types/hooks.d.ts
- types/index.d.ts
- types/polar/Pie.d.ts
- types/polar/PolarAngleAxis.d.ts
- types/polar/PolarGrid.d.ts
- types/polar/PolarRadiusAxis.d.ts
- types/polar/Radar.d.ts
- types/polar/RadialBar.d.ts
- types/shape/Cross.d.ts
- types/shape/Curve.d.ts
- types/shape/Dot.d.ts
- types/shape/Polygon.d.ts
- types/shape/Rectangle.d.ts
- types/shape/Sector.d.ts
- types/shape/Symbols.d.ts
- types/shape/Trapezoid.d.ts
- types/state/cartesianAxisSlice.d.ts
- types/state/selectors/areaSelectors.d.ts
- types/state/selectors/axisSelectors.d.ts
- types/state/tooltipSlice.d.ts
- types/synchronisation/types.d.ts
- types/theme/RechartsTheme.d.ts
- types/theme/RechartsThemeContext.d.ts
- types/theme/autoTheme.d.ts
- types/theme/darkTheme.d.ts
- types/theme/emptyTheme.d.ts
- types/theme/lightTheme.d.ts
- types/types.d.ts
- types/util/BarUtils.d.ts
- types/util/ChartUtils.d.ts
- types/util/DataUtils.d.ts
- types/util/Global.d.ts
- types/util/IfOverflow.d.ts
- types/util/RadialBarUtils.d.ts
- types/util/ScatterUtils.d.ts
- types/util/createCartesianCharts.d.ts
- types/util/createPolarCharts.d.ts
- types/util/getRelativeCoordinate.d.ts
- types/util/payload/getUniqPayload.d.ts
- types/util/scale/CustomScaleDefinition.d.ts
- types/util/scale/RechartsScale.d.ts
- types/util/scale/getNiceTickValues.d.ts
- types/util/types.d.ts
- types/zIndex/DefaultZIndexes.d.ts
- types/zIndex/ZIndexLayer.d.ts
Dependencies (10)
Dev Dependencies (96)
- @arethetypeswrong/cli
- @babel/cli
- @babel/core
- @babel/preset-env
- @babel/preset-react
- @babel/preset-typescript
- @babel/runtime
- @chromatic-com/storybook
- @codecov/bundle-analyzer
- @eslint-community/eslint-plugin-eslint-comments
- @eslint/compat
- @eslint/js
- @flakiness/playwright
- @playwright/test
- @recharts/devtools
- @reduxjs/toolkit
- @rollup/plugin-babel
- @rollup/plugin-commonjs
- @rollup/plugin-node-resolve
- @stackblitz/sdk
- @storybook/addon-a11y
- @storybook/addon-docs
- @storybook/addon-links
- @storybook/addon-onboarding
- @storybook/addon-vitest
- @storybook/builder-vite
- @storybook/icons
- @storybook/react-vite
- @stryker-mutator/typescript-checker
- @stryker-mutator/vitest-runner
- @testing-library/jest-dom
- @testing-library/react
- @testing-library/user-event
- @types/d3-interpolate
- @types/d3-shape
- @types/d3-time-format
- @types/node
- @types/react
- @types/react-dom
- @types/react-is
- @vitejs/plugin-react
- @vitest/browser-playwright
- @vitest/coverage-v8
- babel-loader
- babel-plugin-dev-expression
- babel-plugin-transform-define
- browserslist
- bundlewatch
- chromatic
- cross-env
- d3-scale-chromatic
- d3-time
- d3-time-format
- diff
- eslint
- eslint-config-airbnb-extended
- eslint-config-prettier
- eslint-import-resolver-typescript
- eslint-plugin-import
- eslint-plugin-jsdoc
- eslint-plugin-jsx-a11y
- eslint-plugin-prettier
- eslint-plugin-react
- eslint-plugin-react-hooks
- eslint-plugin-react-perf-x
- eslint-plugin-storybook
- glob
- globals
- husky
- jsdom
- lint-staged
- marked
- playwright
- prettier
- publint
- react
- react-dom
- react-is
- react-redux
- rimraf
- rollup
- rollup-plugin-esbuild
- storybook
- terser
- terser-webpack-plugin
- ts-loader
- ts-morph
- typescript
- typescript-eslint
- update-browserslist-db
- vite
- vitest
- vitest-axe
- webpack
- webpack-bundle-analyzer
- webpack-cli
Peer Dependencies (4)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/recharts.
- Markdown[](https://www.jsdocs.io/package/recharts)
- HTML<a href="https://www.jsdocs.io/package/recharts"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 11480 ms. - Missing or incorrect documentation? Open an issue for this package.
