Docs
📊 ⏐ Charts
Bar Chart

Bar Chart

A bar chart uses rectangular bars to show values, with one axis for categories and the other for values. It's great for visualizing data like months, age groups, or product types. Bar charts help compare different categories and track trends over time. With REAVIZ, you can easily create and customize bar charts to suit your data visualization needs!

Types supported by reaviz:

Where to use:

  • Compare Quantities: Compare different categories, like sales figures.
  • Highlight Largest/Smallest Categories: Identify categories with highest or lowest values.
  • Visualize Categorical Data: Display distinct categories, such as age groups or product types.

Quick Start

To create a Bar chart, use import the BarChart and give it data. The chart will automatically configure itself with the default options exposed via props.

Examples

Single Series Vertical

Single Series Horizontal

Multi Series Vertical

Multi Series Horizontal

Stacked Vertical

Stacked Horizontal

Stacked Normalized Vertical

Stacked Normalized Horizontal

Stacked Diverging Vertical

Stacked Diverging Horizontal

Marimekko

Sparkline

Waterfall

Histograms

Customization

Customize the Bar Chart using various props:

  • colorScheme: Array of colors for the chart.
  • gridlines: Toggle gridlines on or off.
  • bar: Customize the appearance of the bars.
  • legend and tooltips: Add legends and tooltips for better data interpretation.

API

BarChart (opens in a new tab)

PropDescriptionDefault
dataData the chart will receive to render.
ChartDataShape[]
seriesThe series component that renders the bar components.
ReactElement<BarSeriesProps, FC<Partial<BarSeriesProps>>>
yAxisThe linear axis component for the Y Axis of the chart.
ReactElement<LinearAxisProps, FC<Partial<LinearAxisProps>>>
xAxisThe linear axis component for the X Axis of the chart.
ReactElement<LinearAxisProps, FC<Partial<LinearAxisProps>>>
gridlinesThe chart's background gridlines component.
ReactElement<GridlineSeriesProps, FC<Partial<GridlineSeriesProps>>>
brushThe chart's brush component.
ReactElement<ChartBrushProps, FC<Partial<ChartBrushProps>>>
secondaryAxisAny secondary axis components. Useful for multi-axis charts.
ReactElement<LinearAxisProps, FC<Partial<LinearAxisProps>>>[]
idId of the chart.
string
widthWidth of the chart. If not provided will autosize.
number
heightHeight of the chart. If not provided will autosize.
number
marginsMargins for the chart.
Margins
classNameClassnames for the chart.
string
containerClassNameClassnames for the chart.
string
styleAdditional css styles.
StyleHTMLAttributes<SVGSVGElement>
centerCenter the chart. Used mainly internally.
boolean
centerXCenter chart on X Axis only. Used mainly internally.
boolean
centerYCenter chart on Y Axis only. Used mainly internally.
boolean

BarSeries (opens in a new tab)

PropDescriptionDefault
dataParsed data shape. Set internally by `BarChart`.
ChartInternalDataShape[]
idId of the bar chart. Set internally by `BarChart`.
string
xScaleD3 scale for X Axis. Set internally by `BarChart`.
any
yScaleD3 scale for Y Axis. Set internally by `BarChart`.
any
xScale1D3 scale for X Multi-Group Axis. Set internally by `BarChart`.
any
barBar element.
BarElement | BarElement[]
typeType of the chart.
BarType
colorSchemeColor scheme for the chart.
ColorSchemeType
animatedWhether the chart is animated or not.
boolean
paddingAmount of padding between each bar.
number
groupPaddingAmount of padding between each group.
number
isCategoricalWhether the chart is categorical or not. Set internally by `BarChart`.
boolean
layoutDirection of the chart
Direction
binSizeThe size of each bin/bucket in the bar chart.
number
heightHeight of the chart. Set internally by `BarChart`.
number
widthWidth of the chart. Set internally by `BarChart`.
number
tooltipTooltip for the chart area.
ReactElement<TooltipAreaProps, ForwardRefExoticComponent<Partial<TooltipAreaProps> & RefAttributes<any>>>
valueMarkersValue markers line for the chart.
ReactElement<LinearValueMarkerProps, FC<LinearValueMarkerProps>>[]

Bar (opens in a new tab)

PropDescriptionDefault
activeWhether the bar is active or not.
boolean
activeBrightnessChroma brightness factor to brighten the active bar. See https://gka.github.io/chroma.js/#color-brighten for more info.
number
xScaleD3 scale for X Axis. Set internally by `BarChart`.
any
yScaleD3 scale for Y Axis. Set internally by `BarChart`.
any
xScale1D3 scale for X Multi-Group Axis. Set internally by `BarChart`.
any
dataParsed data shape. Set internally by `BarChart`.
ChartInternalShallowDataShape
idId set internally by `BarChart`.
string
gradientGradient shades for the bar.
ReactElement<GradientProps, FC<Partial<GradientProps>>>
rxSVG rx attribute for the bar.
number
rySVG ry attribute for the bar.
number
widthWidth of the bar. Set internally by `BarSeries`.
number
paddingPadding for the bar groups.
number
barCountTotal number of bars used for animation. Set internally by `BarSeries`.
number
colorColor callback for the bar.
any
cursorCursor for the bar element.
string
barIndexIndex of the bar. Set internally by `BarSeries`.
number
groupIndexIndex of the group. Set internally by `BarSeries`.
number
animatedWhether to animate the enter/update/exit. Set internally by `BarSeries`.
boolean
isCategoricalWhether this is categorical chart or not. Set internally by `BarSeries`.
boolean
rangeLinesRangelines element. for the bar.
ReactElement<RangeLinesProps, FC<Partial<RangeLinesProps>>>
maskMask element for the bar.
ReactElement<MaskProps, FC<MaskProps>>
tooltipTooltip element.
ReactElement<ChartTooltipProps, FC<Partial<ChartTooltipProps>>>
layoutDirection of the chart. Set internally by `BarSeries`.
Direction
typeType of bar chart. Set internally by `BarSeries`.
BarType
labelLabel element.
ReactElement<BarLabelProps, FC<Partial<BarLabelProps>>>
guideGuide bar component.
ReactElement<GuideBarProps, FC<Partial<GuideBarProps>>>
minHeightForce a min height on the bar.
number
glowGlow styling for the bar.
Glow
onClickEvent for when the bar is clicked.
(event: ClickEvent) => void
onMouseEnterEvent for when the bar has mouse enter.
(event: any) => void
onMouseLeaveEvent for when the bar has mouse leave.
(event: any) => void
onMouseMoveEvent for when a bar has mouse move.
(event: any) => void
classNameClassnames to apply to the element.
any
styleCSS styles to apply to the element.
any

GuideBar (opens in a new tab)

PropDescriptionDefault
activeWhether the guide bar is active.
boolean
fillFill for the guide bar element.
string
#eee
opacityOpacity for the guide bar element.
number
0.15
height
number
width
number
x
number
y
number
bottom
number
left
number
right
number
top
number
toJSON
() => any

RangeLines (opens in a new tab)

PropDescriptionDefault
heightHeight of the bar.
number
widthWidth of the bar.
number
xSVG x attribute for the bar.
number
ySVG y attribute for the bar.
number
indexGroup index or index of the bar. Set internally by `BarSeries`.
number
strokeWidthStroke width of the range line.
number
1
scaleD3 scale for Axis. Set internally by `BarChart`.
any
positionPosition of the range line.
"top" | "bottom"
top
dataParsed data shape. Set internally by `BarChart`.
ChartInternalShallowDataShape
colorColor for the range line.
string
barCountTotal number of bars used for animation. Set internally by `BarSeries`.
number
layoutDirection of the chart. Set internally by `BarSeries`.
Direction
vertical
animatedWhether to animate the enter/update/exit. Set internally by `BarSeries`.
boolean
typeType of bar chart. Set internally by `BarSeries`.
BarType

BarLabel (opens in a new tab)

PropDescriptionDefault
textText of the label. Set internally by `Bar`.
string
heightHeight of the bar.
number
widthWidth of the bar.
number
xSVG x attribute for the bar.
number
ySVG y attribute for the bar.
number
indexGroup index or index of the bar. Set internally by `BarSeries`.
number
scaleD3 scale for Axis. Set internally by `BarChart`.
any
positionPosition of the label.
"top" | "center" | "bottom"
dataParsed data shape. Set internally by `BarChart`.
ChartInternalShallowDataShape
fillColor of the text.
string
barCountNumber of the bars in the bar group. Set internally by `BarSeries`.
number
layoutLayout of bar chart to render. Set internally by `BarSeries`.
Direction
animatedWhether to animate the enter/update/exit. Set internally by `BarSeries`.
boolean
typeType of bar chart to render. Set internally by `BarSeries`.
BarType
fontSizeFont size of the text.
number
fontFamilyFont family of the text.
string
paddingPadding of the label.
number
classNameClass name to apply to the text.
any