Still have questions?
Contact support

Bar Chart


A bar chart is a chart that visualizes data as a set of rectangular bars, their lengths being proportional to the values they represent. The horizontal axis shows the values, and the vertical axis shows the categories they belong to. So, the bar chart is a vertical version of the column chart. In multi-series bar charts, values are grouped by categories.

The bar chart is used very widely to show comparison among categories and sometimes to visualize time-based data. Also, categories with long names may be a reason to prefer the bar chart to the column chart.

This article explains how to create a basic Bar chart as well as configure settings that are specific to the type. In addition, you see the table below to get a brief overview of the Bar chart's characteristics:

Data Fieldsx, value
Multiple SeriesYES
StackedStacked Bar, Percent Stacked Bar
3D3D Bar
Error BarsBar Chart with Error Bars
Chartopedia: Bar Chart
General Settings

Quick Start

To create a Bar chart, use the chart constructor. If you pass the data to this chart constructor, it creates a Bar series.

To create a Bar series explicitly, call the bar() method.

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

// create a data set
var data =[
  ["John", 10000],
  ["Jake", 12000],
  ["Peter", 13000],
  ["James", 10000],
  ["Mary", 9000]

// create a chart
var chart =;

// create a bar series and set the data
var series =;

// set the container id

// initiate drawing the chart

JsFiddle Playground

General Settings

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

Read the overview of general settings: General Settings.

Special Settings


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

You can learn more from the Appearance Settings article.

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

// create the first series
var series1 =;

// 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 =;

// 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.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 =[
  {x: "John", value: 10000},
  {x: "Jake", value: 12000},
  {x: "Peter", value: 13000, fill: "#5cd65c", stroke: null, label: {enabled: true}},
  {x: "James", value: 10000},
  {x: "Mary", value: 9000}

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 =[
  ["John", 10000, 12500],
  ["Jake", 12000, 15000],
  ["Peter", 13000, 16500, "#5cd65c", "#009933", null, {enabled: true}],
  ["James", 10000, 13000],
  ["Mary", 9000, 11000]

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

JsFiddle Playground


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 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 bar series and set the data
var series =;

// set the padding between bar groups

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().

In the sample below, there is a multi-series Bar chart with the padding between bars and between bar groups set to -0.5 and 2:

// create the first series
var series1 =;

// create the second series
var series2 =;

// set the padding between bars

// set the padding between bar groups

JsFiddle Playground


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.


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.

Stacked Bar

Stacked and percent stacked charts are multi-series charts where related values are placed atop one another, which allows comparing the the contribution of a value to a total, either in absolute or percentage terms.

In AnyChart, you can enable a special mode of the scale to make series stack together: see Stacked Charts.

To learn about the stacked versions of the Bar chart, see:

3D Bar

Using AnyChart, you can create 3D versions of some chart types, including the Bar chart.

To learn about 3D charts in general, see 3D Charts (Overview).

The 3D Bar chart is described in the following article: 3D Bar Chart.