Overview
A bubble chart that is rendered within the browser using SVG or VML . Displays tips when hovering over bubbles.
A bubble chart is used to visualize a data set with two to four dimensions. The first two dimensions are visualized as coordinates, the third as color and the fourth as size.
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(drawSeriesChart); function drawSeriesChart() { var data = google.visualization.arrayToDataTable([ ['ID', 'Life Expectancy', 'Fertility Rate', 'Region', 'Population'], ['CAN', 80.66, 1.67, 'North America', 33739900], ['DEU', 79.84, 1.36, 'Europe', 81902307], ['DNK', 78.6, 1.84, 'Europe', 5523095], ['EGY', 72.73, 2.78, 'Middle East', 79716203], ['GBR', 80.05, 2, 'Europe', 61801570], ['IRN', 72.49, 1.7, 'Middle East', 73137148], ['IRQ', 68.09, 4.77, 'Middle East', 31090763], ['ISR', 81.55, 2.96, 'Middle East', 7485600], ['RUS', 68.6, 1.54, 'Europe', 141850000], ['USA', 78.09, 2.05, 'North America', 307007000] ]); var options = { title: 'Fertility rate vs life expectancy in selected countries (2010).' + ' X=Life Expectancy, Y=Fertility, Bubble size=Population, Bubble color=Region', hAxis: {title: 'Life Expectancy'}, vAxis: {title: 'Fertility Rate'}, bubble: {textStyle: {fontSize: 11}} }; var chart = new google.visualization.BubbleChart(document.getElementById('series_chart_div')); chart.draw(data, options); } </script> </head> <body> <div id="series_chart_div" style="width: 900px; height: 500px;"></div> </body> </html>
Color By Numbers
You can use the colorAxis
option to color the bubbles
in proportion to a value, as shown in the example below.
< 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 ( drawChart ); function drawChart () { var data = google . visualization . arrayToDataTable ([ [ 'ID' , 'X' , 'Y' , 'Temperature' ], [ '' , 80 , 167 , 120 ], [ '' , 79 , 136 , 130 ], [ '' , 78 , 184 , 50 ], [ '' , 72 , 278 , 230 ], [ '' , 81 , 200 , 210 ], [ '' , 72 , 170 , 100 ], [ '' , 68 , 477 , 80 ] ]); var options = { colorAxis : { colors : [ 'yellow' , 'red' ]} }; var chart = new google . visualization . BubbleChart ( document . getElementById ( 'chart_div' )); chart . draw ( data , options ); } < / script > < / head > < body > < div id = "chart_div" style = "width: 900px; height: 500px;" >< / div > < / body > < / html >
Customizing Labels
You can control the bubble typeface, font, and color with
the bubble.textStyle
option:
var options = { title : 'Fertility rate vs life expectancy in selected countries (2010).' + ' X=Life Expectancy, Y=Fertility, Bubble size=Population, Bubble color=Region' , hAxis : { title : 'Life Expectancy' }, vAxis : { title : 'Fertility Rate' }, bubble : { textStyle : { fontSize : 12 , fontName : 'Times-Roman' , color : 'green' , bold : true , italic : true } } };
< 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 ( drawChart ); function drawChart () { var data = google . visualization . arrayToDataTable ([ [ 'ID' , 'Life Expectancy' , 'Fertility Rate' , 'Region' , 'Population' ], [ 'CAN' , 80.66 , 1.67 , 'North America' , 33739900 ], [ 'DEU' , 79.84 , 1.36 , 'Europe' , 81902307 ], [ 'DNK' , 78.6 , 1.84 , 'Europe' , 5523095 ], [ 'EGY' , 72.73 , 2.78 , 'Middle East' , 79716203 ], [ 'GBR' , 80.05 , 2 , 'Europe' , 61801570 ], [ 'IRN' , 72.49 , 1.7 , 'Middle East' , 73137148 ], [ 'IRQ' , 68.09 , 4.77 , 'Middle East' , 31090763 ], [ 'ISR' , 81.55 , 2.96 , 'Middle East' , 7485600 ], [ 'RUS' , 68.6 , 1.54 , 'Europe' , 141850000 ], [ 'USA' , 78.09 , 2.05 , 'North America' , 307007000 ] ]); var options = { title : 'Fertility rate vs life expectancy in selected countries (2010).' + ' X=Life Expectancy, Y=Fertility, Bubble size=Population, Bubble color=Region' , hAxis : { title : 'Life Expectancy' }, vAxis : { title : 'Fertility Rate' }, bubble : { textStyle : { fontSize : 12 , fontName : 'Times-Roman' , color : 'green' , bold : true , italic : true } } }; var chart = new google . visualization . BubbleChart ( document . getElementById ( 'textstyle' )); chart . draw ( data , options ); } < / script > < / head > < body > < div id = "textstyle" style = "width: 900px; height: 500px;" >< / div > < / body > < / html >
Labels on the above chart are hard to read, and one of the reasons
is the white space around them. That's called an aura
, and if
you'd prefer your charts without them, you can set bubble.textStyle.auraColor
to 'none'
.
var options = { title : 'Fertility rate vs life expectancy in selected countries (2010).' + ' X=Life Expectancy, Y=Fertility, Bubble size=Population, Bubble color=Region' , hAxis : { title : 'Life Expectancy' }, vAxis : { title : 'Fertility Rate' }, bubble : { textStyle : { auraColor : 'none' } } };
< 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 ( drawChart ); function drawChart () { var data = google . visualization . arrayToDataTable ([ [ 'ID' , 'Life Expectancy' , 'Fertility Rate' , 'Region' , 'Population' ], [ 'CAN' , 80.66 , 1.67 , 'North America' , 33739900 ], [ 'DEU' , 79.84 , 1.36 , 'Europe' , 81902307 ], [ 'DNK' , 78.6 , 1.84 , 'Europe' , 5523095 ], [ 'EGY' , 72.73 , 2.78 , 'Middle East' , 79716203 ], [ 'GBR' , 80.05 , 2 , 'Europe' , 61801570 ], [ 'IRN' , 72.49 , 1.7 , 'Middle East' , 73137148 ], [ 'IRQ' , 68.09 , 4.77 , 'Middle East' , 31090763 ], [ 'ISR' , 81.55 , 2.96 , 'Middle East' , 7485600 ], [ 'RUS' , 68.6 , 1.54 , 'Europe' , 141850000 ], [ 'USA' , 78.09 , 2.05 , 'North America' , 307007000 ] ]); var options = { title : 'Fertility rate vs life expectancy in selected countries (2010).' + ' X=Life Expectancy, Y=Fertility, Bubble size=Population, Bubble color=Region' , hAxis : { title : 'Life Expectancy' }, vAxis : { title : 'Fertility Rate' }, bubble : { textStyle : { auraColor : 'none' , } } }; var chart = new google . visualization . BubbleChart ( document . getElementById ( 'noAura' )); chart . draw ( data , options ); } < / script > < / head > < body > < div id = "noAura" 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.BubbleChart
.
var visualization = new google . visualization . BubbleChart ( container );
Data Format
Rows:Each row in the table represents a single bubble.
Columns:
- string
A string that identifies bubbles in the same series. Use the same value to identify all bubbles that belong to the same series; bubbles in the same series will be assigned the same color. Series can be configured using theseries
option. - number
A value that is mapped to an actual color on a gradient scale using thecolorAxis
option.
sizeAxis
option.Configuration Options
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.
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.
An object with members to configure the visual properties of the bubbles.
The opacity of the bubbles, where 0 is fully transparent and 1 is fully opaque.
The color of the bubbles' stroke.
An object that specifies the bubble text style. The object has this format:
{color: <string>, fontName: <string>, fontSize: <number>}
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 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']
.
An object that specifies a mapping between color column values and colors or a gradient scale. To specify properties of this object, you can use object literal notation, as shown here:
{minValue: 0, colors: ['#FF0000', '#00FF00']}
If present, specifies a minimum value for chart color data. Color data values of this value
and lower will be rendered as the first color in the colorAxis.colors
range.
If present, specifies a maximum value for chart color data. Color data values of this value
and higher will be rendered as the last color in the colorAxis.colors
range.
If present, controls how values are associated with colors. Each value is associated with the
corresponding color in the colorAxis.colors
array. These values apply to the
chart color data. Coloring is done according to a gradient of the values specified here. Not
specifying a value for this option is equivalent to specifying [minValue, maxValue].
Colors to assign to values in the visualization. An array of strings, where each element is
an HTML color string, for example: colorAxis: {colors:['red','#004411']}
. You
must have at least two values; the gradient will include all your values, plus calculated
intermediary values, with the first color as the smallest value, and the last color as the
highest.
An object that specifies the style of the gradient color legend.
Position of the legend. Can be one of the following:
- 'top' - Above the chart.
- 'bottom' - Below the chart.
- 'in' - Inside the chart, at the top.
- 'none' - No legend is displayed.
An object that specifies the legend text style. The object has this format:
{color: <string>, fontName: <string>, fontSize: <number>}
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>}
A format string for numeric labels. This is a subset of the ICU pattern set
.
For instance, {numberFormat:'.##'}
will display values "10.66",
"10.6", and "10.0" for values 10.666, 10.6, and 10.
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 explorer
option allows users to pan and zoom Google charts. explorer: {}
provides the default explorer behavior, enabling users to pan
horizontally and vertically by dragging, and to zoom in and out by scrolling.
This feature is experimental and may change in future releases.
Note: The explorer only works with continuous axes (such as numbers or dates).
The Google Charts explorer supports three actions:
-
dragToPan
: Drag to pan around the chart horizontally and vertically. To pan only along the horizontal axis, useexplorer: { axis: 'horizontal' }
. Similarly for the vertical axis. -
dragToZoom
: The explorer's default behavior is to zoom in and out when the user scrolls. Ifexplorer: { actions: ['dragToZoom', 'rightClickToReset'] }
is used, dragging across a rectangular area zooms into that area. We recommend usingrightClickToReset
wheneverdragToZoom
is used. Seeexplorer.maxZoomIn
,explorer.maxZoomOut
, andexplorer.zoomDelta
for zoom customizations. -
rightClickToReset
: Right clicking on the chart returns it to the original pan and zoom level.
By default, users can pan both horizontally and vertically when the explorer
option is used. If you want to users to only pan horizontally, use explorer: { axis: 'horizontal' }
. Similarly, explorer: { axis: 'vertical' }
enables vertical-only panning.
By default, users can pan all around, regardless of where the data is. To ensure that users
don't pan beyond the original chart, use explorer: { keepInBounds: true }
.
The maximum that the explorer can zoom in. By default, users will be able to zoom in enough
that they'll see only 25% of the original view. Setting explorer: { maxZoomIn: .5 }
would let users zoom in only far enough to see half
of the original view.
The maximum that the explorer can zoom out. By default, users will be able to zoom out far
enough that the chart will take up only 1/4 of the available space. Setting explorer: { maxZoomOut: 8 }
would let users zoom out far enough that the chart
would take up only 1/8 of the available space.
When users zoom in or out, explorer.zoomDelta
determines how much they zoom by.
The smaller the number, the smoother and slower the zoom.
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.
The color of the baseline for the horizontal axis. Can be any HTML color string, for example: 'red'
or '#00cc00'
.
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 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 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}
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.
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.
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
).
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.
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.
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] }
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>}
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.
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.
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.
haxis.viewWindow.min
and haxis.viewWindow.max
take precedence if used.Specifies the cropping range of the horizontal axis.
The maximum horizontal data value to render.
Ignored when hAxis.viewWindowMode
is 'pretty' or 'maximized'.
The minimum horizontal data value to render.
Ignored when hAxis.viewWindowMode
is 'pretty' or 'maximized'.
Height of the chart, in pixels.
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>}
When selectionMode
is 'multiple'
, users may select multiple data
points.
An object of objects, where the keys are series names (the values in the Color column) and each object describing the format of the corresponding series in the chart. If a series or a value is not specified, the global value will be used. Each object supports the following properties:
-
color
- The color to use for this series. Specify a valid HTML color string. -
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.
series: {'Europe': {color: 'green'}}
An object with members to configure how values are associated with bubble size. To specify properties of this object, you can use object literal notation, as shown here:
{minValue: 0, maxSize: 20}
Maximum radius of the largest possible bubble, in pixels.
The size value (as appears in the chart data) to be mapped to sizeAxis.maxSize
.
Larger values will be cropped to this value.
Mininum radius of the smallest possible bubble, in pixels.
The size value (as appears in the chart data) to be mapped to sizeAxis.minSize
.
Smaller values will be cropped to this value.
If true, sorts the bubbles by size so the smaller bubbles appear above the larger bubbles. If false, bubbles are sorted according to their order in the DataTable.
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, 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.
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.
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.
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).
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.
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 bubbles.
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 bubbles.
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. A bubble correlates to a row in the data table (column index is null).
onmouseout
Fired when the user mouses away from a visual entity. Passes back the row and column indices of the corresponding data table element. A bubble correlates to a row in the data table (column index is null).
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.