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:
- Single Series Vertical / Horizontal
- Multi Series Vertical / Horizontal
- Target Markers Vertical / Horizontal
- Stacked Vertical / Horizontal
- Stacked Normalized Vertical / Horizontal
- Stacked Diverging Vertical / Horizontal
- Marimekko
- Sparkline
- Waterfall
- Histograms
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
Target Markers Vertical
Target Markers 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Β
BarSeriesΒ
BarΒ
| Name | Type | Default |
|---|---|---|
active | booleanWhether the bar is active or not. | |
activeBrightness | numberChroma brightness factor to brighten the active bar. See https://gka.github.io/chroma.js/#color-brightenΒ for more info. | 0.5 |
xScale | anyD3 scale for X Axis. Set internally by | |
yScale | anyD3 scale for Y Axis. Set internally by | |
xScale1 | anyD3 scale for X Multi-Group Axis. Set internally by | |
data | ChartInternalShallowDataShapeParsed data shape. Set internally by | |
id | stringId set internally by | |
gradient | ReactElement<GradientProps, FC<Partial<GradientProps>>> | nullGradient shades for the bar. | `<Gradient />` |
rx | numberSVG rx attribute for the bar. | 0 |
ry | numberSVG ry attribute for the bar. | 0 |
width | numberWidth of the bar. Set internally by | |
padding | numberPadding for the bar groups. | |
barCount | numberTotal number of bars used for animation. Set internally by | |
color | anyColor callback for the bar. | |
cursor | stringCursor for the bar element. | 'auto' |
barIndex | numberIndex of the bar. Set internally by | |
groupIndex | numberIndex of the group. Set internally by | |
animated | booleanWhether to animate the enter/update/exit. Set internally by | |
isCategorical | booleanWhether this is categorical chart or not. Set internally by | |
rangeLines | ReactElement<RangeLinesProps, FC<Partial<RangeLinesProps>>> | nullRangelines element. for the bar. | |
mask | ReactElement<MaskProps, FC<MaskProps>> | nullMask element for the bar. | |
tooltip | ReactElement<ChartTooltipProps, FC<Partial<ChartTooltipProps>>> | nullTooltip element. | |
layout | DirectionDirection of the chart. Set internally by | 'vertical' |
type | BarTypeType of bar chart. Set internally by | |
label | ReactElement<BarLabelProps, FC<Partial<BarLabelProps>>> | nullLabel element. | |
targetMarker | ReactElement<BarTargetMarkerProps, FC<Partial<BarTargetMarkerProps>>> | nullTarget marker element. | `<BarTargetMarker />` |
guide | ReactElement<GuideBarProps, FC<Partial<GuideBarProps>>> | nullGuide bar component. | |
minHeight | numberForce a min height on the bar. | |
glow | GlowGlow styling for the bar. | |
onClick | (event: ClickEvent) => voidEvent for when the bar is clicked. | |
onMouseEnter | (event: any) => voidEvent for when the bar has mouse enter. | |
onMouseLeave | (event: any) => voidEvent for when the bar has mouse leave. | |
onMouseMove | (event: any) => voidEvent for when a bar has mouse move. | |
className | anyClassnames to apply to the element. | |
style | anyCSS styles to apply to the element. |
GuideBarΒ
| Name | Type | Default |
|---|---|---|
active | booleanWhether the guide bar is active. | |
fill | stringFill for the guide bar element. | '#eee' |
opacity | numberOpacity for the guide bar element. | 0.15 |