Visualization: Line Chart
Overview
A line chart that is rendered within the browser using SVG or VML. Displays tips when hovering over points.
Example
class="framebox inherit-locale " src="https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart_880b8985c195f3ca5ec9b8b39140b359.frame?hl=zh-cn" style="border-width: 0px; margin: 0px; padding: 0px; font-weight: inherit; font-style: inherit; font-size: 14px; font-family: inherit; vertical-align: baseline; overflow: auto; width: 924px; height: 500px;"><html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
Curving the Lines
You can smooth the lines by setting the curveType
option to function
:
The code to generate this chart is the same as the one above, except that the options now look like so:
var options = {
title: 'Company Performance',
curveType: 'function',
legend: { position: 'bottom' }
};
Loading
The google.load
package name is "corechart"
.
google.load("visualization", "1", {packages: ["corechart"]});
The visualization's class name is google.visualization.LineChart
.
var visualization = new google.visualization.LineChart(container);
Data Format
Rows: Each row in the table represents a set of data points with the same x-axis location.
Columns:
Column 0 | Column 1 | ... | Column N | |
---|---|---|---|---|
Purpose: |
| Line 1 values | ... | Line N values |
Data Type: |
| number | ... | number |
Role: | domain | data | ... | data |
Optional column roles: | ... |
Configuration Options
Name | Type | Default | Description |
---|---|---|---|
aggregationTarget | string | 'auto' | How multiple data selections are rolled up into tooltips:
aggregationTarget will often be used in tandem with selectionMode andtooltip.trigger , e.g.: var options = { // Allow multiple simultaneous selections. selectionMode: 'multiple', // Trigger tooltips on selections. tooltip: { trigger: 'selection' }, // Group selections by x-value. aggregationTarget: 'category', }; |
animation.duration | number | 0 | The duration of the animation, in milliseconds. For details, see the animation documentation. |
animation.easing | string | 'linear' | The easing function applied to the animation. The following options are available:
|
annotations.boxStyle | object | null | For charts that support annotations, the annotations.boxStyle object controls the appearance of the boxes surrounding annotations: var options = { annotations: { boxStyle: { stroke: '#888', // Color of the box outline. strokeWidth: 1, // Thickness of the box outline. rx: 10, // x-radius of the corner curvature. ry: 10, // y-radius of the corner curvature. gradient: { // Attributes for linear gradient fill. color1: '#fbf6a7', // Start color for gradient. color2: '#33b679', // Finish color for gradient. x1: '0%', y1: '0%', // Where on the boundary to start and end the x2: '100%', y2: '100%', // color1/color2 gradient, relative to the // upper left corner of the boundary. useObjectBoundingBoxUnits: true // If true, the boundary for x1, y1, // x2, and y2 is the box. If false, // it's the entire chart. } } } };class="framebox inherit-locale " src="https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart_0e5dbb5525ed2403ed0b7cdec7ebda65.frame?hl=zh-cn" style="border-width: 0px; margin: 0px; padding: 0px; font-weight: inherit; font-style: inherit; font-size: 14px; font-family: inherit; vertical-align: baseline; overflow: auto; width: 523px; height: 150px;"> This option is currently supported for area, bar, column, combo, line, and scatter charts. It is not supported by the Annotation Chart. |
annotations.highContrast | boolean | true | For charts that support annotations, the 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: class="framebox inherit-locale " src="https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart_5f727dc2c0f23ea2703ef7a2ba0f0239.frame?hl=zh-cn" style="border-width: 0px; margin: 0px; padding: 0px; font-weight: inherit; font-style: inherit; font-size: 14px; font-family: inherit; vertical-align: baseline; overflow: auto; width: 523px; height: 150px;"> |
annotations.textStyle | object | null | For charts that support annotations, the 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, color: '#871b47', // The color of the text. auraColor: '#d799ae', // The color of the text outline. opacity: 0.8 // The transparency of the text. } } };class="framebox inherit-locale " src="https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart_e2c514856282c544e559cce72a082cf9.frame?hl=zh-cn" style="border-width: 0px; margin: 0px; padding: 0px; font-weight: inherit; font-style: inherit; font-size: 14px; font-family: inherit; vertical-align: baseline; overflow: auto; width: 523px; height: 150px;"> This option is currently supported for area, bar, column, combo, line, and scatter charts. It is not supported by the Annotation Chart. |
axisTitlesPosition | string | 'out' | Where to place the axis titles, compared to the chart area. Supported values:
|
backgroundColor | string or object | 'white' | The background color for the main area of the chart. Can be either a simple HTML color string, for example: 'red' or '#00cc00' , or an object with the following properties. |
backgroundColor.stroke | string | '#666' | The color of the chart border, as an HTML color string. |
backgroundColor.strokeWidth | number | 0 | The border width, in pixels. |
backgroundColor.fill | string | 'white' | The chart fill color, as an HTML color string. |
chartArea | Object | null | An object with members to configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends). Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage. Example: chartArea:{left:20,top:0,width:'50%',height:'75%'} |
chartArea.backgroundColor | string or object | 'white' | Chart area background color. When a string is used, it can be either a hex string (e.g., '#fdc') or an English color name. When an object is used, the following properties can be provided:
|
chartArea.left | number or string | auto | How far to draw the chart from the left border. |
chartArea.top | number or string | auto | How far to draw the chart from the top border. |
chartArea.width | number or string | auto | Chart area width. |
chartArea.height | number or string | auto | Chart area height. |
colors | Array of strings | default colors | The colors to use for the chart elements. An array of strings, where each element is an HTML color string, for example: colors:['red','#004411'] . |
crosshair | object | null | An object containing the crosshair properties for the chart. |
crosshair.color | string | default | The crosshair color, expressed as either a color name (e.g., "blue") or an RGB value (e.g., "#adf"). |
crosshair.focused | object | default | An object containing the crosshair properties upon focus. Example: crosshair: { focused: { color: '#3bc', opacity: 0.8 } } |
crosshair.opacity | number | 1.0 | The crosshair opacity, with 0.0 being fully transparent and 1.0 fully opaque. |
crosshair.orientation | string | 'both' | The crosshair orientation, which can be 'vertical' for vertical hairs only, 'horizontal' for horizontal hairs only, or 'both' for traditional crosshairs. |
crosshair.selected | object | default | An object containing the crosshair properties upon selection. Example: crosshair: { selected: { color: '#3bc', opacity: 0.8 } } |
crosshair.trigger | string | 'both' | When to display crosshairs: on 'focus' , 'selection' , or 'both' . |
curveType | string | 'none' | Controls the curve of the lines when the line width is not zero. Can be one of the following:
|
dataOpacity | number | 1.0 | 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 whereselecting 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.) |
enableInteractivity | boolean | true | Whether the chart throws user-based events or reacts to user interaction. If false, the chart will not throw 'select' or other interaction-based events (but will throw ready or error events), and will not display hovertext or otherwise change depending on user input. |
explorer | Object | null | The Note: The explorer only works with continuous axes (such as numbers or dates). |
explorer.actions | Array of strings | ['dragToPan', 'rightClickToReset'] | The Google Charts explorer supports three actions:
|
explorer.axis | string | both horizontal and vertical panning | 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. |
explorer.keepInBounds | boolean | false | 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 } . |
explorer.maxZoomIn | number | 0.25 | 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. |
explorer.maxZoomOut | number | 4 | 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. |
explorer.zoomDelta | number | 1.5 | When users zoom in or out, explorer.zoomDelta determines how much they zoom by. The smaller the number, the smoother and slower the zoom. |
focusTarget | string | 'datum' | The type of the entity that receives focus on mouse hover. Also affects which entity is selected by mouse click, and which data table element is associated with events. Can be one of the following:
In focusTarget 'category' the tooltip displays all the category values. This may be useful for comparing values of different series. |
fontSize | number | automatic | The default font size, in pixels, of all text in the chart. You can override this using properties for specific chart elements. |
fontName | string | 'Arial' | The default font face for all text in the chart. You can override this using properties for specific chart elements. |
forceIFrame | boolean | false | Draws the chart inside an inline frame. (Note that on IE8, this option is ignored; all IE8 charts are drawn in i-frames.) |
hAxis | Object | null | An object with members to configure various horizontal axis elements. To specify properties of this object, you can use object literal notation, as shown here: {title: 'Hello', titleTextStyle: {color: '#FF0000'}} |
hAxis.baseline | number | automatic | The baseline for the horizontal axis. This option is only supported for a |
hAxis.baselineColor | number | 'black' | 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 |
hAxis.direction | 1 or -1 | 1 | The direction in which the values along the horizontal axis grow. Specify -1 to reverse the order of the values. |
hAxis.format | string | auto | 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, For date axis labels, this is a subset of the date formatting ICU pattern set. For instance, 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. This option is only supported for a |
hAxis.gridlines | Object | null | An object with members to configure the gridlines on the horizontal axis. To specify properties of this object, you can use object literal notation, as shown here: {color: '#333', count: 4} This option is only supported for a |
hAxis.gridlines.color | string | '#CCC' | The color of the horizontal gridlines inside the chart area. Specify a valid HTML color string. |
hAxis.gridlines.count | number | 5 | The number of horizontal gridlines inside the chart area. Minimum value is 2. Specify -1 to automatically compute the number of gridlines. |
hAxis.minorGridlines | Object | null | 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 |
hAxis.minorGridlines.color | string | A blend of the gridline and background colors | The color of the horizontal minor gridlines inside the chart area. Specify a valid HTML color string. |
hAxis.minorGridlines.count | number | 0 | The number of horizontal minor gridlines between two regular gridlines. |
hAxis.logScale | boolean | false | 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 |
hAxis.textPosition | string | 'out' | Position of the horizontal axis text, relative to the chart area. Supported values: 'out', 'in', 'none'. |
hAxis.textStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the horizontal axis text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
hAxis.ticks | Array of elements | auto | Replaces the automatically generated X-axis ticks with the specified array. Each element of the array should be either a valid tick value (such as a number, date, datetime, or timeofday), or an object. If it's an object, it should have a Examples:
This option is only supported for a |
hAxis.title | string | null | hAxis property that specifies the title of the horizontal axis. |
hAxis.titleTextStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the horizontal axis title text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
hAxis.allowContainerBoundaryTextCufoff | boolean | false | If false, will hide outermost labels rather than allow them to be cropped by the chart container. If true, will allow label cropping. This option is only supported for a |
hAxis.slantedText | boolean | automatic | If true, draw the horizontal axis text at an angle, to help fit more text along the axis; if false, draw horizontal axis text upright. Default behavior is to slant text if it cannot all fit when drawn upright. Notice that this option is available only when thehAxis.textPosition is set to 'out' (which is the default). This option is only supported for a |
hAxis.slantedTextAngle | number, 1—90 | 30 | The angle of the horizontal axis text, if it's drawn slanted. Ignored ifhAxis.slantedText is false , or is in auto mode, and the chart decided to draw the text horizontally. This option is only supported for a |
hAxis.maxAlternation | number | 2 | Maximum number of levels of horizontal axis text. If axis text labels become too crowded, the server might shift neighboring labels up or down in order to fit labels closer together. This value specifies the most number of levels to use; the server can use fewer levels, if labels can fit without overlapping. This option is only supported for a |
hAxis.maxTextLines | number | auto | Maximum number of lines allowed for the text labels. Labels can span multiple lines if they are too long, and the nuber of lines is, by default, limited by the height of the available space. This option is only supported for a |
hAxis.minTextSpacing | number | The value ofhAxis.textStyle.fontSize | Minimum horizontal spacing, in pixels, allowed between two adjacent text labels. If the labels are spaced too densely, or they are too long, the spacing can drop below this threshold, and in this case one of the label-unclutter measures will be applied (e.g, truncating the lables or dropping some of them). This option is only supported for a |
hAxis.showTextEvery | number | automatic | How many horizontal axis labels to show, where 1 means show every label, 2 means show every other label, and so on. Default is to try to show as many labels as possible without overlapping. This option is only supported for a |
hAxis.maxValue | number | automatic | 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 |
hAxis.minValue | number | automatic | 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 |
hAxis.viewWindowMode | string | Equivalent to 'pretty', buthaxis.viewWindow.min andhaxis.viewWindow.max take precedence if used. | Specifies how to scale the horizontal axis to render the values within the chart area. The following string values are supported:
This option is only supported for a |
hAxis.viewWindow | Object | null | Specifies the cropping range of the horizontal axis. |
hAxis.viewWindow.max | number | auto |
hAxis.viewWindowMode is 'pretty' or 'maximized'. |
hAxis.viewWindow.min | number | auto |
hAxis.viewWindowMode is 'pretty' or 'maximized'. |
height | number | height of the containing element | Height of the chart, in pixels. |
interpolateNulls | boolean | false | 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. |
legend | Object | null | An object with members to configure various aspects of the legend. To specify properties of this object, you can use object literal notation, as shown here: |
legend.alignment | string | automatic | Alignment of the legend. Can be one of the following:
Start, center, and end are relative to the style -- vertical or horizontal -- of the legend. For example, in a 'right' legend, 'start' and 'end' are at the top and bottom, respectively; for a 'top' legend, 'start' and 'end' would be at the left and right of the area, respectively. The default value depends on the legend's position. For 'bottom' legends, the default is 'center'; other legends default to 'start'. |
legend.maxLines | number | 1 | Maximum number of lines in the legend. Set this to a number greater than one to add lines to your legend. Note: The exact logic used to determine the actual number of lines rendered is still in flux. This option currently works only when legend.position is 'top'. |
legend.position | string | 'right' | Position of the legend. Can be one of the following:
|
legend.textStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the legend text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
lineWidth | number | 2 | 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. |
orientation | string | 'horizontal' | 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:class="framebox inherit-locale " src="https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart_0643a296d9622d0d29263d915cbca06f.frame?hl=zh-cn" style="border-width: 0px; margin: 0px; padding: 0px; font-weight: inherit; font-style: inherit; font-size: 14px; font-family: inherit; vertical-align: baseline; overflow: auto; width: 523px; height: 150px;"> |
pointShape | string | 'circle' | The shape of individual data elements: 'circle', 'triangle', 'square', 'diamond', 'star', or 'polygon'. See the points documentation for examples. |
pointSize | number | 0 | Diameter of displayed points in pixels. Use zero to hide all points. You can override values for individual series using the series property. |
reverseCategories | boolean | false | If set to true, will draw series from right to left. The default is to draw left-to-right. |
selectionMode | string | 'single' | When selectionMode is 'multiple' , users may select multiple data points. |
series | Array of objects, or object with nested objects | {} | An array of objects, each describing the format of the corresponding series in the chart. To use default values for a series, specify an empty object {}. If a series or a value is not specified, the global value will be used. Each object supports the following properties:
You can specify either an array of objects, each of which applies to the series in the order given, or you can specify an object where each child has a numeric key indicating which series it applies to. For example, the following two declarations are identical, and declare the first series as black and absent from the legend, and the fourth as red and absent from the legend: series: [{color: 'black', visibleInLegend: false}, {}, {}, {color: 'red', visibleInLegend: false}] series: {0:{color: 'black', visibleInLegend: false}, 3:{color: 'red', visibleInLegend: false}} |
theme | string | null | A theme is a set of predefined option values that work together to achieve a specific chart behavior or visual effect. Currently only one theme is available:
|
title | string | no title | Text to display above the chart. |
titlePosition | string | 'out' | Where to place the chart title, compared to the chart area. Supported values:
|
titleTextStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the title text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
tooltip | Object | null | An object with members to configure various tooltip elements. To specify properties of this object, you can use object literal notation, as shown here: {textStyle: {color: '#FF0000'}, showColorCode: true} |
tooltip.isHtml | boolean | false | If set to true, use HTML-rendered (rather than SVG-rendered) tooltips. SeeCustomizing Tooltip Content for more details. |
tooltip.showColorCode | boolean | automatic | If true, show colored squares next to the series information in the tooltip. The default is true when focusTarget is set to 'category', otherwise the default is false. |
tooltip.textStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the tooltip text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
tooltip.trigger | string | 'focus' | The user interaction that causes the tooltip to be displayed:
|
trendlines | Object | null | Displays trendlines on the charts that support them. By default, linear trendlines are used, but this can be customized with the
Trendlines are specified on a per-series basis, so most of the time your options will look like this: var options = { trendlines: { 0: { type: 'linear', color: 'green', lineWidth: 3, opacity: 0.3, showR2: true, visibleInLegend: true } } }
|
trendlines.n.color | string | default series color | The color of the trendline, expressed as either an English color name or a hex string. |
trendlines.n.degree | number | 3 | For trendlines of type: 'polynomial' , the degree of the polynomial (2 for quadratic,3 for cubic, and so on). (The default degree may change from 3 to 2 in an upcoming release of Google Charts.) |
trendlines.n.labelInLegend | string | null | If set, the trendline will appear in the legend as this string. |
trendlines.n.lineWidth | number | 2 | The line width of the trendline, in pixels. |
trendlines.n.opacity | number | 1.0 | The transparency of the trendline, from 0.0 (transparent) to 1.0 (opaque). |
trendlines.n.pointSize | number | 1 | Trendlines are constucted by stamping a bunch of dots on the chart; this rarely-needed option lets you customize the size of the dots. The trendlines lineWidth will usually be preferable. |
trendlines.n.showR2 | boolean | false | Whether to show the coefficient of determination in the legend or trendline tooltip. |
trendlines.n.type | string | linear | Whether the trendlines is 'linear' (the default), 'exponential' , or 'polynomial' . |
trendlines.n.visibleInLegend | boolean | false | Whether the trendline equation appears in the legend. (It will appear in the trendline tooltip.) |
vAxes | Array of object, or object with child objects | null | Specifies properties for individual vertical axes, if the chart has multiple vertical axes. Each child object is a To specify a chart with multiple vertical axes, first define a new axis using 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 vAxes:[ {}, // Nothing specified for axis 0 {title:'Losses',textStyle:{color: 'red'}} // Axis 1 ] |
vAxis | Object | null | An object with members to configure various vertical axis elements. To specify properties of this object, you can use object literal notation, as shown here: {title: 'Hello', titleTextStyle: {color: '#FF0000'}} |
vAxis.baseline | number | automatic | vAxis property that specifies the baseline for the vertical axis. If the baseline is larger than the highest grid line or smaller than the lowest grid line, it will be rounded to the closest gridline. |
vAxis.baselineColor | number | 'black' | Specifies the color of the baseline for the vertical axis. Can be any HTML color string, for example: 'red' or '#00cc00' . |
vAxis.direction | 1 or -1 | 1 | The direction in which the values along the vertical axis grow. Specify -1 to reverse the order of the values. |
vAxis.format | string | auto | A format string for numeric axis labels. This is a subset of the ICU pattern set. For instance, {format:'#,###%'} will display values "1,000%", "750%", and "50%" for values 10, 7.5, and 0.5. The actual formatting applied to the label is derived from the locale the API has been loaded with. For more details, see loading charts with a specific locale. |
vAxis.gridlines | Object | null | An object with members to configure the gridlines on the vertical axis. To specify properties of this object, you can use object literal notation, as shown here: {color: '#333', count: 4} |
vAxis.gridlines.color | string | '#CCC' | The color of the vertical gridlines inside the chart area. Specify a valid HTML color string. |
vAxis.gridlines.count | number | 5 | The number of vertical gridlines inside the chart area. Minimum value is 2. Specify -1 to automatically compute the number of gridlines. |
vAxis.minorGridlines | Object | null | An object with members to configure the minor gridlines on the vertical axis, similar to the vAxis.gridlines option. |
vAxis.minorGridlines.color | string | A blend of the gridline and background colors | The color of the vertical minor gridlines inside the chart area. Specify a valid HTML color string. |
vAxis.minorGridlines.count | number | 0 | The number of vertical minor gridlines between two regular gridlines. |
vAxis.logScale | boolean | false | If true, makes the vertical axis a logarithmic scale Note: All values must be positive. |
vAxis.textPosition | string | 'out' | Position of the vertical axis text, relative to the chart area. Supported values: 'out', 'in', 'none'. |
vAxis.textStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the vertical axis text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
vAxis.ticks | Array of elements | auto | Replaces the automatically generated Y-axis ticks with the specified array. Each element of the array should be either a valid tick value (such as a number, date, datetime, or timeofday), or an object. If it's an object, it should have a Examples:
|
vAxis.title | string | no title | vAxis property that specifies a title for the vertical axis. |
vAxis.titleTextStyle | Object | {color: 'black', fontName: <global-font-name>, fontSize: <global-font-size>} | An object that specifies the vertical axis title text style. The object has this format: { color: <string>, fontName: <string>, fontSize: <number>, bold: <boolean>, italic: <boolean> } The |
vAxis.maxValue | number | automatic | Moves the max value of the vertical axis to the specified value; this will be upward in most charts. Ignored if this is set to a value smaller than the maximum y-value of the data. vAxis.viewWindow.max overrides this property. |
vAxis.minValue | number | automatic | Moves the min value of the vertical axis to the specified value; this will be downward in most charts. Ignored if this is set to a value greater than the minimum y-value of the data. vAxis.viewWindow.min overrides this property. |
vAxis.viewWindowMode | string | Equivalent to 'pretty', butvaxis.viewWindow.min andvaxis.viewWindow.max take precedence if used. | Specifies how to scale the vertical axis to render the values within the chart area. The following string values are supported:
|
vAxis.viewWindow | Object | null | Specifies the cropping range of the vertical axis. |
vAxis.viewWindow.max | number | auto | The maximum vertical data value to render. Ignored when vAxis.viewWindowMode is 'pretty' or 'maximized'. |
vAxis.viewWindow.min | number | auto | The minimum horizontal data value to render. Ignored when vAxis.viewWindowMode is 'pretty' or 'maximized'. |
width | number | width of the containing element | Width of the chart, in pixels. |
Methods
Method | Return Type | Description |
---|---|---|
draw(data, options) | none | Draws the chart. The chart accepts further method calls only after the ready event is fired. Extended description . |
getAction(actionID) | Object | Returns the tooltip action object with the requested |
getBoundingBox(id) | Object | Returns an object containing the left, top, width, and height of chart element
Values are relative to the container of the chart. Call this after the chart is drawn. |
getChartAreaBoundingBox() | Object | Returns an object containing the left, top, width, and height of the chart content (i.e., excluding labels and legend):
Values are relative to the container of the chart. Call this after the chart is drawn. |
getChartLayoutInterface() | Object | Returns an object containing information about the onscreen placement of the chart and its elements. The following methods can be called on the returned object:
Call this after the chart is drawn. |
getHAxisValue(position, optional_axis_index) | Number | Returns the logical horizontal value at Example: Call this after the chart is drawn. |
getImageURI() | String | Returns the chart serialized as an image URI. Call this after the chart is drawn. See Printing PNG Charts. |
getSelection() | Array of selection elements | Returns an array of the selected chart entities. Selectable entities are points, annotations, legend entries and categories. A point 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(position, optional_axis_index) | Number | Returns the logical vertical value at Example: Call this after the chart is drawn. |
getXLocation(position, optional_axis_index) | Number | Returns the screen x-coordinate of Example: Call this after the chart is drawn. |
getYLocation(position, optional_axis_index) | Number | Returns the screen y-coordinate of Example: Call this after the chart is drawn. |
removeAction(actionID) | none | Removes the tooltip action with the requested actionID from the chart. |
setAction(action) | none | Sets a tooltip action to be executed when the user clicks on the action text. The Any and all tooltip actions should be set prior to calling the chart's |
setSelection() | none | Selects the specified chart entities. Cancels any previous selection. Selectable entities are points, annotations, legend entries and categories. A point 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() | none | Clears the chart, and releases all of its allocated resources. |
Events
For more information on how to use these events, see Basic Interactivity, Handling Events, and Firing Events.
Name | Description | Properties |
---|---|---|
animationfinish | Fired when transition animation is complete. | None |
click | Fired when the user clicks inside the chart. Can be used to identify when the title, data elements, legend entries, axes, gridlines, or labels are clicked. | targetID |
error | Fired when an error occurs when attempting to render the chart. | id, message |
onmouseover | Fired when the user mouses over a visual entity. Passes back the row and column indices of the corresponding data table element. | row, column |
onmouseout | Fired when the user mouses away from a visual entity. Passes back the row and column indices of the corresponding data table element. | row, column |
ready | The chart is ready for external method calls. If you want to interact with the chart, and call methods after you draw it, you should set up a listener for this event before you call the draw method, and call them only after the event was fired. | None |
select | Fired when the user clicks a visual entity. To learn what has been selected, call getSelection() . | None |
Data Policy
All code and data are processed and rendered in the browser. No data is sent to any server.