Charts Service

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
Area Chart Builder Builder for area charts.
Bar Chart Builder Builder for bar charts.
Chart A Chart object, which can be converted to a static image.
Chart Hidden Dimension Strategy An enumeration of how hidden dimensions in a source are expressed in a chart.
Chart Merge Strategy An enumeration of how multiple ranges in the source are expressed in a chart.
Chart Options Exposes options currently configured for a Chart , such as height, color, etc.
Chart Type Chart types supported by the Charts service.
Charts Entry point for creating Charts in scripts.
Column Chart Builder Builder for column charts.
Column Type An enumeration of the valid data types for columns in a Data Table .
Curve Style An enumeration of the styles for curves in a chart.
Data Table A Data Table to be used in charts.
Data Table Builder Builder of DataTable objects.
Data Table Source Interface for objects that can represent their data as a Data Table .
Data View Definition A data view definition for visualizing chart data.
Data View Definition Builder Builder for Data View Definition objects.
Line Chart Builder Builder for line charts.
Match Type An enumeration of how a string value should be matched.
Number Range Filter Builder A builder for number range filter controls.
Orientation An enumeration of the orientation of an object.
Picker Values Layout An enumeration of how to display selected values in picker widget.
Pie Chart Builder A builder for pie charts.
Point Style An enumeration of the styles of points in a line.
Position An enumeration of legend positions within a chart.
Scatter Chart Builder Builder for scatter charts.
String Filter Builder A builder for string filter controls.
Table Chart Builder A builder for table charts.
Text Style A text style configuration object.
Text Style Builder A builder used to create Text Style objects.

Area Chart Builder

Methods

Method Return type Brief description
Chart Builds the chart.
Area Chart Builder Reverses the drawing of series in the domain axis.
Area Chart Builder Sets the background color for the chart.
Area Chart Builder Sets the colors for the lines in the chart.
Area Chart Builder Sets the data source URL that is used to pull data in from an external source, such as Google Sheets.
Area Chart Builder Sets the data table to use for the chart using a DataTableBuilder.
Area Chart Builder Sets the data table which contains the lines for the chart, as well as the X-axis labels.
Area Chart Builder Sets the data view definition to use for the chart.
Area Chart Builder Sets the dimensions for the chart.
Area Chart Builder Sets the position of the legend with respect to the chart.
Area Chart Builder Sets the text style of the chart legend.
Area Chart Builder Sets advanced options for this chart.
Area Chart Builder Sets the style for points in the line.
Area Chart Builder Sets the range for the chart.
Area Chart Builder Uses stacked lines, meaning that line and bar values are stacked (accumulated).
Area Chart Builder Sets the title of the chart.
Area Chart Builder Sets the text style of the chart title.
Area Chart Builder Sets the horizontal axis text style.
Area Chart Builder Adds a title to the horizontal axis.
Area Chart Builder Sets the horizontal axis title text style.
Area Chart Builder Sets the vertical axis text style.
Area Chart Builder Adds a title to the vertical axis.
Area Chart Builder Sets the vertical axis title text style.
Area Chart Builder Makes the range axis into a logarithmic scale (requires all values to be positive).

Bar Chart Builder

Methods

Method Return type Brief description
Chart Builds the chart.
Bar Chart Builder Reverses the drawing of series in the domain axis.
Bar Chart Builder Reverses the direction in which the bars grow along the horizontal axis.
Bar Chart Builder Sets the background color for the chart.
Bar Chart Builder Sets the colors for the lines in the chart.
Bar Chart Builder Sets the data source URL that is used to pull data in from an external source, such as Google Sheets.
Bar Chart Builder Sets the data table to use for the chart using a DataTableBuilder.
Bar Chart Builder Sets the data table which contains the lines for the chart, as well as the X-axis labels.
Bar Chart Builder Sets the data view definition to use for the chart.
Bar Chart Builder Sets the dimensions for the chart.
Bar Chart Builder Sets the position of the legend with respect to the chart.
Bar Chart Builder Sets the text style of the chart legend.
Bar Chart Builder Sets advanced options for this chart.
Bar Chart Builder Sets the range for the chart.
Bar Chart Builder Uses stacked lines, meaning that line and bar values are stacked (accumulated).
Bar Chart Builder Sets the title of the chart.
Bar Chart Builder Sets the text style of the chart title.
Bar Chart Builder Sets the horizontal axis text style.
Bar Chart Builder Adds a title to the horizontal axis.
Bar Chart Builder Sets the horizontal axis title text style.
Bar Chart Builder Sets the vertical axis text style.
Bar Chart Builder Adds a title to the vertical axis.
Bar Chart Builder Sets the vertical axis title text style.
Bar Chart Builder 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.
Chart Options Returns the options for this chart, such as height, colors, and axes.

Chart Hidden Dimension Strategy

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.

Chart Merge Strategy

Properties

Property Type Description
MERGE_COLUMNS
Enum Default.
MERGE_ROWS
Enum Charts merges the rows of multiple ranges.

Chart Options

Methods

Method Return type Brief description
Object Returns a configured option for this chart.
Object Returns a configured option for this chart.

Chart Type

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
Chart Hidden Dimension Strategy
Chart Hidden Dimension Strategy An enumeration of how hidden dimensions in a source are expressed in a chart.
Chart Merge Strategy
Chart Merge Strategy An enumeration of how multiple ranges in the source are expressed in a chart.
Chart Type
Chart Type An enumeration of chart types supported by the Charts service.
Column Type
Column Type An enumeration of the valid data types for columns in a Data Table .
Curve Style
Curve Style An enumeration of the styles for curves in a chart.
Point Style
Point Style 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
Area Chart Builder Starts building an area chart, as described in the Google Chart Tools documentation.
Bar Chart Builder Starts building a bar chart, as described in the Google Chart Tools documentation.
Column Chart Builder Starts building a column chart, as described in the Google Chart Tools documentation.
Data Table Builder Creates an empty data table, which can have its values set manually.
Data View Definition Builder Creates a new data view definition.
Line Chart Builder Starts building a line chart, as described in the Google Chart Tools documentation.
Pie Chart Builder Starts building a pie chart, as described in the Google Chart Tools documentation.
Scatter Chart Builder Starts building a scatter chart, as described in the Google Chart Tools documentation.
Table Chart Builder Starts building a table chart, as described in the Google Chart Tools documentation.
Text Style Builder Creates a new text style builder.

Column Chart Builder

Methods

Method Return type Brief description
Chart Builds the chart.
Column Chart Builder Reverses the drawing of series in the domain axis.
Column Chart Builder Sets the background color for the chart.
Column Chart Builder Sets the colors for the lines in the chart.
Column Chart Builder Sets the data source URL that is used to pull data in from an external source, such as Google Sheets.
Column Chart Builder Sets the data table to use for the chart using a DataTableBuilder.
Column Chart Builder Sets the data table which contains the lines for the chart, as well as the X-axis labels.
Column Chart Builder Sets the data view definition to use for the chart.
Column Chart Builder Sets the dimensions for the chart.
Column Chart Builder Sets the position of the legend with respect to the chart.
Column Chart Builder Sets the text style of the chart legend.
Column Chart Builder Sets advanced options for this chart.
Column Chart Builder Sets the range for the chart.
Column Chart Builder Uses stacked lines, meaning that line and bar values are stacked (accumulated).
Column Chart Builder Sets the title of the chart.
Column Chart Builder Sets the text style of the chart title.
Column Chart Builder Sets the horizontal axis text style.
Column Chart Builder Adds a title to the horizontal axis.
Column Chart Builder Sets the horizontal axis title text style.
Column Chart Builder Sets the vertical axis text style.
Column Chart Builder Adds a title to the vertical axis.
Column Chart Builder Sets the vertical axis title text style.
Column Chart Builder Makes the range axis into a logarithmic scale (requires all values to be positive).

Column Type

Properties

Property Type Description
DATE
Enum Corresponds to date values.
NUMBER
Enum Corresponds to number values.
STRING
Enum Corresponds to string values.

Curve Style

Properties

Property Type Description
NORMAL
Enum Straight lines without curve.
SMOOTH
Enum The angles of the line are smoothed.

Data Table

Data Table Builder

Methods

Method Return type Brief description
Data Table Builder Adds a column to the data table.
Data Table Builder Adds a row to the data table.
Data Table Builds and returns a data table.
Data Table Builder Sets a specific value in the table.

Data Table Source

Methods

Method Return type Brief description
Data Table Return the data inside this object as a DataTable.

Data View Definition

Data View Definition Builder

Methods

Method Return type Brief description
Data View Definition Builds and returns the data view definition object that was built using this builder.
Data View Definition Builder Sets the indexes of the columns to include in the data view as well as specifying role-column information.

Line Chart Builder

Methods

Method Return type Brief description
Chart Builds the chart.
Line Chart Builder Reverses the drawing of series in the domain axis.
Line Chart Builder Sets the background color for the chart.
Line Chart Builder Sets the colors for the lines in the chart.
Line Chart Builder Sets the style to use for curves in the chart.
Line Chart Builder Sets the data source URL that is used to pull data in from an external source, such as Google Sheets.
Line Chart Builder Sets the data table to use for the chart using a DataTableBuilder.
Line Chart Builder Sets the data table which contains the lines for the chart, as well as the X-axis labels.
Line Chart Builder Sets the data view definition to use for the chart.
Line Chart Builder Sets the dimensions for the chart.
Line Chart Builder Sets the position of the legend with respect to the chart.
Line Chart Builder Sets the text style of the chart legend.
Line Chart Builder Sets advanced options for this chart.
Line Chart Builder Sets the style for points in the line.
Line Chart Builder Sets the range for the chart.
Line Chart Builder Sets the title of the chart.
Line Chart Builder Sets the text style of the chart title.
Line Chart Builder Sets the horizontal axis text style.
Line Chart Builder Adds a title to the horizontal axis.
Line Chart Builder Sets the horizontal axis title text style.
Line Chart Builder Sets the vertical axis text style.
Line Chart Builder Adds a title to the vertical axis.
Line Chart Builder Sets the vertical axis title text style.
Line Chart Builder Makes the range axis into a logarithmic scale (requires all values to be positive).

Match Type

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.

Number Range Filter Builder

Methods

Method Return type Brief description
Number Range Filter Builder Sets the maximum allowed value for the range lower extent.
Number Range Filter Builder Sets the minimum allowed value for the range lower extent.
Number Range Filter Builder Sets the slider orientation.
Number Range Filter Builder Sets whether to have labels next to the slider displaying extents of the selected range.
Number Range Filter Builder 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.

Picker Values Layout

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.

Pie Chart Builder

Methods

Method Return type Brief description
Chart Builds the chart.
Pie Chart Builder Reverses the drawing of series in the domain axis.
Pie Chart Builder Sets the chart to be three-dimensional.
Pie Chart Builder Sets the background color for the chart.
Pie Chart Builder Sets the colors for the lines in the chart.
Pie Chart Builder Sets the data source URL that is used to pull data in from an external source, such as Google Sheets.
Pie Chart Builder Sets the data table to use for the chart using a DataTableBuilder.
Pie Chart Builder Sets the data table which contains the lines for the chart, as well as the X-axis labels.
Pie Chart Builder Sets the data view definition to use for the chart.
Pie Chart Builder Sets the dimensions for the chart.
Pie Chart Builder Sets the position of the legend with respect to the chart.
Pie Chart Builder Sets the text style of the chart legend.
Pie Chart Builder Sets advanced options for this chart.
Pie Chart Builder Sets the title of the chart.
Pie Chart Builder Sets the text style of the chart title.

Point Style

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.

Scatter Chart Builder

Methods

Method Return type Brief description
Chart Builds the chart.
Scatter Chart Builder Sets the background color for the chart.
Scatter Chart Builder Sets the colors for the lines in the chart.
Scatter Chart Builder Sets the data source URL that is used to pull data in from an external source, such as Google Sheets.
Scatter Chart Builder Sets the data table to use for the chart using a DataTableBuilder.
Scatter Chart Builder Sets the data table which contains the lines for the chart, as well as the X-axis labels.
Scatter Chart Builder Sets the data view definition to use for the chart.
Scatter Chart Builder Sets the dimensions for the chart.
Scatter Chart Builder Sets the position of the legend with respect to the chart.
Scatter Chart Builder Sets the text style of the chart legend.
Scatter Chart Builder Sets advanced options for this chart.
Scatter Chart Builder Sets the style for points in the line.
Scatter Chart Builder Sets the title of the chart.
Scatter Chart Builder Sets the text style of the chart title.
Scatter Chart Builder Makes the horizontal axis into a logarithmic scale (requires all values to be positive).
Scatter Chart Builder Sets the range for the horizontal axis of the chart.
Scatter Chart Builder Sets the horizontal axis text style.
Scatter Chart Builder Adds a title to the horizontal axis.
Scatter Chart Builder Sets the horizontal axis title text style.
Scatter Chart Builder Makes the vertical axis into a logarithmic scale (requires all values to be positive).
Scatter Chart Builder Sets the range for the vertical axis of the chart.
Scatter Chart Builder Sets the vertical axis text style.
Scatter Chart Builder Adds a title to the vertical axis.
Scatter Chart Builder Sets the vertical axis title text style.

String Filter Builder

Methods

Method Return type Brief description
String Filter Builder Sets whether matching should be case sensitive or not.
String Filter Builder Sets whether the control should match exact values only ( Match Type.EXACT ), prefixes starting from the beginning of the value ( Match Type.PREFIX ), or any substring ( Match Type.ANY ).
String Filter Builder 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).

Table Chart Builder

Methods

Method Return type Brief description
Chart Builds the chart.
Table Chart Builder Sets whether to enable paging through the data.
Table Chart Builder Enables paging and sets the number of rows in each page.
Table Chart Builder Enables paging, sets the number of rows in each page and the first table page to display (page numbers are zero based).
Table Chart Builder 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.
Table Chart Builder Sets whether to sort columns when the user clicks a column heading.
Table Chart Builder Sets the data source URL that is used to pull data in from an external source, such as Google Sheets.
Table Chart Builder Sets the data table to use for the chart using a DataTableBuilder.
Table Chart Builder Sets the data table which contains the lines for the chart, as well as the X-axis labels.
Table Chart Builder Sets the data view definition to use for the chart.
Table Chart Builder Sets the dimensions for the chart.
Table Chart Builder Sets the row number for the first row in the data table.
Table Chart Builder Sets the index of the column according to which the table should be initially sorted (ascending).
Table Chart Builder Sets the index of the column according to which the table should be initially sorted (descending).
Table Chart Builder Sets advanced options for this chart.
Table Chart Builder Sets whether to show the row number as the first column of the table.
Table Chart Builder Sets whether alternating color style is assigned to odd and even rows of a table chart.

Text Style

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.

Text Style Builder

Methods

Method Return type Brief description
Text Style Builds and returns a text style configuration object that was built using this builder.
Text Style Builder Sets the color of the text style.
Text Style Builder Sets the font name of the text style.
Text Style Builder Sets the font size of the text style.
Create a Mobile Website
View Site in Mobile | Classic
Share by: