Charts - Range Bar
Use range bar charts to show the span between minimum and maximum values across categories.
Overview
A range bar chart displays the span between two values for each category.
Each bar extends from a lower to an upper value. This chart type works well for visualizing data like temperature ranges, project timelines, or performance intervals.
Basics
To create a range bar chart, render BarChartPremium with at least one series of type 'rangeBar'.
Each data point in a range bar series consists of a { start: number, end: number } object.
Average monthly temperature ranges in °C for Porto and Berlin in 1991-2020
- Porto, Portugal
- Berlin, Germany
Customization
Grid
You can add a grid in the background of the chart with the grid prop.
See Axis—Grid for details.
Border radius
To achieve rounded corners, set the borderRadius prop on BarChartPremium to any positive value.
When composing a custom component, set the borderRadius prop on the RangeBarPlot component.
Border Radius
<BarChartPremium
// ...
borderRadius={10}
/>Color
You can set series colors for individual series or use the color palette.
Use a colorMap to map values to colors.
The color set by colorMap has priority over other color settings.
See Styling—Value-based colors for more details on colorMap.
<BarChart
/* ... */
xAxis={[{
colorMap: {
type: 'piecewise',
thresholds: [new Date(2021, 1, 1), new Date(2023, 1, 1)],
colors: ['blue', 'red', 'blue'],
}
}]}
/>CSS
You can customize the range bar chart elements using CSS selectors.
Like a bar chart, each series renders a g element that contains a data-series attribute.
You can use this attribute to target elements based on their series.
Click event
The click event handlers work similarly to bar charts. See Bars—Click events for details.
- A
- B
Click on the chart
// Data from item click
// The data will appear here
// Data from axis click
// The data will appear hereAnimation
Animation works similarly to bar charts. See Bars—Animation for details.
- series 1
- series 2
Number of items
Number of series
Composition
Use ChartDataProviderPremium to provide series, xAxis, and yAxis props for composition.
In addition to the shared chart components available for composition, you can render the RangeBarPlot component to display the range bars and their labels.
The example below shows how BarChartPremium is composed:
<ChartsDataProviderPremium>
<ChartsWrapper>
<ChartsLegend />
<ChartsSurface>
<ChartsGrid />
<g clipPath={`url(#${clipPathId})`}>
<BarPlot />
<RangeBarPlot />
<ChartsOverlay />
<ChartsAxisHighlight />
<FocusedBar />
<FocusedRangeBar />
</g>
<ChartsAxis />
<ChartsClipPath id={clipPathId} />
</ChartsSurface>
<ChartsTooltip />
</ChartsWrapper>
</ChartsDataProviderPremium>
The example below follows a similar pattern and creates a project schedule chart using range bars to represent task durations.
API
See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.