Renders a group of rectangles in a Cartesian chart.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/recharts/recharts/llms.txt
Use this file to discover all available pages before exploring further.
Usage
Props
The key or getter function of a group of data which should be displayed in the bar.
The fill color of bars.
The stroke color of bars.
The width of the stroke.
The width or height of each bar. If the barSize is not specified, the size of bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
The maximum width of bar in a horizontal chart, or maximum height in a vertical chart.
The minimal height of a bar in a horizontal chart, or the minimal width of a bar in a vertical chart.By default, 0 values are not shown.
To visualize a 0 (or close to zero) point, set the minimal point size to a pixel value like 3.In stacked bar charts, minPointSize might not be respected for tightly packed values.
So we strongly recommend not using this props in stacked BarChart.You may provide a function to conditionally change this prop based on Bar value.
When two Bars have the same axisId and same stackId, then the two Bars are stacked in the chart.
The radius of corners.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.
If set a ReactElement, the shape of bar can be customized.
If set a function, the function will be called to render customized shape.
By default, renders a rectangle.
The active bar is shown when a user enters a bar chart and this chart has tooltip. Options:
false: all bars are passive, nothing happens on mouse eventstrue: active bar is rendered separately but the default props are the same as othersobject: the props of active barReactElement: the active bar elementfunction: a render function of active bar
Renders a background for each bar. Options:
false: no backgroundtrue: renders default backgroundobject: the props of background rectangleReactElement: a custom background elementfunction: a render function of custom background
Renders one label for each bar. Options:
true: renders default labelsfalse: no labels are renderedobject: the props of LabelList componentReactElement: a custom label elementfunction: a render function of custom label
Hides the whole graphical element when true.Hiding an element is different from removing it from the chart:
Hidden graphical elements are still visible in Legend,
and can be included in axis domain calculations,
depending on
includeHidden props of your XAxis/YAxis.The name of data.
This option will be used in tooltip and legend to represent a bar.
If no value was set to this option, the value of dataKey will be used alternatively.
The unit of data. This option will be used in tooltip.
The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.
The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.
The type of icon in legend. If set to ‘none’, no legend item will be rendered.
The type of tooltip item.
Animation props
If set false, animation of bar 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.
Specifies when the animation should begin, the unit of this option is ms.
Specifies the duration of animation, the unit of this option is ms.
The type of easing function.
The customized event handler of animation start.
The customized event handler of animation end.
Event handlers
The customized event handler of click on the bars in this group.
The customized event handler of mouseenter on the bars in this group.
The customized event handler of mouseleave on the bars in this group.
The customized event handler of mousemove on the bars in this group.
The customized event handler of mousedown on the bars in this group.
The customized event handler of mouseup on the bars in this group.
The customized event handler of mouseover on the bars in this group.
The customized event handler of mouseout on the bars in this group.
Layout props
The unique identifier of this component.
Used as an HTML attribute
id, and also to identify this element internally.If undefined, Recharts will generate a unique ID automatically.Z-Index of this component and its children. The higher the value,
the more on top it will be rendered.
Components with higher zIndex will appear in front of components with lower zIndex.
If undefined or 0, the content is rendered in the default layer without portals.@since 3.4
CSS class name for styling.
Source
https://github.com/recharts/recharts/blob/main/src/cartesian/Bar.tsx