Still have questions?
Contact support

Range Bar Chart

Overview

A range bar chart displays information as a range of data by plotting two Y-values (low and high) per data point. The vertical axis shows the values, and the horizontal axis shows the categories they belong to. So, the range bar chart is a vertical version of the range column chart. In multi-series range bar charts, values are grouped by categories.

This type is sometimes referred to as the floating bar chart since it looks like a set of bar "floating" above the horizontal axis. It is used to show the difference between high and low values while visualizing time-based data or showing comparison among categories.

This article explains how to create a basic Range Bar chart as well as configure settings that are specific to the type. You can also see the table below to get a brief overview of the Range Bar chart's characteristics:

API
Classanychart.core.cartesian.series.RangeBar
DATA
Data Fieldsx, value
Multiple SeriesYES
OPTIONS
StackedN/A
VerticalRange Bar
3DN/A
Error BarsN/A
SUPPORTED CHART PLOTS
PolarN/A
RadarN/A
ScatterN/A
StockN/A
RELATED TYPES
Column
Bar
Range Column
SEE ALSO
Chartopedia: Range Bar Chart
General Settings

Quick Start

To create a Range Bar chart, use the rangeBar() method (before, of course, you should create a chart by using anychart.bar() or any other cartesian chart constructor).

Since range bar charts plot two Y-values per data point, you need to specify two values for each category by using the "low" and "high" parameters. That is how it looks like in object notation:

var data = [
  {x: "January", low: 0.7, high: 6.1},
  {x: "February", low: 0.6, high: 6.3},
  {x: "March", low: 1.9, high: 8.5},
  {x: "April", low: 3.1, high: 10.8},
  {x: "May", low: 5.7, high: 14.4}
];

The following sample demonstrates how a basic Range Bar chart is created:

// create a data set
var data = anychart.data.set([
  ["January", 0.7, 6.1],
  ["February", 0.6, 6.3],
  ["March", 1.9, 8.5],
  ["April", 3.1, 10.8],
  ["May", 5.7, 14.4]
]);

// create a chart
var chart = anychart.bar();

// create a range bar series and set the data
var series = chart.rangeBar(data);

// set the container id
chart.container("container");

// initiate drawing the chart
chart.draw();

JsFiddle Playground

General Settings

In AnyChart there are many settings that are configured in the same way for all chart types, including the Range Bar chart (for example, legend and interactivity settings).

Read the overview of general settings: General Settings.

Special Settings

Appearance

Here is a full list of methods used to configure visual settings that are available for the Range Bar series:

You can learn more from the Appearance Settings section.

In the sample below, there are two Range Bar series with some of the appearance settings configured:

// create the first series
var series1 = chart.RangeBar(seriesData_1);

// configure the visual settings of the first series
series1.fill("#00cc99", 0.3);
series1.hoverFill("#00cc99", 0.3);
series1.selectFill("#00cc99", 0.5);
series1.stroke("#00cc99", 1, "10 5", "round");
series1.hoverStroke("#00cc99", 2, "10 5", "round");
series1.selectStroke("#00cc99", 4, "10 5", "round");

// create the second series
var series2 = chart.RangeBar(seriesData_2);

// configure the visual settings of the second series
series2.fill("#0066cc", 0.3);
series2.hoverFill("#0066cc", 0.3);
series2.selectFill("#0066cc", 0.5);
series2.hatchFill("zigzag", "#808080", 1, 15);
series2.stroke("#0066cc");
series2.hoverStroke("#0066cc", 2);
series2.selectStroke("#0066cc", 4);

JsFiddle Playground

If you use object notation to set the data, you can change the appearance (and some other settings) of particular bars by adding special fields to the data set:

// create a data set
var data = anychart.data.set([
  {x: "January", low: 0.7, high: 6.1},
  {x: "February", low: 0.6, high: 6.3},
  {x: "March", low: 1.9, high: 8.5},
  {x: "April", low: 3.1, high: 10.8},
  {x: "May", low: 5.7, high: 14.4, fill: "#5cd65c", stroke: null, label: {enabled: true}}
]);

JsFiddle Playground

If you use an array to set the data, you can also configure the appearance of each bar separately, but in a slightly different way. You should first add visual parameters to the data set and then map fields for them so that they can be interpreted by the component:

// create a data set
var data = anychart.data.set([
  ["January", 0.7, 6.1, 8.1, 12.6],
  ["February", 0.6, 6.3, 8.5, 12.2],
  ["March", 1.9, 8.5, 10.3, 13.1],
  ["April", 3.1, 10.8, 13.4, 15.9],
  ["May", 5.7, 14.4, 14.9, 16.4, "#5cd65c", "#009933", null, {enabled: true}]
]);

// map the data
var seriesData_1 = data.mapAs({x: [0], low: [1], high: [2], fill: [5], stroke: [7], label: [8]});
var seriesData_2 = data.mapAs({x: [0], low: [3], high: [4], fill: [6], stroke: [7], label: [8]});

JsFiddle Playground

Padding

To set the padding between bars and bar groups, use these methods:

Padding is measured as a ratio to the width of bars (the width is calculated automatically). So, if it is < 1, the space between bars or bar groups is less than the width of bars, and vice versa. If padding is set to 0, there is no space between bars/groups, and a negative parameter makes bars overlap each other.

Please note that in AnyChart single-series range bar charts are, technically speaking, composed of one-element bar groups, so you should use barGroupsPadding() to configure the padding between bars. In the following sample it is set to 0:

// create a range bar series and set the data
var series = chart.rangeBar(data);

// set the padding between bar groups
chart.barGroupsPadding(0);

JsFiddle Playground

The barsPadding() method works only with multi-series charts: it sets the padding between bars within a group. The space between groups is set via barGroupsPadding().

If you set barsPadding() to -1, you can create an imitation of a stacked chart, which is not bound to zero. See the sample below (there is a multi-series Range Bar chart with the padding between bars and between bar groups set to -1 and 2):

// create the first series
var series1 = chart.rangeBar(seriesData_1);

// create the second series
var series2 = chart.rangeBar(seriesData_2);

// set the padding between bars
chart.barsPadding(-1);

// set the padding between bar groups
chart.barGroupsPadding(2);

JsFiddle Playground

Labels

Labels are text or image elements that can be placed anywhere on any chart (you can enable them on a whole series or in a single point). For text labels, font settings and text formatters are available.

Tooltips

A Tooltip is a text box displayed when a point on a chart is hovered. There is a number of visual and other settings available: for example, you can edit the text by using font settings and text formatters, change the style of background, adjust the position of a tooltip, and so on.