Google Charts
Google Charts Introduction Getting Started Area Charts Bar Charts Bubble Charts Calendar Charts Candlestick Charts Column Charts Combination Chart Gauge Chart Geo Charts Histogram Charts Line Charts Maps Organization Chart Pie Charts Sankey Charts Scatter Charts Stepped Area Charts Table Chart Trendline Charts Wordtree Charts

Google Column Chart

Column charts are used to draw vertical bar charts.

A column chart is rendered within the browser using SVG or VML.

Like all Google charts, column charts display tooltips when the user hovers over the data.

Basic Column Chart

The following example shows how to draw a basic column chart, using google charts API:

For a horizontal version of this chart, see the bar chart.

Example Explained

First add a <div> element with the id "chart-div" and set width and height:

<!DOCTYPE html> <html lang="en-US"> <body> <div id="chart-div" style="width:100%; height:350px;"></div> </body> </html>

Then add a reference to the Chart API:

<script src=""></script>

Finally add a JavaScript function:

// Load the corechart package and set a callback google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); // Callback that creates and populates a data table function drawChart() { // Create the data table var data = google.visualization.arrayToDataTable([ ['City', '2019 Population'], ['Mumbai', 20185064], ['Delhi', 29399141], ['Chennai', 10711243], ['Jaipur', 3812262], ['Bengaluru', 11882666] ]); // Set chart options var options = { title: 'Population of Largest Indian Cities' }; // Display the chart inside the <div> element with id="chart-div" var chart = new google.visualization.ColumnChart(document.getElementById('chart-div')); chart.draw(data, options); }

Grouped Column Chart

The following example shows how to create grouped column chart:

var data = google.visualization.arrayToDataTable([ ['City', '2010 Population', '2019 Population'], ['Mumbai', 18257413, 20185064], ['Delhi', 21987895, 29399141], ['Chennai', 8506193, 10711243], ['Jaipur', 2991656, 3812262], ['Bengaluru', 8295564, 11882666] ]);
Run code

Stacked Column Chart

A stacked column chart is a column chart that places related values atop one another.

You create a stacked column chart by setting the isStacked option to true:

// Set chart options var options = { title: 'Population of Largest Indian Cities', chartArea: {width: '50%'}, hAxis: {title: 'City'}, vAxis: {title: 'Total Population', minValue: 0}, isStacked: true };
Run code

Creating Material Column Chart

Material Column Charts have many small improvements over Classic Column Charts, including an improved color palette, rounded corners, clearer label formatting, tighter default spacing between series, softer gridlines and titles (and the addition of subtitles).

Creating a Material Column Chart is similar to creating what we'll now call a "Classic" Column Chart.

You load the Google Visualization API (although with the 'bar' package instead of the 'corechart' package):

google.charts.load('current', {'packages':['bar']});

And then create an object (but of class google.charts.Bar instead of google.visualization.ColumnChart):

var chart = new google.charts.Bar(document.getElementById('chart-div')); chart.draw(data, google.charts.Bar.convertOptions(options));
Run code

Material Charts will not work in old versions of Internet Explorer. (IE8 and earlier versions don't support SVG, which Material Charts require.)

Animated Column Chart

Google charts can animate smoothly in one of two ways, either on startup when you first draw the chart, or when you redraw a chart after making a change in data or options.

To animate on startup:

  • Set your chart data and options. Be sure to set an animation duration and easing type
  • Set animation: {startup: true} — setting this in your options will cause your chart to start with series values drawn at the baseline, and animate out to their final state

Here is a simple example which animate smoothly on startup:

// Set chart options var options = { title: 'Population of Largest Indian Cities', animation: { duration: 2000, easing: 'out', startup: true } };
Run code

To animate a transition:

  • Start with an already rendered chart
  • Modify the data table or options
  • Specify the transition behavior using the animation option
  • Call chart.draw() on your chart to transition to the new values

Here is a simple example which changes the values presented in a chart upon each click on a button:

Click the button to animate chart:

Run code