What would you call a table added to the bottom of your chart?

  • Students
  • Staff
  • Schools & services
  • Sussex Direct
  • Canvas

What would you call a table added to the bottom of your chart?

Excel 2013 and Excel 2016

Arrange your data so that headings are directly above and to the left of the data to be charted. There should be no blank rows or columns. Make sure that you select the headings as well as the data before you create your chart.

If you have already created your chart:

  1. Click on the chart to select it.
  2. Click the Chart Filters button.
  3. Click Select Data... at the bottom right of the dialog.
  4. In the Select Data Source dialog box under Horizontal (Category) Axis Labels, click Edit.
  5. In the Axis label range enter the cell references for the x-axis or use the mouse to select the range, click OK.
  6. In the dialog box under Legend Entry Series, select the first series and click Edit
  7. In the Series name box, enter the cell reference for the name of the series or use the mouse to select the cell, click OK.
  8. Repeat for each series of data.
  9. Click OK.

What would you call a table added to the bottom of your chart?

Excel 2010

Arrange your data so that headings are directly above and to the left of the data to be charted. No blank rows or columns. Make sure that you select the headings as well as the data before you create your chart.

If you have already created your chart:

  1. Click on the chart to select it.
  2. From the Chart Tools, Layout tab, Current Selection group, select the Horizontal (Category) Axis
  3. From the Design tab, Data group, select Select Data.
  4. In the dialog box under Horizontal (Category) Axis Labels, click Edit.
  5. In the Axis label range enter the cell references for the x-axis or use the mouse to select the range, click OK.
  6. Click OK.
  7. Make sure that the chart is still selected.
  8. From the Chart Tools, Layout tab, Current Selection group, select the Vertical (Value) Axis.
  9. From the Design tab, Data group, select Select Data.
  10. In the dialog box under Legend Entry Series, select the first series and click Edit
  11. In the Series name box, enter the cell reference for the name of the series or use the mouse to select the cell, click OK.
  12. Repeat for each series.
  13. Click OK.

Please suggest an improvement
(login needed, link opens in new window)

Your views are welcome and will help other readers of this page.

This is question number 264, which appears in the following categories:

A column chart is a vertical bar chart rendered in the browser using SVG or VML, whichever is appropriate for the user's browser. Like all Google charts, column charts display tooltips when the user hovers over the data. For a horizontal version of this chart, see the bar chart.

Examples

Coloring columns

Let's chart the densities of four precious metals:

Above, all colors are the default blue. That's because they're all part of the same series; if there were a second series, that would have been colored red. We can customize these colors with the style role:

There are three different ways to choose the colors, and our data table showcases them all: RGB values, English color names, and a CSS-like declaration:

var data = google.visualization.arrayToDataTable([ ['Element', 'Density', { role: 'style' }], ['Copper', 8.94, '#b87333'], // RGB value ['Silver', 10.49, 'silver'], // English color name ['Gold', 19.30, 'gold'], ['Platinum', 21.45, 'color: #e5e4e2' ], // CSS-style declaration ]);

Column styles

The style role lets your control several aspects of column appearance with CSS-like declarations:

  • color
  • opacity
  • fill-color
  • fill-opacity
  • stroke-color
  • stroke-opacity
  • stroke-width

We don't recommend that you mix styles too freely inside a chart—pick a style and stick with it—but to demonstrate all the style attributes, here's a sampler:

The first two columns each use a specific color (the first with an English name, the second with an RGB value). No opacity was chosen, so the default of 1.0 (fully opaque) is used; that's why the second column obscures the gridline behind it. In the third column, an opacity of 0.2 is used, revealing the gridline. In the fourth, three style attributes are used: stroke-color and stroke-width to draw the border, and fill-color to specify the color of the rectangle inside. The rightmost column additionally uses stroke-opacity and fill-opacity to choose opacities for the border and fill:

function drawChart() { var data = google.visualization.arrayToDataTable([ ['Year', 'Visitations', { role: 'style' } ], ['2010', 10, 'color: gray'], ['2020', 14, 'color: #76A7FA'], ['2030', 16, 'opacity: 0.2'], ['2040', 22, 'stroke-color: #703593; stroke-width: 4; fill-color: #C5A5CF'], ['2050', 28, 'stroke-color: #871B47; stroke-opacity: 0.6; stroke-width: 8; fill-color: #BC5679; fill-opacity: 0.2'] ]);

Labeling columns

Charts have several kinds of labels, such as tick labels, legend labels, and labels in the tooltips. In this section, we'll see how to put labels inside (or near) the columns in a column chart.

Let's say we wanted to annotate each column with the appropriate chemical symbol. We can do that with the annotation role:

In our data table, we define a new column with { role: 'annotation' } to hold our column labels:

var data = google.visualization.arrayToDataTable([ ['Element', 'Density', { role: 'style' }, { role: 'annotation' } ], ['Copper', 8.94, '#b87333', 'Cu' ], ['Silver', 10.49, 'silver', 'Ag' ], ['Gold', 19.30, 'gold', 'Au' ], ['Platinum', 21.45, 'color: #e5e4e2', 'Pt' ] ]);

While users can hover over the columns to see the data values, you might want to include them on the columns themselves:

This is a little more complicated than it should be, because we create a DataView to specify the annotation for each column.

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load("current", {packages:['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ["Element", "Density", { role: "style" } ], ["Copper", 8.94, "#b87333"], ["Silver", 10.49, "silver"], ["Gold", 19.30, "gold"], ["Platinum", 21.45, "color: #e5e4e2"] ]); var view = new google.visualization.DataView(data); view.setColumns([0, 1, { calc: "stringify", sourceColumn: 1, type: "string", role: "annotation" }, 2]); var options = { title: "Density of Precious Metals, in g/cm^3", width: 600, height: 400, bar: {groupWidth: "95%"}, legend: { position: "none" }, }; var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_values")); chart.draw(view, options); } </script> <div id="columnchart_values" style="width: 900px; height: 300px;"></div>

If we wanted to format the value differently, we could define a formatter and wrap it in a function like this:

function getValueAt(column, dataTable, row) { return dataTable.getFormattedValue(row, column); }

Then we could call it with calc: getValueAt.bind(undefined, 1).

If the label is too big to fit entirely inside the column, it's displayed outside:

Stacked column charts

A stacked column chart is a column chart that places related values atop one another. If there are any negative values, they are stacked in reverse order below the chart's baseline. It's typically used when a category naturally divides into components. For instance, consider some hypothetical book sales, divided by genre and compared across time:

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

var data = google.visualization.arrayToDataTable([ ['Genre', 'Fantasy & Sci Fi', 'Romance', 'Mystery/Crime', 'General', 'Western', 'Literature', { role: 'annotation' } ], ['2010', 10, 24, 20, 32, 18, 5, ''], ['2020', 16, 22, 23, 30, 16, 9, ''], ['2030', 28, 19, 29, 30, 12, 13, ''] ]); var options = { width: 600, height: 400, legend: { position: 'top', maxLines: 3 }, bar: { groupWidth: '75%' }, isStacked: true, };

Stacked column charts also support 100% stacking, where the stacks of elements at each domain-value are rescaled such that they add up to 100%. The options for this are isStacked: 'percent', which formats each value as a percentage of 100%, and isStacked: 'relative', which formats each value as a fraction of 1. There is also an isStacked: 'absolute' option, which is functionally equivalent to isStacked: true.

Note in the 100% stacked chart on the right, the tick values are based on the relative 0-1 scale as fractions of 1, but the axis values are displayed as percentages. This is because the percentage axis ticks are the result of applying a format of "#.##%" to the relative 0-1 scale values. When using isStacked: 'percent', be sure to specify any ticks/axis values using the relative 0-1 scale.

Stacked var options_stacked = { isStacked: true, height: 300, legend: {position: 'top', maxLines: 3}, vAxis: {minValue: 0} };
100% Stacked var options_fullStacked = { isStacked: 'percent', height: 300, legend: {position: 'top', maxLines: 3}, vAxis: { minValue: 0, ticks: [0, .3, .6, .9, 1] } };

Creating Material column charts

In 2014, Google announced guidelines intended to support a common look and feel across its properties and apps (such as Android apps) that run on Google platforms. We call this effort Material Design. We'll be providing "Material" versions of all our core charts; you're welcome to use them if you like how they look.

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), define your datatable, and then create an object (but of class google.charts.Bar instead of google.visualization.ColumnChart).

Since bar charts and column charts are essentially identical but for orientation, we call both Material Bar Charts, regardless of whether the bars are vertical (classically, a column chart) or horizontal (a bar chart). In Material, the only difference is in the bars option. When set to 'horizontal', the orientation will resemble the traditional Classic Bar Chart; otherwise, the bars will be vertical.

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

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

<html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Year', 'Sales', 'Expenses', 'Profit'], ['2014', 1000, 400, 200], ['2015', 1170, 460, 250], ['2016', 660, 1120, 300], ['2017', 1030, 540, 350] ]); var options = { chart: { title: 'Company Performance', subtitle: 'Sales, Expenses, and Profit: 2014-2017', } }; var chart = new google.charts.Bar(document.getElementById('columnchart_material')); chart.draw(data, google.charts.Bar.convertOptions(options)); } </script> </head> <body> <div id="columnchart_material" style="width: 800px; height: 500px;"></div> </body> </html>

The Material Charts are in beta. The appearance and interactivity are largely final, but many of the options available in Classic Charts are not yet available in them. You can find a list of options that are not yet supported in this issue. Also, the way options are declared is not finalized, so if you are using any of the classic options, you must convert your to material options by replacing this line:

chart.draw(data, options);

...with this:

chart.draw(data, google.charts.Bar.convertOptions(options));

Using google.charts.Bar.convertOptions() allows you to take advantage of certain features, such as the hAxis/vAxis.format preset options.

Dual-Y charts

Sometimes you'll want to display two series in a column chart, with two independent Y-axes: a left axis for one series, and a right axis for another:

Note that not only are our two y-axes labeled differently ("parsecs" versus "apparent magnitude") but they each have their own independent scales and gridlines. If you want to customize this behavior, use the vAxis.gridlines options.

In the code below, the axes and series options together specify the dual-Y appearance of the chart. The series option specifies which axis to use for each ('distance' and 'brightness'; they needn't have any relation to the column names in the datatable). The axes option then makes this chart a dual-Y chart, placing the 'distance' axis on the left (labeled "parsecs") and the 'brightness' axis on the right (labeled "apparent magnitude").

<html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart', 'bar']}); google.charts.setOnLoadCallback(drawStuff); function drawStuff() { var button = document.getElementById('change-chart'); var chartDiv = document.getElementById('chart_div'); var data = google.visualization.arrayToDataTable([ ['Galaxy', 'Distance', 'Brightness'], ['Canis Major Dwarf', 8000, 23.3], ['Sagittarius Dwarf', 24000, 4.5], ['Ursa Major II Dwarf', 30000, 14.3], ['Lg. Magellanic Cloud', 50000, 0.9], ['Bootes I', 60000, 13.1] ]); var materialOptions = { width: 900, chart: { title: 'Nearby galaxies', subtitle: 'distance on the left, brightness on the right' }, series: { 0: { axis: 'distance' }, // Bind series 0 to an axis named 'distance'. 1: { axis: 'brightness' } // Bind series 1 to an axis named 'brightness'. }, axes: { y: { distance: {label: 'parsecs'}, // Left y-axis. brightness: {side: 'right', label: 'apparent magnitude'} // Right y-axis. } } }; var classicOptions = { width: 900, series: { 0: {targetAxisIndex: 0}, 1: {targetAxisIndex: 1} }, title: 'Nearby galaxies - distance on the left, brightness on the right', vAxes: { // Adds titles to each axis. 0: {title: 'parsecs'}, 1: {title: 'apparent magnitude'} } }; function drawMaterialChart() { var materialChart = new google.charts.Bar(chartDiv); materialChart.draw(data, google.charts.Bar.convertOptions(materialOptions)); button.innerText = 'Change to Classic'; button.onclick = drawClassicChart; } function drawClassicChart() { var classicChart = new google.visualization.ColumnChart(chartDiv); classicChart.draw(data, classicOptions); button.innerText = 'Change to Material'; button.onclick = drawMaterialChart; } drawMaterialChart(); }; </script> </head> <body> <button id="change-chart">Change to Classic</button> <br><br> <div id="chart_div" style="width: 800px; height: 500px;"></div> </body> </html>

Top-X charts

Note: Top-X axes are available only for Material charts (i.e., those with package bar).

If you want to put the X-axis labels and title on the top of your chart rather than the bottom, you can do that in Material charts with the axes.x option:

<html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawStuff); function drawStuff() { var data = new google.visualization.arrayToDataTable([ ['Move', 'Percentage'], ["King's pawn (e4)", 44], ["Queen's pawn (d4)", 31], ["Knight to King 3 (Nf3)", 12], ["Queen's bishop pawn (c4)", 10], ['Other', 3] ]); var options = { width: 800, legend: { position: 'none' }, chart: { title: 'Chess opening moves', subtitle: 'popularity by percentage' }, axes: { x: { 0: { side: 'top', label: 'White to move'} // Top x-axis. } }, bar: { groupWidth: "90%" } }; var chart = new google.charts.Bar(document.getElementById('top_x_div')); // Convert the Classic options to Material options. chart.draw(data, google.charts.Bar.convertOptions(options)); }; </script> </head> <body> <div id="top_x_div" style="width: 800px; height: 600px;"></div> </body> </html>

Loading

The google.charts.load package name is "corechart". The visualization's class name is google.visualization.ColumnChart.

google.charts.load("current", {packages: ["corechart"]}); var visualization = new google.visualization.ColumnChart(container);

For Material Column Charts, the google.charts.load package name is "bar". (Not a typo: the Material Bar Chart handles both orientations.) The visualization's class name is google.charts.Bar. (Not a typo: the Material Bar Chart handles both orientations.)

google.charts.load("current", {packages: ["bar"]}); var chart = new google.charts.Bar(container);

Data format

Each row in the table represents a group of adjacent bars.

Rows: Each row in the table represents a group of bars.

Columns:

Configuration options

Name
animation.duration

The duration of the animation, in milliseconds. For details, see the animation documentation.

Type: number

Default: 0

animation.easing

The easing function applied to the animation. The following options are available:

  • 'linear' - Constant speed.
  • 'in' - Ease in - Start slow and speed up.
  • 'out' - Ease out - Start fast and slow down.
  • 'inAndOut' - Ease in and out - Start slow, speed up, then slow down.

Type: string

Default: 'linear'

animation.startup

Determines if the chart will animate on the initial draw. If true, the chart will start at the baseline and animate to its final state.

Type: boolean

Default false

annotations.alwaysOutside

In Bar and Column charts, if set to true, draws all annotations outside of the Bar/Column.

Type: boolean

Default: false

annotations.boxStyle

For charts that support annotations, the annotations.boxStyle object controls the appearance of the boxes surrounding annotations:

var options = { annotations: { boxStyle: { // Color of the box outline. stroke: '#888', // Thickness of the box outline. strokeWidth: 1, // x-radius of the corner curvature. rx: 10, // y-radius of the corner curvature. ry: 10, // Attributes for linear gradient fill. gradient: { // Start color for gradient. color1: '#fbf6a7', // Finish color for gradient. color2: '#33b679', // Where on the boundary to start and // end the color1/color2 gradient, // relative to the upper left corner // of the boundary. x1: '0%', y1: '0%', x2: '100%', y2: '100%', // If true, the boundary for x1, // y1, x2, and y2 is the box. If // false, it's the entire chart. useObjectBoundingBoxUnits: true } } } };

This option is currently supported for area, bar, column, combo, line, and scatter charts. It is not supported by the Annotation Chart.

Type: object

Default: null

annotations.datum

For charts that support annotations, the annotations.datum object lets you override Google Charts' choice for annotations provided for individual data elements (such as values displayed with each bar on a bar chart). You can control the color with annotations.datum.stem.color, the stem length with annotations.datum.stem.length, and the style with annotations.datum.style.

Type: object

Default: color is "black"; length is 12; style is "point".

annotations.domain

For charts that support annotations, the annotations.domain object lets you override Google Charts' choice for annotations provided for a domain (the major axis of the chart, such as the X axis on a typical line chart). You can control the color with annotations.domain.stem.color, the stem length with annotations.domain.stem.length, and the style with annotations.domain.style.

Type: object

Default: color is "black"; length is 5; style is "point".

All code and data are processed and rendered in the browser. No data is sent to any server.