Charts Service

  • The Charts service facilitates server-side chart creation using Google Charts Tools, whereas client-side rendering utilizes the Google Charts API.

  • An example is provided illustrating the process of creating a data table, populating an area chart, and displaying it as an image.

  • The documentation details various classes and methods for building different chart types such as Area, Bar, Column, Line, Pie, and Scatter charts, as well as data table and text style objects.

  • Supported chart types are listed, including Timeline, Area, Bar, Bubble, Candlestick, Column, Combo, Gauge, Geo, Histogram, Radar, Line, Org, Pie, Scatter, Sparkline, Stepped Area, Table, Treemap, and Waterfall charts.

  • Enums are defined for handling hidden data, merging data ranges, specifying column types, setting curve and point styles, defining legend positions, handling string matching in filters, setting orientation, and specifying picker values layout.

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

AreaChartBuilder

BarChartBuilder

Chart

Methods

MethodReturn typeBrief description
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getBlob()BlobReturn the data inside this object as a blob.
getOptions()ChartOptionsReturns the options for this chart, such as height, colors, and axes.

Properties

PropertyTypeDescription
IGNORE_BOTHEnumDefault; charts skips any hidden columns and hidden rows.
IGNORE_ROWSEnumCharts skips hidden rows only.
IGNORE_COLUMNSEnumCharts skips hidden columns only.
SHOW_BOTHEnumCharts does not skip hidden columns or hidden rows.

ChartMergeStrategy

Properties

PropertyTypeDescription
MERGE_COLUMNSEnumDefault.
MERGE_ROWSEnumCharts merges the rows of multiple ranges.

ChartOptions

Methods

MethodReturn typeBrief description
get(option)ObjectReturns a configured option for this chart.
getOrDefault(option)ObjectReturns a configured option for this chart.

ChartType

Properties

PropertyTypeDescription
TIMELINEEnumTimeline chart.
AREAEnumArea chart
BAREnumBar chart
BUBBLEEnumBubble chart.
CANDLESTICKEnumCandlestick chart.
COLUMNEnumColumn chart
COMBOEnumCombo chart
GAUGEEnumGauge chart.
GEOEnumGeo chart.
HISTOGRAMEnumHistogram
RADAREnumRadar chart.
LINEEnumLine chart
ORGEnumOrg chart.
PIEEnumPie chart
SCATTEREnumScatter chart
SPARKLINEEnumSparkline chart.
STEPPED_AREAEnumStepped area chart.
TABLEEnumTable chart
TREEMAPEnumTreemap chart.
WATERFALLEnumWaterfall chart.

ColumnChartBuilder

ColumnType

Properties

PropertyTypeDescription
DATEEnumCorresponds to date values.
NUMBEREnumCorresponds to number values.
STRINGEnumCorresponds to string values.

CurveStyle

Properties

PropertyTypeDescription
NORMALEnumStraight lines without curve.
SMOOTHEnumThe angles of the line are smoothed.

DataTable

DataTableBuilder

DataTableSource

Methods

MethodReturn typeBrief description
getDataTable()DataTableReturn the data inside this object as a DataTable.

DataViewDefinition

DataViewDefinitionBuilder

LineChartBuilder

MatchType

Properties

PropertyTypeDescription
EXACTEnumMatch exact values only
PREFIXEnumMatch prefixes starting from the beginning of the value
ANYEnumMatch any substring

Methods

MethodReturn typeBrief description
getName()StringReturns the name of the match type to be used in the options JSON.

NumberRangeFilterBuilder

Orientation

Properties

PropertyTypeDescription
HORIZONTALEnumHorizontal orientation.
VERTICALEnumVertical orientation.

PickerValuesLayout

Properties

PropertyTypeDescription
ASIDEEnumSelected values display in a single text line next to the value picker widget.
BELOWEnumSelected values display in a single text line below the widget.
BELOW_WRAPPINGEnumSimilar to below, but entries that cannot fit in the picker wrap to a new line.
BELOW_STACKEDEnumSelected values display in a column below the widget.

PieChartBuilder

PointStyle

Properties

PropertyTypeDescription
NONEEnumDo not display line points.
TINYEnumUse tiny line points.
MEDIUMEnumUse medium sized line points.
LARGEEnumUse large sized line points.
HUGEEnumUse largest sized line points.

Position

Properties

PropertyTypeDescription
TOPEnumAbove the chart.
RIGHTEnumTo the right of the chart.
BOTTOMEnumBelow the chart.
NONEEnumNo legend is displayed.

ScatterChartBuilder

StringFilterBuilder

TableChartBuilder

TextStyle

Methods

MethodReturn typeBrief description
getColor()StringGets the color of the text style.
getFontName()StringGets the font name of the text style.
getFontSize()NumberGets the font size of the text style.

TextStyleBuilder

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.