Charts
This service allows users to create charts using Google Charts Tools and render them server side. If you want to render charts in a web browser, use the Google Charts API instead.
This example creates a basic data table, populates an area chart with the data, and adds it to a web page as an image:
function
doGet
()
{
var
data
=
Charts
.
newDataTable
()
.
addColumn
(
Charts
.
ColumnType
.
STRING
,
'Month'
)
.
addColumn
(
Charts
.
ColumnType
.
NUMBER
,
'In Store'
)
.
addColumn
(
Charts
.
ColumnType
.
NUMBER
,
'Online'
)
.
addRow
([
'January'
,
10
,
1
])
.
addRow
([
'February'
,
12
,
1
])
.
addRow
([
'March'
,
20
,
2
])
.
addRow
([
'April'
,
25
,
3
])
.
addRow
([
'May'
,
30
,
4
])
.
build
();
var
chart
=
Charts
.
newAreaChart
()
.
setDataTable
(
data
)
.
setStacked
()
.
setRange
(
0
,
40
)
.
setTitle
(
'Sales per Month'
)
.
build
();
var
htmlOutput
=
HtmlService
.
createHtmlOutput
()
.
setTitle
(
'My Chart'
);
var
imageData
=
Utilities
.
base64Encode
(
chart
.
getAs
(
'image/png'
)
.
getBytes
());
var
imageUrl
=
"data:image/png;base64,"
+
encodeURI
(
imageData
);
htmlOutput
.
append
(
"Render chart server side: <br/>"
);
htmlOutput
.
append
(
"<img border=
\"
1
\"
src=
\"
"
+
imageUrl
+
"
\">
"
);
return
htmlOutput
;
}
Classes
Name | Brief description |
---|---|
AreaChartBuilder
|
Builder for area charts. |
BarChartBuilder
|
Builder for bar charts. |
Chart
|
A Chart object, which can be converted to a static image. |
ChartHiddenDimensionStrategy
|
An enumeration of how hidden dimensions in a source are expressed in a chart. |
ChartMergeStrategy
|
An enumeration of how multiple ranges in the source are expressed in a chart. |
ChartOptions
|
Exposes options currently configured for a Chart
, such as height, color, etc. |
ChartType
|
Chart types supported by the Charts service. |
Charts
|
Entry point for creating Charts in scripts. |
ColumnChartBuilder
|
Builder for column charts. |
ColumnType
|
An enumeration of the valid data types for columns in a DataTable
. |
CurveStyle
|
An enumeration of the styles for curves in a chart. |
DataTable
|
A Data Table to be used in charts. |
DataTableBuilder
|
Builder of DataTable objects. |
DataTableSource
|
Interface for objects that can represent their data as a DataTable
. |
DataViewDefinition
|
A data view definition for visualizing chart data. |
DataViewDefinitionBuilder
|
Builder for DataViewDefinition
objects. |
LineChartBuilder
|
Builder for line charts. |
MatchType
|
An enumeration of how a string value should be matched. |
NumberRangeFilterBuilder
|
A builder for number range filter controls. |
Orientation
|
An enumeration of the orientation of an object. |
PickerValuesLayout
|
An enumeration of how to display selected values in picker widget. |
PieChartBuilder
|
A builder for pie charts. |
PointStyle
|
An enumeration of the styles of points in a line. |
Position
|
An enumeration of legend positions within a chart. |
ScatterChartBuilder
|
Builder for scatter charts. |
StringFilterBuilder
|
A builder for string filter controls. |
TableChartBuilder
|
A builder for table charts. |
TextStyle
|
A text style configuration object. |
TextStyleBuilder
|
A builder used to create TextStyle
objects. |
AreaChartBuilder
Methods
Method | Return type | Brief description |
---|---|---|
Chart
|
Builds the chart. | |
AreaChartBuilder
|
Reverses the drawing of series in the domain axis. | |
AreaChartBuilder
|
Sets the background color for the chart. | |
AreaChartBuilder
|
Sets the colors for the lines in the chart. | |
AreaChartBuilder
|
Sets the data source URL that is used to pull data in from an external source, such as Google Sheets. | |
AreaChartBuilder
|
Sets the data table to use for the chart using a DataTableBuilder. | |
AreaChartBuilder
|
Sets the data table which contains the lines for the chart, as well as the X-axis labels. | |
AreaChartBuilder
|
Sets the data view definition to use for the chart. | |
AreaChartBuilder
|
Sets the dimensions for the chart. | |
AreaChartBuilder
|
Sets the position of the legend with respect to the chart. | |
AreaChartBuilder
|
Sets the text style of the chart legend. | |
AreaChartBuilder
|
Sets advanced options for this chart. | |
AreaChartBuilder
|
Sets the style for points in the line. | |
AreaChartBuilder
|
Sets the range for the chart. | |
AreaChartBuilder
|
Uses stacked lines, meaning that line and bar values are stacked (accumulated). | |
AreaChartBuilder
|
Sets the title of the chart. | |
AreaChartBuilder
|
Sets the text style of the chart title. | |
AreaChartBuilder
|
Sets the horizontal axis text style. | |
AreaChartBuilder
|
Adds a title to the horizontal axis. | |
AreaChartBuilder
|
Sets the horizontal axis title text style. | |
AreaChartBuilder
|
Sets the vertical axis text style. | |
AreaChartBuilder
|
Adds a title to the vertical axis. | |
AreaChartBuilder
|
Sets the vertical axis title text style. | |
AreaChartBuilder
|
Makes the range axis into a logarithmic scale (requires all values to be positive). |
BarChartBuilder
Methods
Method | Return type | Brief description |
---|---|---|
Chart
|
Builds the chart. | |
BarChartBuilder
|
Reverses the drawing of series in the domain axis. | |
BarChartBuilder
|
Reverses the direction in which the bars grow along the horizontal axis. | |
BarChartBuilder
|
Sets the background color for the chart. | |
BarChartBuilder
|
Sets the colors for the lines in the chart. | |
BarChartBuilder
|
Sets the data source URL that is used to pull data in from an external source, such as Google Sheets. | |
BarChartBuilder
|
Sets the data table to use for the chart using a DataTableBuilder. | |
BarChartBuilder
|
Sets the data table which contains the lines for the chart, as well as the X-axis labels. | |
BarChartBuilder
|
Sets the data view definition to use for the chart. | |
BarChartBuilder
|
Sets the dimensions for the chart. | |
BarChartBuilder
|
Sets the position of the legend with respect to the chart. | |
BarChartBuilder
|
Sets the text style of the chart legend. | |
BarChartBuilder
|
Sets advanced options for this chart. | |
BarChartBuilder
|
Sets the range for the chart. | |
BarChartBuilder
|
Uses stacked lines, meaning that line and bar values are stacked (accumulated). | |
BarChartBuilder
|
Sets the title of the chart. | |
BarChartBuilder
|
Sets the text style of the chart title. | |
BarChartBuilder
|
Sets the horizontal axis text style. | |
BarChartBuilder
|
Adds a title to the horizontal axis. | |
BarChartBuilder
|
Sets the horizontal axis title text style. | |
BarChartBuilder
|
Sets the vertical axis text style. | |
BarChartBuilder
|
Adds a title to the vertical axis. | |
BarChartBuilder
|
Sets the vertical axis title text style. | |
BarChartBuilder
|
Makes the range axis into a logarithmic scale (requires all values to be positive). |
Chart
Methods
Method | Return type | Brief description |
---|---|---|
Blob
|
Return the data inside this object as a blob converted to the specified content type. | |
Blob
|
Return the data inside this object as a blob. | |
ChartOptions
|
Returns the options for this chart, such as height, colors, and axes. |
ChartHiddenDimensionStrategy
Properties
Property | Type | Description |
---|---|---|
IGNORE_BOTH
|
Enum
|
Default; charts skips any hidden columns and hidden rows. |
IGNORE_ROWS
|
Enum
|
Charts skips hidden rows only. |
IGNORE_COLUMNS
|
Enum
|
Charts skips hidden columns only. |
SHOW_BOTH
|
Enum
|
Charts does not skip hidden columns or hidden rows. |
ChartMergeStrategy
Properties
Property | Type | Description |
---|---|---|
MERGE_COLUMNS
|
Enum
|
Default. |
MERGE_ROWS
|
Enum
|
Charts merges the rows of multiple ranges. |
ChartOptions
Methods
Method | Return type | Brief description |
---|---|---|
Object
|
Returns a configured option for this chart. | |
Object
|
Returns a configured option for this chart. |
ChartType
Properties
Property | Type | Description |
---|---|---|
TIMELINE
|
Enum
|
Timeline chart. |
AREA
|
Enum
|
Area chart |
BAR
|
Enum
|
Bar chart |
BUBBLE
|
Enum
|
Bubble chart. |
CANDLESTICK
|
Enum
|
Candlestick chart. |
COLUMN
|
Enum
|
Column chart |
COMBO
|
Enum
|
Combo chart |
GAUGE
|
Enum
|
Gauge chart. |
GEO
|
Enum
|
Geo chart. |
HISTOGRAM
|
Enum
|
Histogram |
RADAR
|
Enum
|
Radar chart. |
LINE
|
Enum
|
Line chart |
ORG
|
Enum
|
Org chart. |
PIE
|
Enum
|
Pie chart |
SCATTER
|
Enum
|
Scatter chart |
SPARKLINE
|
Enum
|
Sparkline chart. |
STEPPED_AREA
|
Enum
|
Stepped area chart. |
TABLE
|
Enum
|
Table chart |
TREEMAP
|
Enum
|
Treemap chart. |
WATERFALL
|
Enum
|
Waterfall chart. |
Charts
Properties
Property | Type | Description |
---|---|---|
ChartHiddenDimensionStrategy
|
ChartHiddenDimensionStrategy
|
An enumeration of how hidden dimensions in a source are expressed in a chart. |
ChartMergeStrategy
|
ChartMergeStrategy
|
An enumeration of how multiple ranges in the source are expressed in a chart. |
ChartType
|
ChartType
|
An enumeration of chart types supported by the Charts service. |
ColumnType
|
ColumnType
|
An enumeration of the valid data types for columns in a DataTable
. |
CurveStyle
|
CurveStyle
|
An enumeration of the styles for curves in a chart. |
PointStyle
|
PointStyle
|
An enumeration of the styles of points in a line. |
Position
|
Position
|
An enumeration of legend positions within a chart. |
Methods
Method | Return type | Brief description |
---|---|---|
AreaChartBuilder
|
Starts building an area chart, as described in the Google Chart Tools documentation. | |
BarChartBuilder
|
Starts building a bar chart, as described in the Google Chart Tools documentation. | |
ColumnChartBuilder
|
Starts building a column chart, as described in the Google Chart Tools documentation. | |
DataTableBuilder
|
Creates an empty data table, which can have its values set manually. | |
DataViewDefinitionBuilder
|
Creates a new data view definition. | |
LineChartBuilder
|
Starts building a line chart, as described in the Google Chart Tools documentation. | |
PieChartBuilder
|
Starts building a pie chart, as described in the Google Chart Tools documentation. | |
ScatterChartBuilder
|
Starts building a scatter chart, as described in the Google Chart Tools documentation. | |
TableChartBuilder
|
Starts building a table chart, as described in the Google Chart Tools documentation. | |
TextStyleBuilder
|
Creates a new text style builder. |
ColumnChartBuilder
Methods
Method | Return type | Brief description |
---|---|---|
Chart
|
Builds the chart. | |
ColumnChartBuilder
|
Reverses the drawing of series in the domain axis. | |
ColumnChartBuilder
|
Sets the background color for the chart. | |
ColumnChartBuilder
|
Sets the colors for the lines in the chart. | |
ColumnChartBuilder
|
Sets the data source URL that is used to pull data in from an external source, such as Google Sheets. | |
ColumnChartBuilder
|
Sets the data table to use for the chart using a DataTableBuilder. | |
ColumnChartBuilder
|
Sets the data table which contains the lines for the chart, as well as the X-axis labels. | |
ColumnChartBuilder
|
Sets the data view definition to use for the chart. | |
ColumnChartBuilder
|
Sets the dimensions for the chart. | |
ColumnChartBuilder
|
Sets the position of the legend with respect to the chart. | |
ColumnChartBuilder
|
Sets the text style of the chart legend. | |
ColumnChartBuilder
|
Sets advanced options for this chart. | |
ColumnChartBuilder
|
Sets the range for the chart. | |
ColumnChartBuilder
|
Uses stacked lines, meaning that line and bar values are stacked (accumulated). | |
ColumnChartBuilder
|
Sets the title of the chart. | |
ColumnChartBuilder
|
Sets the text style of the chart title. | |
ColumnChartBuilder
|
Sets the horizontal axis text style. | |
ColumnChartBuilder
|
Adds a title to the horizontal axis. | |
ColumnChartBuilder
|
Sets the horizontal axis title text style. | |
ColumnChartBuilder
|
Sets the vertical axis text style. | |
ColumnChartBuilder
|
Adds a title to the vertical axis. | |
ColumnChartBuilder
|
Sets the vertical axis title text style. | |
ColumnChartBuilder
|
Makes the range axis into a logarithmic scale (requires all values to be positive). |
ColumnType
Properties
Property | Type | Description |
---|---|---|
DATE
|
Enum
|
Corresponds to date values. |
NUMBER
|
Enum
|
Corresponds to number values. |
STRING
|
Enum
|
Corresponds to string values. |
CurveStyle
Properties
Property | Type | Description |
---|---|---|
NORMAL
|
Enum
|
Straight lines without curve. |
SMOOTH
|
Enum
|
The angles of the line are smoothed. |
DataTable
DataTableBuilder
Methods
Method | Return type | Brief description |
---|---|---|
DataTableBuilder
|
Adds a column to the data table. | |
DataTableBuilder
|
Adds a row to the data table. | |
DataTable
|
Builds and returns a data table. | |
DataTableBuilder
|
Sets a specific value in the table. |
DataTableSource
Methods
Method | Return type | Brief description |
---|---|---|
DataTable
|
Return the data inside this object as a DataTable. |
DataViewDefinition
DataViewDefinitionBuilder
Methods
Method | Return type | Brief description |
---|---|---|
DataViewDefinition
|
Builds and returns the data view definition object that was built using this builder. | |
DataViewDefinitionBuilder
|
Sets the indexes of the columns to include in the data view as well as specifying role-column information. |
LineChartBuilder
Methods
Method | Return type | Brief description |
---|---|---|
Chart
|
Builds the chart. | |
LineChartBuilder
|
Reverses the drawing of series in the domain axis. | |
LineChartBuilder
|
Sets the background color for the chart. | |
LineChartBuilder
|
Sets the colors for the lines in the chart. | |
LineChartBuilder
|
Sets the style to use for curves in the chart. | |
LineChartBuilder
|
Sets the data source URL that is used to pull data in from an external source, such as Google Sheets. | |
LineChartBuilder
|
Sets the data table to use for the chart using a DataTableBuilder. | |
LineChartBuilder
|
Sets the data table which contains the lines for the chart, as well as the X-axis labels. | |
LineChartBuilder
|
Sets the data view definition to use for the chart. | |
LineChartBuilder
|
Sets the dimensions for the chart. | |
LineChartBuilder
|
Sets the position of the legend with respect to the chart. | |
LineChartBuilder
|
Sets the text style of the chart legend. | |
LineChartBuilder
|
Sets advanced options for this chart. | |
LineChartBuilder
|
Sets the style for points in the line. | |
LineChartBuilder
|
Sets the range for the chart. | |
LineChartBuilder
|
Sets the title of the chart. | |
LineChartBuilder
|
Sets the text style of the chart title. | |
LineChartBuilder
|
Sets the horizontal axis text style. | |
LineChartBuilder
|
Adds a title to the horizontal axis. | |
LineChartBuilder
|
Sets the horizontal axis title text style. | |
LineChartBuilder
|
Sets the vertical axis text style. | |
LineChartBuilder
|
Adds a title to the vertical axis. | |
LineChartBuilder
|
Sets the vertical axis title text style. | |
LineChartBuilder
|
Makes the range axis into a logarithmic scale (requires all values to be positive). |
MatchType
Properties
Property | Type | Description |
---|---|---|
EXACT
|
Enum
|
Match exact values only |
PREFIX
|
Enum
|
Match prefixes starting from the beginning of the value |
ANY
|
Enum
|
Match any substring |
Methods
Method | Return type | Brief description |
---|---|---|
String
|
Returns the name of the match type to be used in the options JSON. |
NumberRangeFilterBuilder
Methods
Method | Return type | Brief description |
---|---|---|
NumberRangeFilterBuilder
|
Sets the maximum allowed value for the range lower extent. | |
NumberRangeFilterBuilder
|
Sets the minimum allowed value for the range lower extent. | |
NumberRangeFilterBuilder
|
Sets the slider orientation. | |
NumberRangeFilterBuilder
|
Sets whether to have labels next to the slider displaying extents of the selected range. | |
NumberRangeFilterBuilder
|
Sets the number of ticks (fixed positions in a range bar) a number range filter slider thumbs can fall in. |
Orientation
Properties
Property | Type | Description |
---|---|---|
HORIZONTAL
|
Enum
|
Horizontal orientation. |
VERTICAL
|
Enum
|
Vertical orientation. |
PickerValuesLayout
Properties
Property | Type | Description |
---|---|---|
ASIDE
|
Enum
|
Selected values display in a single text line next to the value picker widget. |
BELOW
|
Enum
|
Selected values display in a single text line below the widget. |
BELOW_WRAPPING
|
Enum
|
Similar to below, but entries that cannot fit in the picker wrap to a new line. |
BELOW_STACKED
|
Enum
|
Selected values display in a column below the widget. |
PieChartBuilder
Methods
Method | Return type | Brief description |
---|---|---|
Chart
|
Builds the chart. | |
PieChartBuilder
|
Reverses the drawing of series in the domain axis. | |
PieChartBuilder
|
Sets the chart to be three-dimensional. | |
PieChartBuilder
|
Sets the background color for the chart. | |
PieChartBuilder
|
Sets the colors for the lines in the chart. | |
PieChartBuilder
|
Sets the data source URL that is used to pull data in from an external source, such as Google Sheets. | |
PieChartBuilder
|
Sets the data table to use for the chart using a DataTableBuilder. | |
PieChartBuilder
|
Sets the data table which contains the lines for the chart, as well as the X-axis labels. | |
PieChartBuilder
|
Sets the data view definition to use for the chart. | |
PieChartBuilder
|
Sets the dimensions for the chart. | |
PieChartBuilder
|
Sets the position of the legend with respect to the chart. | |
PieChartBuilder
|
Sets the text style of the chart legend. | |
PieChartBuilder
|
Sets advanced options for this chart. | |
PieChartBuilder
|
Sets the title of the chart. | |
PieChartBuilder
|
Sets the text style of the chart title. |
PointStyle
Properties
Property | Type | Description |
---|---|---|
NONE
|
Enum
|
Do not display line points. |
TINY
|
Enum
|
Use tiny line points. |
MEDIUM
|
Enum
|
Use medium sized line points. |
LARGE
|
Enum
|
Use large sized line points. |
HUGE
|
Enum
|
Use largest sized line points. |
Position
Properties
Property | Type | Description |
---|---|---|
TOP
|
Enum
|
Above the chart. |
RIGHT
|
Enum
|
To the right of the chart. |
BOTTOM
|
Enum
|
Below the chart. |
NONE
|
Enum
|
No legend is displayed. |
ScatterChartBuilder
Methods
Method | Return type | Brief description |
---|---|---|
Chart
|
Builds the chart. | |
ScatterChartBuilder
|
Sets the background color for the chart. | |
ScatterChartBuilder
|
Sets the colors for the lines in the chart. | |
ScatterChartBuilder
|
Sets the data source URL that is used to pull data in from an external source, such as Google Sheets. | |
ScatterChartBuilder
|
Sets the data table to use for the chart using a DataTableBuilder. | |
ScatterChartBuilder
|
Sets the data table which contains the lines for the chart, as well as the X-axis labels. | |
ScatterChartBuilder
|
Sets the data view definition to use for the chart. | |
ScatterChartBuilder
|
Sets the dimensions for the chart. | |
ScatterChartBuilder
|
Sets the position of the legend with respect to the chart. | |
ScatterChartBuilder
|
Sets the text style of the chart legend. | |
ScatterChartBuilder
|
Sets advanced options for this chart. | |
ScatterChartBuilder
|
Sets the style for points in the line. | |
ScatterChartBuilder
|
Sets the title of the chart. | |
ScatterChartBuilder
|
Sets the text style of the chart title. | |
ScatterChartBuilder
|
Makes the horizontal axis into a logarithmic scale (requires all values to be positive). | |
ScatterChartBuilder
|
Sets the range for the horizontal axis of the chart. | |
ScatterChartBuilder
|
Sets the horizontal axis text style. | |
ScatterChartBuilder
|
Adds a title to the horizontal axis. | |
ScatterChartBuilder
|
Sets the horizontal axis title text style. | |
ScatterChartBuilder
|
Makes the vertical axis into a logarithmic scale (requires all values to be positive). | |
ScatterChartBuilder
|
Sets the range for the vertical axis of the chart. | |
ScatterChartBuilder
|
Sets the vertical axis text style. | |
ScatterChartBuilder
|
Adds a title to the vertical axis. | |
ScatterChartBuilder
|
Sets the vertical axis title text style. |
StringFilterBuilder
Methods
Method | Return type | Brief description |
---|---|---|
StringFilterBuilder
|
Sets whether matching should be case sensitive or not. | |
StringFilterBuilder
|
Sets whether the control should match exact values only ( MatchType.EXACT
), prefixes
starting from the beginning of the value ( MatchType.PREFIX
), or any substring
( MatchType.ANY
). |
|
StringFilterBuilder
|
Sets whether the control should match any time a key is pressed or only when the input field 'changes' (loss of focus or pressing the Enter key). |
TableChartBuilder
Methods
Method | Return type | Brief description |
---|---|---|
Chart
|
Builds the chart. | |
TableChartBuilder
|
Sets whether to enable paging through the data. | |
TableChartBuilder
|
Enables paging and sets the number of rows in each page. | |
TableChartBuilder
|
Enables paging, sets the number of rows in each page and the first table page to display (page numbers are zero based). | |
TableChartBuilder
|
Adds basic support for right-to-left languages (such as Arabic or Hebrew) by reversing the column order of the table, so that column zero is the right-most column, and the last column is the left-most column. | |
TableChartBuilder
|
Sets whether to sort columns when the user clicks a column heading. | |
TableChartBuilder
|
Sets the data source URL that is used to pull data in from an external source, such as Google Sheets. | |
TableChartBuilder
|
Sets the data table to use for the chart using a DataTableBuilder. | |
TableChartBuilder
|
Sets the data table which contains the lines for the chart, as well as the X-axis labels. | |
TableChartBuilder
|
Sets the data view definition to use for the chart. | |
TableChartBuilder
|
Sets the dimensions for the chart. | |
TableChartBuilder
|
Sets the row number for the first row in the data table. | |
TableChartBuilder
|
Sets the index of the column according to which the table should be initially sorted (ascending). | |
TableChartBuilder
|
Sets the index of the column according to which the table should be initially sorted (descending). | |
TableChartBuilder
|
Sets advanced options for this chart. | |
TableChartBuilder
|
Sets whether to show the row number as the first column of the table. | |
TableChartBuilder
|
Sets whether alternating color style is assigned to odd and even rows of a table chart. |
TextStyle
Methods
Method | Return type | Brief description |
---|---|---|
String
|
Gets the color of the text style. | |
String
|
Gets the font name of the text style. | |
Number
|
Gets the font size of the text style. |
TextStyleBuilder
Methods
Method | Return type | Brief description |
---|---|---|
TextStyle
|
Builds and returns a text style configuration object that was built using this builder. | |
TextStyleBuilder
|
Sets the color of the text style. | |
TextStyleBuilder
|
Sets the font name of the text style | |
TextStyleBuilder
|
Sets the font size of the text style. |