Overview
A chart that lets you render each series as a different marker type from the following list: line, area, bars, candlesticks, and stepped area.
To assign a default marker type for series, specify the seriesType
property.
Use the series
property to specify properties of each series individually.
Example
<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']}); google.charts.setOnLoadCallback(drawVisualization); function drawVisualization() { // Some raw data (not necessarily accurate) var data = google.visualization.arrayToDataTable([ ['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Average'], ['2004/05', 165, 938, 522, 998, 450, 614.6], ['2005/06', 135, 1120, 599, 1268, 288, 682], ['2006/07', 157, 1167, 587, 807, 397, 623], ['2007/08', 139, 1110, 615, 968, 215, 609.4], ['2008/09', 136, 691, 629, 1026, 366, 569.6] ]); var options = { title : 'Monthly Coffee Production by Country', vAxis: {title: 'Cups'}, hAxis: {title: 'Month'}, seriesType: 'bars', series: {5: {type: 'line'}} }; var chart = new google.visualization.ComboChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> </head> <body> <div id="chart_div" style="width: 900px; height: 500px;"></div> </body> </html>
Loading
The google.charts.load
package name is "corechart"
google . charts . load ( "current" , { packages : [ "corechart" ]});
The visualization's class name is google.visualization.ComboChart
var visualization = new google . visualization . ComboChart ( container );
Data Format
Rows:Each row in the table represents a set of data points with the same x-axis location.
Columns:
- X-axis group labels ( discrete )
- X-axis values ( continuous )
Configuration Options
-
'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' , };
The duration of the animation, in milliseconds. For details, see the animation documentation .
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.
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.
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 .
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
.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
.annotations.highContrast
boolean lets you override Google Charts' choice of
the annotation color. By default, annotations.highContrast
is true, which causes
Charts to select an annotation color with good contrast: light colors on dark backgrounds, and
dark on light. If you set annotations.highContrast
to false and don't specify
your own annotation color, Google Charts will use the default series color for the annotation:annotations.stem
object lets you override
Google Charts' choice for the stem style. You can control color
with annotations.stem.color
and the stem length
with annotations.stem.length
. Note that the stem
length option has no effect on annotations with
style 'line'
: for 'line'
datum
annotations, the stem length is always the same as the text, and
for 'line'
domain annotations, the stem extends
across the entire chart.annotations.style
option lets you override
Google Charts' choice of the annotation type. It can be
either 'line'
or 'point'
.annotations.textStyle
object controls the appearance of the text of
the annotation:var options = { annotations : { textStyle : { fontName : 'Times-Roman' , fontSize : 18 , bold : true , italic : true , // The color of the text . color : '#871b47' , // The color of the text outline . auraColor : '#d799ae' , // The transparency of the text . opacity : 0.8 } } };
This option is currently supported for area, bar, column, combo, line, and scatter charts. It is not supported by the Annotation Chart .
The default opacity of the colored area under an area chart series, where 0.0 is fully
transparent and 1.0 is fully opaque. To specify opacity for an individual series, set the
areaOpacity value in the series
property.
Where to place the axis titles, compared to the chart area. Supported values:
- in - Draw the axis titles inside the chart area.
- out - Draw the axis titles outside the chart area.
- none - Omit the axis titles.
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.
The color of the chart border, as an HTML color string.
The border width, in pixels.
The chart fill color, as an HTML color string.
- Pixels (e.g. 50).
- Percentage of the available width for each group (e.g. '20%'), where '100%' means that groups have no space between them.
If true, rising candles will appear hollow and falling candles will appear solid, otherwise, the opposite.
The fill color of falling candles, as an HTML color string.
The stroke color of falling candles, as an HTML color string.
The stroke width of falling candles, as an HTML color string.
The fill color of rising candles, as an HTML color string.
The stroke color of rising candles, as an HTML color string.
The stroke width of rising candles, as an HTML color string.
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%'}
-
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 ofstroke
).
How far to draw the chart from the left border.
How far to draw the chart from the top border.
Chart area width.
Chart area height.
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']
.
The crosshair color, expressed as either a color name (e.g., "blue") or an RGB value (e.g., "#adf").
An object containing the crosshair properties upon focus.
Example: crosshair: { focused: { color: '#3bc', opacity: 0.8 } }
The crosshair opacity, with 0.0
being fully transparent and 1.0
fully opaque.
The crosshair orientation, which can be 'vertical' for vertical hairs only, 'horizontal' for horizontal hairs only, or 'both' for traditional crosshairs.
An object containing the crosshair properties upon selection.
Example: crosshair: { selected: { color: '#3bc', opacity: 0.8 } }
When to display crosshairs: on 'focus'
, 'selection'
, or 'both'
.
Controls the curve of the lines when the line width is not zero. Can be one of the following:
- 'none' - Straight lines without curve.
- 'function' - The angles of the line will be smoothed.
The transparency of data points, with 1.0 being completely opaque and 0.0 fully transparent. In scatter, histogram, bar, and column charts, this refers to the visible data: dots in the scatter chart and rectangles in the others. In charts where selecting data creates a dot, such as the line and area charts, this refers to the circles that appear upon hover or selection. The combo chart exhibits both behaviors, and this option has no effect on other charts. (To change the opacity of a trendline, see trendline opacity .)
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.
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.
The default font size, in pixels, of all text in the chart. You can override this using properties for specific chart elements.
The default font face for all text in the chart. You can override this using properties for specific chart elements.
Draws the chart inside an inline frame. (Note that on IE8, this option is ignored; all IE8 charts are drawn in i-frames.)
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' } }
The baseline for the horizontal axis.
This option is only supported for a continuous
axis.
The color of the baseline for the horizontal axis. Can be any HTML color string, for example: 'red'
or '#00cc00'
.
This option is only supported for a continuous
axis.
The direction in which the values along the horizontal axis grow. Specify -1
to
reverse the order of the values.
A format string for numeric or date axis labels.
For number axis labels, this is a subset of the decimal formatting 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)
For date axis labels, this is a subset of the date formatting ICU pattern set
. For instance, {format:'MMM d, y'}
will display the value
"Jul 1, 2011" for the date of July first in 2011.
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 .
In computing tick values and gridlines, several alternative
combinations of all the relevant gridline
options will be considered and alternatives will be rejected if the
formatted tick labels would be duplicated or overlap.
So you can specify format:"#"
if you want to only show integer tick values,
but be aware that if no alternative satisfies this condition,
no gridlines or ticks will be shown.
This option is only supported for a continuous
axis.
An object with properties to configure the gridlines on the horizontal axis. Note that horizontal axis gridlines are drawn vertically. To specify properties of this object, you can use object literal notation, as shown here:
{color: '#333', minSpacing: 20}
This option is only supported for a continuous
axis.
The color of the horizontal gridlines inside the chart area. Specify a valid HTML color string.
The approximate number of horizontal gridlines inside the chart area.
If you specify a positive number for gridlines.count
,
it will be used to compute the minSpacing
between gridlines.
You can specify a value of 1
to only draw one gridline,
or 0
to draw no gridlines.
Specify -1, which is the default,
to automatically compute the number of gridlines
based on other options.
An array of sizes (as data values, not pixels) between adjacent
gridlines. This option is only for numeric axes at this time,
but it is analogous to the gridlines.units.<unit>.interval
options which are used only for dates and times.
For linear scales, the default is [1, 2, 2.5, 5]
which means the gridline values can fall on every unit (1),
on even units (2), or on multiples of 2.5 or 5.
Any power of 10 times these values is also
considered (e.g. [10, 20, 25, 50] and [.1, .2, .25, .5]).
For log scales, the default is [1, 2, 5]
.
The minimum screen space, in pixels, between hAxis major gridlines.
The default for major gridlines is 40
for linear scales, and 20
for log scales.
If you specify the count
and not the minSpacing
, the minSpacing is computed from the count.
And conversely, if you specify the minSpacing
and not
the count
, the count is computed from the
minSpacing. If you specify both, the minSpacing
overrides.
All gridline and tick values must be a multiple of this
option's value. Note that, unlike for intervals, powers of 10
times the multiple are not considered.
So you can force ticks to be integers by specifying gridlines.multiple = 1
, or force ticks to be
multiples of 1000 by specifying gridlines.multiple = 1000
.
Overrides the default format for various aspects of date/datetime/timeofday data types when used with chart computed gridlines. Allows formatting for years, months, days, hours, minutes, seconds, and milliseconds.
General format is:
gridlines: { units: { years: {format: [/*format strings here*/]}, months: {format: [/*format strings here*/]}, days: {format: [/*format strings here*/]} hours: {format: [/*format strings here*/]} minutes: {format: [/*format strings here*/]} seconds: {format: [/*format strings here*/]}, milliseconds: {format: [/*format strings here*/]}, } }
Additional information can be found in Dates and Times .
An object with members to configure the minor gridlines on the horizontal axis, similar to the hAxis.gridlines option.
This option is only supported for a continuous
axis.
The color of the horizontal minor gridlines inside the chart area. Specify a valid HTML color string.
The minorGridlines.count
option is mostly deprecated, except for disabling minor gridlines
by setting the count to 0. The number of minor gridlines now depends
entirely on the interval between
major gridlines (see hAxis.gridlines.interval
)
and the minimum required space
(see hAxis.minorGridlines.minSpacing
).
The minorGridlines.interval option is like the major gridlines
interval option, but the interval that is chosen will always
be an even divisor of the major gridline interval.
The default interval for linear scales is [1, 1.5, 2, 2.5, 5]
,
and for log scales is [1, 2, 5]
.
The minimum required space, in pixels, between adjacent minor gridlines, and between minor and major gridlines. The default value is 1/2 the minSpacing of major gridlines for linear scales, and 1/5 the minSpacing for log scales.
Same as for major gridlines.multiple
.
Overrides the default format for various aspects of date/datetime/timeofday data types when used with chart computed minorGridlines. Allows formatting for years, months, days, hours, minutes, seconds, and milliseconds.
General format is:
gridlines: { units: { years: {format: [/*format strings here*/]}, months: {format: [/*format strings here*/]}, days: {format: [/*format strings here*/]} hours: {format: [/*format strings here*/]} minutes: {format: [/*format strings here*/]} seconds: {format: [/*format strings here*/]}, milliseconds: {format: [/*format strings here*/]}, } }
Additional information can be found in Dates and Times .
hAxis
property that makes the horizontal axis a logarithmic scale (requires all
values to be positive). Set to true for yes.
This option is only supported for a continuous
axis.
hAxis
property that makes the horizontal axis a logarithmic scale. Can be one of the following:
- null - No logarithmic scaling is performed.
- 'log' - Logarithmic scaling. Negative and zero values are not plotted. This option is the same as setting
hAxis: { logscale: true }
. - 'mirrorLog' - Logarithmic scaling in which negative and zero values are plotted. The plotted value of a negative number is the negative of the log of the absolute value. Values close to 0 are plotted on a linear scale.
This option is only supported for a continuous
axis.
Position of the horizontal axis text, relative to the chart area. Supported values: 'out', 'in', 'none'.
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
.
{color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}
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.
The viewWindow will be automatically expanded to
include the min and max ticks unless you specify a viewWindow.min
or viewWindow.max
to override.
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] }
This option is only supported for a continuous
axis.
hAxis
property that specifies the title of the horizontal axis.
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
.
{color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}
If false, will hide outermost labels rather than allow them to be cropped by the chart container. If true, will allow label cropping.
This option is only supported for a discrete
axis.
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).
The default is false
for dates and times.
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. If the angle is positive, the rotation
is counter-clockwise, and if negative, it is clockwise.
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. For dates and times, the default is 1.
Maximum number of lines allowed for the text labels. Labels can span multiple lines if they are too long, and the number of lines is, by default, limited by the height of the available space.
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 labels or dropping some of them).
hAxis.textStyle.fontSize
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.
Moves the max value of the horizontal axis to the specified value; this will be rightward in
most charts. Ignored if this is set to a value smaller than the maximum x-value of the data. hAxis.viewWindow.max
overrides this property.
This option is only supported for a continuous
axis.
Moves the min value of the horizontal axis to the specified value; this will be leftward in
most charts. Ignored if this is set to a value greater than the minimum x-value of the data. hAxis.viewWindow.min
overrides this property.
This option is only supported for a continuous
axis.
Specifies how to scale the horizontal axis to render the values within the chart area. The following string values are supported:
- 'pretty' - Scale the horizontal values so that the maximum and minimum data values are rendered a bit inside the left and right of the chart area. The viewWindow is expanded to the nearest major gridline for numbers, or the nearest minor gridline for dates and times.
- 'maximized' - Scale the horizontal values so that the maximum and minimum data values touch
the left and right of the chart area. This will cause
haxis.viewWindow.min
andhaxis.viewWindow.max
to be ignored. - 'explicit' - A deprecated option for specifying the left and right scale values of the
chart area. (Deprecated because it's redundant with
haxis.viewWindow.min
andhaxis.viewWindow.max
.) Data values outside these values will be cropped. You must specify anhAxis.viewWindow
object describing the maximum and minimum values to show.
This option is only supported for a continuous
axis.
haxis.viewWindow.min
and haxis.viewWindow.max
take precedence if used.Specifies the cropping range of the horizontal axis.
-
For a
continuous
axis:The maximum horizontal data value to render.
-
For a
discrete
axis: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 thatmin <= index < max
will be displayed.
Ignored when hAxis.viewWindowMode
is 'pretty' or 'maximized'.
-
For a
continuous
axis:The minimum horizontal data value to render.
-
For a
discrete
axis: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 thatmin <= index < max
will be displayed.
Ignored when hAxis.viewWindowMode
is 'pretty' or 'maximized'.
Height of the chart, in pixels.
Whether to guess the value of missing points. If true, it will guess the value of any missing data based on neighboring points. If false, it will leave a break in the line at the unknown point.
This is notsupported by Area
charts with the isStacked: true/'percent'/'relative'/'absolute'
option.
If set to true, series elements of the same type are stacked. Affects bar, column and area series only.
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}}
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'.
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'.
Initial selected zero-based page index of the legend.
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.
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
.
{color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}
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.
Data line width in pixels. Use zero to hide all lines and show only the points. You can
override values for individual series using the series
property.
The orientation of the chart. When set to 'vertical'
, rotates the axes of the
chart so that (for instance) a column chart becomes a bar chart, and an area chart grows
rightward instead of up:
The shape of individual data elements: 'circle', 'triangle', 'square', 'diamond', 'star', or 'polygon'. See the points documentation for examples.
Diameter of displayed points in pixels. Use zero to hide all points. You can override values
for individual series using the series
property. If you're using a trendline
, the pointSize
option will affect the width of the trendline unless you override
it with the trendlines.n.pointsize
option.
Determines whether points will be displayed. Set to false
to hide all points.
You can override values for individual series using the series
property. If
you're using a trendline
, the pointsVisible
option will affect the visibility of the points on all trendlines
unless you override it with the trendlines.n.pointsVisible
option.
This can also be overridden using the style role
in the form of "point {visible: true}"
.
When selectionMode
is 'multiple'
, users may select multiple data
points.
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:
-
annotations
- An object to be applied to annotations for this series. This can be used to control, for instance, thetextStyle
for the series:series: { 0: { annotations: { textStyle: {fontSize: 12, color: 'red' } } } }
See the various
annotations
options for a more complete list of what can be customized. -
areaOpacity
- Overrides the globalareaOpacity
for this series. -
color
- The color to use for this series. Specify a valid HTML color string. -
curveType
- Overrides the globalcurveType
value for this series. -
fallingColor.fill
- Overrides the globalcandlestick.fallingColor.fill
value for this series. -
fallingColor.stroke
- Overrides the globalcandlestick.fallingColor.stroke
value for this series. -
fallingColor.strokeWidth
- Overrides the globalcandlestick.fallingColor.strokeWidth
value for this series. -
labelInLegend
- The description of the series to appear in the chart legend. -
lineDashStyle
- Overrides the globallineDashStyle
value for this series. -
lineWidth
- Overrides the globallineWidth
value for this series. -
pointShape
- Overrides the globalpointShape
value for this series. -
pointSize
- Overrides the globalpointSize
value for this series. -
pointsVisible
- Overrides the globalpointsVisible
value for this series. -
risingColor.fill
- Overrides the globalcandlestick.risingColor.fill
value for this series. -
risingColor.stroke
- Overrides the globalcandlestick.risingColor.stroke
value for this series. -
risingColor.strokeWidth
- Overrides the globalcandlestick.risingColor.strokeWidth
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. -
type
- The type of marker for this series. Valid values are 'line', 'area', 'bars', 'candlesticks' and 'steppedArea'. Note that bars are actually vertical bars (columns). The default value is specified by the chart'sseriesType
option. -
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} }
The default line type for any series not specified in the series
property.
Available values are 'line', 'area', 'bars', 'candlesticks', and 'steppedArea'.
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'}
Text to display above the chart.
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.
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
.
{color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}
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}
If set to true
, allows the drawing of tooltips to flow outside of the bounds of
the chart on all sides.
Note: This only applies to HTML tooltips. If this is enabled with SVG tooltips, any overflow outside of the chart bounds will be cropped. See Customizing Tooltip Content for more details.
If set to true, use HTML-rendered (rather than SVG-rendered) tooltips. See Customizing Tooltip Content for more details.
Note:customization of the HTML tooltip content via the tooltip column data role is notsupported by the Bubble Chart visualization.
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.
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
.
{color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}
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.
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 } ]
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
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.
Specifies the color of the baseline for the vertical axis. Can be any HTML color string, for
example: 'red'
or '#00cc00'
.
The direction in which the values along the vertical axis grow. By default, low values
are on the bottom of the chart. Specify -1
to
reverse the order of the values.
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 .
In computing tick values and gridlines, several alternative
combinations of all the relevant gridline
options will be considered and alternatives will be rejected if the
formatted tick labels would be duplicated or overlap.
So you can specify format:"#"
if you want to only show integer tick values,
but be aware that if no alternative satisfies this condition,
no gridlines or ticks will be shown.
An object with members to configure the gridlines on the vertical axis. Note that vertical axis gridlines are drawn horizontally. To specify properties of this object, you can use object literal notation, as shown here:
{color: '#333', minSpacing: 20}
The color of the vertical gridlines inside the chart area. Specify a valid HTML color string.
The approximate number of horizontal gridlines inside the chart area.
If you specify a positive number for gridlines.count
,
it will be used to compute the minSpacing
between gridlines.
You can specify a value of 1
to only draw one gridline,
or 0
to draw no gridlines.
Specify -1, which is the default,
to automatically compute the number of gridlines
based on other options.
An array of sizes (as data values, not pixels) between adjacent
gridlines. This option is only for numeric axes at this time,
but it is analogous to the gridlines.units.<unit>.interval
options which are used only for dates and times.
For linear scales, the default is [1, 2, 2.5, 5]
which means the gridline values can fall on every unit (1),
on even units (2), or on multiples of 2.5 or 5.
Any power of 10 times these values is also
considered (e.g. [10, 20, 25, 50] and [.1, .2, .25, .5]).
For log scales, the default is [1, 2, 5]
.
The minimum screen space, in pixels, between hAxis major gridlines.
The default for major gridlines is 40
for linear scales, and 20
for log scales.
If you specify the count
and not the minSpacing
, the minSpacing is computed from the count.
And conversely, if you specify the minSpacing
and not
the count
, the count is computed from the
minSpacing. If you specify both, the minSpacing
overrides.
All gridline and tick values must be a multiple of this
option's value. Note that, unlike for intervals, powers of 10
times the multiple are not considered.
So you can force ticks to be integers by specifying gridlines.multiple = 1
, or force ticks to be
multiples of 1000 by specifying gridlines.multiple = 1000
.
Overrides the default format for various aspects of date/datetime/timeofday data types when used with chart computed gridlines. Allows formatting for years, months, days, hours, minutes, seconds, and milliseconds.
General format is:
gridlines: { units: { years: {format: [/*format strings here*/]}, months: {format: [/*format strings here*/]}, days: {format: [/*format strings here*/]}, hours: {format: [/*format strings here*/]}, minutes: {format: [/*format strings here*/]}, seconds: {format: [/*format strings here*/]}, milliseconds: {format: [/*format strings here*/]} } }
Additional information can be found in Dates and Times .
An object with members to configure the minor gridlines on the vertical axis, similar to the vAxis.gridlines option.
The color of the vertical minor gridlines inside the chart area. Specify a valid HTML color string.
The minorGridlines.count option is mostly deprecated, except for disabling minor gridlines by setting the count to 0. The number of minor gridlines depends on the interval between major gridlines (see vAxis.gridlines.interval) and the minimum required space (see vAxis.minorGridlines.minSpacing).
The minorGridlines.interval option is like the major gridlines
interval option, but the interval that is chosen will always
be an even divisor of the major gridline interval.
The default interval for linear scales is [1, 1.5, 2, 2.5, 5]
,
and for log scales is [1, 2, 5]
.
The minimum required space, in pixels, between adjacent minor gridlines, and between minor and major gridlines. The default value is 1/2 the minSpacing of major gridlines for linear scales, and 1/5 the minSpacing for log scales.
Same as for major gridlines.multiple
.
Overrides the default format for various aspects of date/datetime/timeofday data types when used with chart computed minorGridlines. Allows formatting for years, months, days, hours, minutes, seconds, and milliseconds.
General format is:
gridlines: { units: { years: {format: [/*format strings here*/]}, months: {format: [/*format strings here*/]}, days: {format: [/*format strings here*/]} hours: {format: [/*format strings here*/]} minutes: {format: [/*format strings here*/]} seconds: {format: [/*format strings here*/]}, milliseconds: {format: [/*format strings here*/]}, } }
Additional information can be found in Dates and Times .
If true, makes the vertical axis a logarithmic scale. Note: All values must be positive.
vAxis
property that makes the vertical axis a logarithmic scale. Can be one of the following:
- null - No logarithmic scaling is performed.
- 'log' - Logarithmic scaling. Negative and zero values are not plotted. This option is the same as setting
vAxis: { logscale: true }
. - 'mirrorLog' - Logarithmic scaling in which negative and zero values are plotted. The plotted value of a negative number is the negative of the log of the absolute value. Values close to 0 are plotted on a linear scale.
This option is only supported for a continuous
axis.
Position of the vertical axis text, relative to the chart area. Supported values: 'out', 'in', 'none'.
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
.
{color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}
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.
The viewWindow will be automatically expanded to
include the min and max ticks unless you specify a viewWindow.min
or viewWindow.max
to override.
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
property that specifies a title for the vertical axis.
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
.
{color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>}
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.
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.
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 bottom and top of the chart area. The viewWindow is expanded to the nearest major gridline for numbers, or the nearest minor gridline for dates and times.
- '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
andvaxis.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
andvaxis.viewWindow.max
. Data values outside these values will be cropped. You must specify avAxis.viewWindow
object describing the maximum and minimum values to show.
vaxis.viewWindow.min
and vaxis.viewWindow.max
take precedence if used.Specifies the cropping range of the vertical axis.
The maximum vertical data value to render.
Ignored when vAxis.viewWindowMode
is 'pretty' or 'maximized'.
The minimum vertical data value to render.
Ignored when vAxis.viewWindowMode
is 'pretty' or 'maximized'.
Width of the chart, in pixels.
Methods
draw(data, options)
Draws the chart. The chart accepts further method calls only after the ready
event is fired. Extended description
.
getAction(actionID)
Returns the tooltip action object with the requested actionID
.
getBoundingBox(id)
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()
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()
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(xPosition, optional_axis_index)
Returns the horizontal data value at xPosition
, which is a pixel offset from the
chart container's left edge. Can be negative.
Example: chart.getChartLayoutInterface().getHAxisValue(400)
.
Call this after the chart is drawn.
getImageURI()
Returns the chart serialized as an image URI.
Call this after the chart is drawn.
See Printing PNG Charts .
getSelection()
Returns an array of the selected chart entities.
Selectable entities are
points, bars, steps, annotations, legend entries and categories
.
A point, bar, step, or annotation 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(yPosition, optional_axis_index)
Returns the vertical data value at yPosition
, which is a pixel offset down
from the chart container's top edge. Can be negative.
Example: chart.getChartLayoutInterface().getVAxisValue(300)
.
Call this after the chart is drawn.
getXLocation(dataValue, optional_axis_index)
Returns the pixel x-coordinate of dataValue
relative to the left edge of the
chart's container.
Example: chart.getChartLayoutInterface().getXLocation(400)
.
Call this after the chart is drawn.
getYLocation(dataValue, optional_axis_index)
Returns the pixel y-coordinate of dataValue
relative to the top edge of the
chart's container.
Example: chart.getChartLayoutInterface().getYLocation(300)
.
Call this after the chart is drawn.
removeAction(actionID)
Removes the tooltip action with the requested actionID
from the chart.
none
setAction(action)
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
.
none
setSelection()
Selects the specified chart entities. Cancels any previous selection.
Selectable entities are
points, bars, steps, annotations, legend entries and categories
.
A point, bar, step, or annotation 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()
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 .
animationfinish
Fired when transition animation is complete.
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.
error
Fired when an error occurs when attempting to render the chart.
legendpagination
Fired when the user clicks legend pagination arrows. Passes back the current legend zero-based page index and the total number of pages.
onmouseover
Fired when the user mouses over a visual entity. Passes back the row and column indices of the corresponding data table element.
onmouseout
Fired when the user mouses away from a visual entity. Passes back the row and column indices of the corresponding data table element.
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.
select
Fired when the user clicks a visual entity. To learn what has been selected, call getSelection()
.
Data Policy
All code and data are processed and rendered in the browser. No data is sent to any server.