Click here to see your recently viewed pages and most viewed pages.
Hide

Stepped Area Chart

Overview

A stepped area chart that is rendered within the browser using SVG or VML. Displays tips when hovering over steps.

A Simple Example

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Director (Year)',  'Rotten Tomatoes', 'IMDB'],
          ['Alfred Hitchcock (1935)', 8.4,         7.9],
          ['Ralph Thomas (1959)',     6.9,         6.5],
          ['Don Sharp (1978)',        6.5,         6.4],
          ['James Hawes (2008)',      4.4,         6.2]
        ]);

        var options = {
          title: 'The decline of \'The 39 Steps\'',
          vAxis: {title: 'Accumulated Rating'},
          isStacked: true
        };

        var chart = new google.visualization.SteppedAreaChart(document.getElementById('chart_div'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

Some Common Options

Like all Google Charts, stepped area charts have lots of options, shown here. Here's an example demonstrating some of the most common:

In the above chart, we've changed the background color with backgroundColor, moved the legend to the bottom with legend.position, removed the vertical lines by setting connectSteps to false, and customized the colors. Here's how that was done:

  var options = {
      backgroundColor: '#ddd',
      legend: { position: 'bottom' },
      connectSteps: false,
      colors: ['#4374E0', '#53A8FB', '#F1CA3A', '#E49307'],
      isStacked: true,
  };

Stacked Stepped Area Charts

Stepped area charts also support stacking, including 100% stacking. A stacked stepped area chart is a stepped area 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. For 100% stacking, 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 written based on the relative 0-1 scale as fractions of 1.

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

Loading

The google.load package name is "corechart".

  google.load("visualization", "1", {packages: ["corechart"]});

The visualization's class name is google.visualization.SteppedAreaChart.

  var visualization = new google.visualization.SteppedAreaChart(container);

Data Format

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

Columns:

  Column 0 Column 1 ... Column N
Purpose: X-axis group labels Bar 1 values in this group ... Bar N values in this group
Data Type: string number ... number
Role: domain data ... data
Optional column roles:

None

...

 

Configuration Options

Name Type Default Description
aggregationTarget string 'auto' How multiple data selections are rolled up into tooltips:
  • 'category': Group selected data by x-value.
  • 'series': Group selected data by series.
  • 'auto': Group selected data by x-value if all selections have the same x-value, and by series otherwise.
  • 'none': Show only one tooltip per selection.
aggregationTarget will often be used in tandem with selectionMode and tooltip.trigger, e.g.:
  var options = {
    // Allow multiple simultaneous selections.
    selectionMode: 'multiple',
    // Trigger tooltips on selections.
    tooltip: { trigger: 'selection' },
    // Group selections by x-value.
    aggregationTarget: 'category',
  };
animation.duration number 0 The duration of the animation, in milliseconds. For details, see the animation documentation.
animation.easing string 'linear' 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.
animation.startup boolean false 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.
areaOpacity number, 0.0–1.0 0.3 The default opacity of the area beneath the step, where 0.0 is fully transparent and 1.0 is fully opaque. Does not affect the opacity of the stepped line. To achieve a stepped line chart, set this value to 0. To specify opacity for an individual series, set the areaOpacity value in the series property.
axisTitlesPosition string 'out'

Where to place the axis titles, compared to the chart area. Supported values:

  • in - Draw the axis titles inside the the chart area.
  • out - Draw the axis titles outside the chart area.
  • none - Omit the axis titles.
backgroundColor string or object 'white' The background color for the main area of the chart. Can be either a simple HTML color string, for example: 'red' or '#00cc00', or an object with the following properties.
backgroundColor.stroke string '#666' The color of the chart border, as an HTML color string.
backgroundColor.strokeWidth number 0 The border width, in pixels.
backgroundColor.fill string 'white' The chart fill color, as an HTML color string.
chartArea Object null An object with members to configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends). Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage. Example: chartArea:{left:20,top:0,width:'50%',height:'75%'}
chartArea.backgroundColor string or object 'white' Chart area background color. When a string is used, it can be either a hex string (e.g., '#fdc') or an English color name. When an object is used, the following properties can be provided:
  • stroke: the color, provided as a hex string or English color name.
  • strokeWidth: if provided, draws a border around the chart area of the given width (and with the color of stroke).
chartArea.left number or string auto How far to draw the chart from the left border.
chartArea.top number or string auto How far to draw the chart from the top border.
chartArea.width number or string auto Chart area width.
chartArea.height number or string auto Chart area height.
colors Array of strings default colors The colors to use for the chart elements. An array of strings, where each element is an HTML color string, for example: colors:['red','#004411'].
connectSteps boolean true If set to true, will connect the steps to form a stepped line. Otherwise, only a top line appears. The default is to connect the steps.
enableInteractivity boolean true Whether the chart throws user-based events or reacts to user interaction. If false, the chart will not throw 'select' or other interaction-based events (but will throw ready or error events), and will not display hovertext or otherwise change depending on user input.
focusTarget string 'datum'

The type of the entity that receives focus on mouse hover. Also affects which entity is selected by mouse click, and which data table element is associated with events. Can be one of the following:

  • 'datum' - Focus on a single data point. Correlates to a cell in the data table.
  • 'category' - Focus on a grouping of all data points along the major axis. Correlates to a row in the data table.

In focusTarget 'category' the tooltip displays all the category values. This may be useful for comparing values of different series.

fontSize number automatic The default font size, in pixels, of all text in the chart. You can override this using properties for specific chart elements.
fontName string 'Arial' The default font face for all text in the chart. You can override this using properties for specific chart elements.
forceIFrame boolean false Draws the chart inside an inline frame. (Note that on IE8, this option is ignored; all IE8 charts are drawn in i-frames.)
hAxis Object null

An object with members to configure various horizontal axis elements. To specify properties of this object, you can use object literal notation, as shown here:

 {title: 'Hello',  titleTextStyle: {color: '#FF0000'}}
hAxis.direction 1 or -1 1 The direction in which the values along the horizontal axis grow. Specify -1 to reverse the order of the values.
hAxis.textPosition string 'out'

Position of the horizontal axis text, relative to the chart area. Supported values: 'out', 'in', 'none'.

hAxis.textStyle Object {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}

An object that specifies the horizontal axis text style. The object has this format:

{ color: <string>,
  fontName: <string>,
  fontSize: <number>,
  bold: <boolean>,
  italic: <boolean> }

The color can be any HTML color string, for example: 'red' or '#00cc00'. Also see fontName and fontSize.

hAxis.ticks Array of elements auto

Replaces the automatically generated X-axis ticks with the specified array. Each element of the array should be either a valid tick value (such as a number, date, datetime, or timeofday), or an object. If it's an object, it should have a v property for the tick value, and an optional f property containing the literal string to be displayed as the label.

Examples:

  • hAxis: { ticks: [5,10,15,20] }
  • hAxis: { ticks: [{v:32, f:'thirty two'}, {v:64, f:'sixty four'}] }
  • hAxis: { ticks: [new Date(2014,3,15), new Date(2013,5,15)] }
  • hAxis: { ticks: [16, {v:32, f:'thirty two'}, {v:64, f:'sixty four'}, 128] }

hAxis.title string null hAxis property that specifies the title of the horizontal axis.
hAxis.titleTextStyle Object {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}

An object that specifies the horizontal axis title text style. The object has this format:

{ color: <string>,
  fontName: <string>,
  fontSize: <number>,
  bold: <boolean>,
  italic: <boolean> }

The color can be any HTML color string, for example: 'red' or '#00cc00'. Also see fontName and fontSize.

hAxis.allowContainerBoundaryTextCufoff boolean false If false, will hide outermost labels rather than allow them to be cropped by the chart container. If true, will allow label cropping.
hAxis.slantedText boolean automatic If true, draw the horizontal axis text at an angle, to help fit more text along the axis; if false, draw horizontal axis text upright. Default behavior is to slant text if it cannot all fit when drawn upright. Notice that this option is available only when the hAxis.textPosition is set to 'out' (which is the default).
hAxis.slantedTextAngle number, 1—90 30 The angle of the horizontal axis text, if it's drawn slanted. Ignored if hAxis.slantedText is false, or is in auto mode, and the chart decided to draw the text horizontally.
hAxis.maxAlternation number 2 Maximum number of levels of horizontal axis text. If axis text labels become too crowded, the server might shift neighboring labels up or down in order to fit labels closer together. This value specifies the most number of levels to use; the server can use fewer levels, if labels can fit without overlapping.
hAxis.maxTextLines number auto Maximum number of lines allowed for the text labels. Labels can span multiple lines if they are too long, and the nuber of lines is, by default, limited by the height of the available space.
hAxis.minTextSpacing number The value of hAxis.textStyle.fontSize Minimum horizontal spacing, in pixels, allowed between two adjacent text labels. If the labels are spaced too densely, or they are too long, the spacing can drop below this threshold, and in this case one of the label-unclutter measures will be applied (e.g, truncating the lables or dropping some of them).
hAxis.showTextEvery number automatic How many horizontal axis labels to show, where 1 means show every label, 2 means show every other label, and so on. Default is to try to show as many labels as possible without overlapping.
hAxis.viewWindow Object null Specifies the cropping range of the horizontal axis.
hAxis.viewWindow.max number auto The zero-based row index where the cropping window ends. Data points at this index and higher will be cropped out. In conjunction with vAxis.viewWindowMode.min, it defines a half-opened range [min, max) that denotes the element indices to display. In other words, every index such that min <= index < max will be displayed. Ignored when hAxis.viewWindowMode is 'pretty' or 'maximized'.
hAxis.viewWindow.min number auto The zero-based row index where the cropping window begins. Data points at indices lower than this will be cropped out. In conjunction with vAxis.viewWindowMode.max, it defines a half-opened range [min, max) that denotes the element indices to display. In other words, every index such that min <= index < max will be displayed. Ignored when hAxis.viewWindowMode is 'pretty' or 'maximized'.
height number height of the containing element Height of the chart, in pixels.
isStacked boolean/string false

If set to true, stacks the elements for all series at each domain value. Note: In Column, Area, and SteppedArea charts, Google Charts reverses the order of legend items to better correspond with the stacking of the series elements (E.g. series 0 will be the bottom-most legend item). This does not apply to Bar Charts.

The isStacked option also supports 100% stacking, where the stacks of elements at each domain value are rescaled to add up to 100%.

The options for isStacked are:

  • false — elements will not stack. This is the default option.
  • true — stacks elements for all series at each domain value.
  • 'percent' — stacks elements for all series at each domain value and rescales them such that they add up to 100%, with each element's value calculated as a percentage of 100%.
  • 'relative' — stacks elements for all series at each domain value and rescales them such that they add up to 1, with each element's value calculated as a fraction of 1.
  • 'absolute' — functions the same as isStacked: true.

For 100% stacking, the calculated value for each element will appear in the tooltip after its actual value.

The target axis will default to tick values based on the relative 0-1 scale as fractions of 1 for 'relative', and 0-100% for 'percent' (Note: when using the 'percent' option, the axis/tick values are displayed as percentages, however the actual values are the relative 0-1 scale values. 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/gridlines using the relative 0-1 scale values). You can customize the gridlines/tick values and formatting using the appropriate hAxis/vAxis options.

100% stacking only supports data values of type number, and must have a baseline of zero.

legend Object null

An object with members to configure various aspects of the legend. To specify properties of this object, you can use object literal notation, as shown here:

{position: 'top', textStyle: {color: 'blue', fontSize: 16}}
legend.alignment string automatic Alignment of the legend. Can be one of the following:
  • 'start' - Aligned to the start of the area allocated for the legend.
  • 'center' - Centered in the area allocated for the legend.
  • 'end' - Aligned to the end of the area allocated for the legend.

Start, center, and end are relative to the style -- vertical or horizontal -- of the legend. For example, in a 'right' legend, 'start' and 'end' are at the top and bottom, respectively; for a 'top' legend, 'start' and 'end' would be at the left and right of the area, respectively.

The default value depends on the legend's position. For 'bottom' legends, the default is 'center'; other legends default to 'start'.

legend.maxLines number 1

Maximum number of lines in the legend. Set this to a number greater than one to add lines to your legend. Note: The exact logic used to determine the actual number of lines rendered is still in flux.

This option currently works only when legend.position is 'top'.

legend.position string 'right' Position of the legend. Can be one of the following:
  • 'bottom' - Below the chart.
  • 'left' - To the left of the chart, provided the left axis has no series associated with it. So if you want the legend on the left, use the option targetAxisIndex: 1.
  • 'in' - Inside the chart, by the top left corner.
  • 'none' - No legend is displayed.
  • 'right' - To the right of the chart. Incompatible with the vAxes option.
  • 'top' - Above the chart.
legend.textStyle Object {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}

An object that specifies the legend text style. The object has this format:

{ color: <string>,
  fontName: <string>,
  fontSize: <number>,
  bold: <boolean>,
  italic: <boolean> }

The color can be any HTML color string, for example: 'red' or '#00cc00'. Also see fontName and fontSize.

lineDashStyle Array of numbers null The on-and-off pattern for dashed lines. For instance, [4, 4] will repeat 4-length dashes followed by 4-length gaps, and [5, 1, 3] will repeat a 5-length dash, a 1-length gap, a 3-length dash, a 5-length gap, a 1-length dash, and a 3-length gap. See Dashed Lines for more information.
reverseCategories boolean false If set to true, will draw series from right to left. The default is to draw left-to-right.
selectionMode string 'single' When selectionMode is 'multiple', users may select multiple data points.
series Array of objects, or object with nested objects {}

An array of objects, each describing the format of the corresponding series in the chart. To use default values for a series, specify an empty object {}. If a series or a value is not specified, the global value will be used. Each object supports the following properties:

  • areaOpacity - Overrides the global areaOpacity for this series.
  • color - The color to use for this series. Specify a valid HTML color string.
  • labelInLegend - The description of the series to appear in the chart legend.
  • lineDashStyle - Overrides the global lineDashStyle value for this series.
  • targetAxisIndex - Which axis to assign this series to, where 0 is the default axis, and 1 is the opposite axis. Default value is 0; set to 1 to define a chart where different series are rendered against different axes. At least one series much be allocated to the default axis. You can define a different scale for different axes.
  • visibleInLegend - A boolean value, where true means that the series should have a legend entry, and false means that it should not. Default is true.

You can specify either an array of objects, each of which applies to the series in the order given, or you can specify an object where each child has a numeric key indicating which series it applies to. For example, the following two declarations are identical, and declare the first series as black and absent from the legend, and the fourth as red and absent from the legend:

series: [{color: 'black', visibleInLegend: false}, {}, {},
                      {color: 'red', visibleInLegend: false}]
series: {0:{color: 'black', visibleInLegend: false},
         3:{color: 'red', visibleInLegend: false}}
theme string null A theme is a set of predefined option values that work together to achieve a specific chart behavior or visual effect. Currently only one theme is available:
  • 'maximized' - Maximizes the area of the chart, and draws the legend and all of the labels inside the chart area. Sets the following options:
    chartArea: {width: '100%', height: '100%'},
    legend: {position: 'in'},
    titlePosition: 'in', axisTitlesPosition: 'in',
    hAxis: {textPosition: 'in'}, vAxis: {textPosition: 'in'}
title string no title Text to display above the chart.
titlePosition string 'out'

Where to place the chart title, compared to the chart area. Supported values:

  • in - Draw the title inside the chart area.
  • out - Draw the title outside the chart area.
  • none - Omit the title.
titleTextStyle Object {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}

An object that specifies the title text style. The object has this format:

{ color: <string>,
  fontName: <string>,
  fontSize: <number>,
  bold: <boolean>,
  italic: <boolean> }

The color can be any HTML color string, for example: 'red' or '#00cc00'. Also see fontName and fontSize.

tooltip Object null

An object with members to configure various tooltip elements. To specify properties of this object, you can use object literal notation, as shown here:

 {textStyle: {color: '#FF0000'}, showColorCode: true}
tooltip.showColorCode boolean automatic If true, show colored squares next to the series information in the tooltip. The default is true when focusTarget is set to 'category', otherwise the default is false.
tooltip.textStyle Object {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}

An object that specifies the tooltip text style. The object has this format:

{ color: <string>,
  fontName: <string>,
  fontSize: <number>,
  bold: <boolean>,
  italic: <boolean> }

The color can be any HTML color string, for example: 'red' or '#00cc00'. Also see fontName and fontSize.

tooltip.trigger string 'focus'

The user interaction that causes the tooltip to be displayed:

  • 'focus' - The tooltip will be displayed when the user hovers over the element.
  • 'none' - The tooltip will not be displayed.
  • 'selection' - The tooltip will be displayed when the user selects the element.
vAxes Array of object, or object with child objects null

Specifies properties for individual vertical axes, if the chart has multiple vertical axes. Each child object is a vAxis object, and can contain all the properties supported by vAxis. These property values override any global settings for the same property.

To specify a chart with multiple vertical axes, first define a new axis using series.targetAxisIndex, then configure the axis using vAxes. The following example assigns series 2 to the right axis and specifies a custom title and text style for it:

series:{2:{targetAxisIndex:1}}, vAxes:{1:{title:'Losses',textStyle:{color: 'red'}}}

This property can be either an object or an array: the object is a collection of objects, each with a numeric label that specifies the axis that it defines--this is the format shown above; the array is an array of objects, one per axis. For example, the following array-style notation is identical to the vAxis object shown above:

vAxes:[
{}, // Nothing specified for axis 0
{title:'Losses',textStyle:{color: 'red'}} // Axis 1
]
vAxis Object null

An object with members to configure various vertical axis elements. To specify properties of this object, you can use object literal notation, as shown here:

 {title: 'Hello', titleTextStyle: {color: '#FF0000'}}
vAxis.baseline number automatic vAxis property that specifies the baseline for the vertical axis. If the baseline is larger than the highest grid line or smaller than the lowest grid line, it will be rounded to the closest gridline.
vAxis.baselineColor number 'black' Specifies the color of the baseline for the vertical axis. Can be any HTML color string, for example: 'red' or '#00cc00'.
vAxis.direction 1 or -1 1 The direction in which the values along the vertical axis grow. Specify -1 to reverse the order of the values.
vAxis.format string auto A format string for numeric axis labels. This is a subset of the ICU pattern set. For instance, {format:'#,###%'} will display values "1,000%", "750%", and "50%" for values 10, 7.5, and 0.5. You can also supply any of the following:
  • {format: 'none'}: displays numbers with no formatting (e.g., 8000000)
  • {format: 'decimal'}: displays numbers with thousands separators (e.g., 8,000,000)
  • {format: 'scientific'}: displays numbers in scientific notation (e.g., 8e6)
  • {format: 'currency'}: displays numbers in the local currency (e.g., $8,000,000.00)
  • {format: 'percent'}: displays numbers as percentages (e.g., 800,000,000%)
  • {format: 'short'}: displays abbreviated numbers (e.g., 8M)
  • {format: 'long'}: displays numbers as full words (e.g., 8 million)

The actual formatting applied to the label is derived from the locale the API has been loaded with. For more details, see loading charts with a specific locale.

vAxis.gridlines Object null

An object with members to configure the gridlines on the vertical axis. To specify properties of this object, you can use object literal notation, as shown here:

 {color: '#333', count: 4}
vAxis.gridlines.color string '#CCC' The color of the vertical gridlines inside the chart area. Specify a valid HTML color string.
vAxis.gridlines.count number 5 The number of vertical gridlines inside the chart area. Minimum value is 2. Specify -1 to automatically compute the number of gridlines.
vAxis.minorGridlines Object null An object with members to configure the minor gridlines on the vertical axis, similar to the vAxis.gridlines option.
vAxis.minorGridlines.color string A blend of the gridline and background colors The color of the vertical minor gridlines inside the chart area. Specify a valid HTML color string.
vAxis.minorGridlines.count number 0 The number of vertical minor gridlines between two regular gridlines.
vAxis.logScale boolean false If true, makes the vertical axis a logarithmic scale Note: All values must be positive.
vAxis.textPosition string 'out'

Position of the vertical axis text, relative to the chart area. Supported values: 'out', 'in', 'none'.

vAxis.textStyle Object {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}

An object that specifies the vertical axis text style. The object has this format:

{ color: <string>,
  fontName: <string>,
  fontSize: <number>,
  bold: <boolean>,
  italic: <boolean> }

The color can be any HTML color string, for example: 'red' or '#00cc00'. Also see fontName and fontSize.

vAxis.ticks Array of elements auto

Replaces the automatically generated Y-axis ticks with the specified array. Each element of the array should be either a valid tick value (such as a number, date, datetime, or timeofday), or an object. If it's an object, it should have a v property for the tick value, and an optional f property containing the literal string to be displayed as the label.

Examples:

  • vAxis: { ticks: [5,10,15,20] }
  • vAxis: { ticks: [{v:32, f:'thirty two'}, {v:64, f:'sixty four'}] }
  • vAxis: { ticks: [new Date(2014,3,15), new Date(2013,5,15)] }
  • vAxis: { ticks: [16, {v:32, f:'thirty two'}, {v:64, f:'sixty four'}, 128] }

vAxis.title string no title vAxis property that specifies a title for the vertical axis.
vAxis.titleTextStyle Object {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}

An object that specifies the vertical axis title text style. The object has this format:

{ color: <string>,
  fontName: <string>,
  fontSize: <number>,
  bold: <boolean>,
  italic: <boolean> }

The color can be any HTML color string, for example: 'red' or '#00cc00'. Also see fontName and fontSize.

vAxis.maxValue number automatic Moves the max value of the vertical axis to the specified value; this will be upward in most charts. Ignored if this is set to a value smaller than the maximum y-value of the data. vAxis.viewWindow.max overrides this property.
vAxis.minValue number automatic Moves the min value of the vertical axis to the specified value; this will be downward in most charts. Ignored if this is set to a value greater than the minimum y-value of the data. vAxis.viewWindow.min overrides this property.
vAxis.viewWindowMode string Equivalent to 'pretty', but vaxis.viewWindow.min and vaxis.viewWindow.max take precedence if used.

Specifies how to scale the vertical axis to render the values within the chart area. The following string values are supported:

  • 'pretty' - Scale the vertical values so that the maximum and minimum data values are rendered a bit inside the top and bottom of the chart area. This will cause vaxis.viewWindow.min and vaxis.viewWindow.max to be ignored.
  • 'maximized' - Scale the vertical values so that the maximum and minimum data values touch the top and bottom of the chart area. This will cause vaxis.viewWindow.min and vaxis.viewWindow.max to be ignored.
  • 'explicit' - A deprecated option for specifying the top and bottom scale values of the chart area. (Deprecated because it's redundant with vaxis.viewWindow.min and vaxis.viewWindow.max. Data values outside these values will be cropped. You must specify a vAxis.viewWindow object describing the maximum and minimum values to show.
vAxis.viewWindow Object null Specifies the cropping range of the vertical axis.
vAxis.viewWindow.max number auto The maximum vertical data value to render.
Ignored when vAxis.viewWindowMode is 'pretty' or 'maximized'.
vAxis.viewWindow.min number auto The minimum horizontal data value to render.
Ignored when vAxis.viewWindowMode is 'pretty' or 'maximized'.
width number width of the containing element Width of the chart, in pixels.

Methods

Method Return Type Description
draw(data, options) none Draws the chart. The chart accepts further method calls only after the ready event is fired. Extended description.
getAction(actionID) Object

Returns the tooltip action object with the requested actionID.

getBoundingBox(id) Object

Returns an object containing the left, top, width, and height of chart element id. The format for id isn't yet documented (they're the return values of event handlers), but here are some examples:

var cli = chart.getChartLayoutInterface();

Height of the chart area
cli.getBoundingBox('chartarea').height
Width of the third bar in the first series of a bar or column chart
cli.getBoundingBox('bar#0#2').width
Bounding box of the fifth wedge of a pie chart
cli.getBoundingBox('slice#4')
Bounding box of the chart data of a vertical (e.g., column) chart:
cli.getBoundingBox('vAxis#0#gridline')
Bounding box of the chart data of a horizontal (e.g., bar) chart:
cli.getBoundingBox('hAxis#0#gridline')

Values are relative to the container of the chart. Call this after the chart is drawn.

getChartAreaBoundingBox() Object

Returns an object containing the left, top, width, and height of the chart content (i.e., excluding labels and legend):

var cli = chart.getChartLayoutInterface();

cli.getChartAreaBoundingBox().left
cli.getChartAreaBoundingBox().top
cli.getChartAreaBoundingBox().height
cli.getChartAreaBoundingBox().width

Values are relative to the container of the chart. Call this after the chart is drawn.

getChartLayoutInterface() Object

Returns an object containing information about the onscreen placement of the chart and its elements.

The following methods can be called on the returned object:

  • getBoundingBox
  • getChartAreaBoundingBox
  • getHAxisValue
  • getVAxisValue
  • getXLocation
  • getYLocation

Call this after the chart is drawn.

getHAxisValue(position, optional_axis_index) Number

Returns the logical horizontal value at position, which is an offset from the chart container's left edge. Can be negative.

Example: chart.getChartLayoutInterface().getHAxisValue(400).

Call this after the chart is drawn.

getImageURI() String

Returns the chart serialized as an image URI.

Call this after the chart is drawn.

See Printing PNG Charts.

getSelection() Array of selection elements Returns an array of the selected chart entities. Selectable entities are steps, legend entries and categories. A step corresponds to a cell in the data table, a legend entry to a column (row index is null), and a category to a row (column index is null). For this chart, only one entity can be selected at any given moment. Extended description .
getVAxisValue(position, optional_axis_index) Number

Returns the logical vertical value at position, which is an offset from the chart container's top edge. Can be negative.

Example: chart.getChartLayoutInterface().getVAxisValue(300).

Call this after the chart is drawn.

getXLocation(position, optional_axis_index) Number

Returns the screen x-coordinate of position relative to the chart's container.

Example: chart.getChartLayoutInterface().getXLocation(400).

Call this after the chart is drawn.

getYLocation(position, optional_axis_index) Number

Returns the screen y-coordinate of position relative to the chart's container.

Example: chart.getChartLayoutInterface().getYLocation(300).

Call this after the chart is drawn.

removeAction(actionID) none Removes the tooltip action with the requested actionID from the chart.
setAction(action) none

Sets a tooltip action to be executed when the user clicks on the action text.

The setAction method takes an object as its action parameter. This object should specify 3 properties: id— the ID of the action being set, text —the text that should appear in the tooltip for the action, and action — the function that should be run when a user clicks on the action text.

Any and all tooltip actions should be set prior to calling the chart's draw() method. Extended description.

setSelection() none Selects the specified chart entities. Cancels any previous selection. Selectable entities are steps, legend entries and categories. A step corresponds to a cell in the data table, a legend entry to a column (row index is null), and a category to a row (column index is null). For this chart, only one entity can be selected at a time. Extended description .
clearChart() none Clears the chart, and releases all of its allocated resources.

Events

For more information on how to use these events, see Basic Interactivity, Handling Events, and Firing Events.

Name Description Properties
animationfinish Fired when transition animation is complete. None
click Fired when the user clicks inside the chart. Can be used to identify when the title, data elements, legend entries, axes, gridlines, or labels are clicked. targetID
error Fired when an error occurs when attempting to render the chart. id, message
onmouseover Fired when the user mouses over a visual entity. Passes back the row and column indices of the corresponding data table element. row, column
onmouseout Fired when the user mouses away from a visual entity. Passes back the row and column indices of the corresponding data table element. row, column
ready The chart is ready for external method calls. If you want to interact with the chart, and call methods after you draw it, you should set up a listener for this event before you call the draw method, and call them only after the event was fired. None
select Fired when the user clicks a visual entity. To learn what has been selected, call getSelection(). None

Data Policy

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