Charts

Entry point for creating Charts in scripts.

This example creates a basic data table, populates an area chart with the data, and adds it
into a web page as an image:

```javascript
function doGet() {
  const 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();

  const chart = Charts.newAreaChart()
                    .setDataTable(data)
                    .setStacked()
                    .setRange(0, 40)
                    .setTitle('Sales per Month')
                    .build();

  const htmlOutput = HtmlService.createHtmlOutput().setTitle('My Chart');
  const imageData = Utilities.base64Encode(chart.getAs('image/png').getBytes());
  const imageUrl = `data:image/png;base64,${encodeURI(imageData)}`;
  htmlOutput.append('Render chart server side: <br/>');
  htmlOutput.append(`<img border="1" src="${imageUrl}">`);
  return htmlOutput;
}
```

### Properties

| Property | Type | Description |
|---|---|---|
| `ChartHiddenDimensionStrategy` | `https://developers.google.com/apps-script/reference/charts/chart-hidden-dimension-strategy` | An enumeration of how hidden dimensions in a source are expressed in a chart. |
| `ChartMergeStrategy` | `https://developers.google.com/apps-script/reference/charts/chart-merge-strategy` | An enumeration of how multiple ranges in the source are expressed in a chart. |
| `ChartType` | `https://developers.google.com/apps-script/reference/charts/chart-type` | An enumeration of chart types supported by the Charts service. |
| `ColumnType` | `https://developers.google.com/apps-script/reference/charts/column-type` | An enumeration of the valid data types for columns in a `https://developers.google.com/apps-script/reference/charts/data-table`. |
| `CurveStyle` | `https://developers.google.com/apps-script/reference/charts/curve-style` | An enumeration of the styles for curves in a chart. |
| `PointStyle` | `https://developers.google.com/apps-script/reference/charts/point-style` | An enumeration of the styles of points in a line. |
| `Position` | `https://developers.google.com/apps-script/reference/charts/position` | An enumeration of legend positions within a chart. |

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/charts/charts#newAreaChart()` | `https://developers.google.com/apps-script/reference/charts/area-chart-builder` | Starts building an area chart, as described in the [Google Chart Tools](https://developers.google.com/chart/interactive/docs/gallery/areachart) documentation. |
| `https://developers.google.com/apps-script/reference/charts/charts#newBarChart()` | `https://developers.google.com/apps-script/reference/charts/bar-chart-builder` | Starts building a bar chart, as described in the [Google Chart Tools](https://developers.google.com/chart/interactive/docs/gallery/barchart) documentation. |
| `https://developers.google.com/apps-script/reference/charts/charts#newColumnChart()` | `https://developers.google.com/apps-script/reference/charts/column-chart-builder` | Starts building a column chart, as described in the [Google Chart Tools](https://developers.google.com/chart/interactive/docs/gallery/columnchart) documentation. |
| `https://developers.google.com/apps-script/reference/charts/charts#newDataTable()` | `https://developers.google.com/apps-script/reference/charts/data-table-builder` | Creates an empty data table, which can have its values set manually. |
| `https://developers.google.com/apps-script/reference/charts/charts#newDataViewDefinition()` | `https://developers.google.com/apps-script/reference/charts/data-view-definition-builder` | Creates a new data view definition. |
| `https://developers.google.com/apps-script/reference/charts/charts#newLineChart()` | `https://developers.google.com/apps-script/reference/charts/line-chart-builder` | Starts building a line chart, as described in the [Google Chart Tools](https://developers.google.com/chart/interactive/docs/gallery/linechart) documentation. |
| `https://developers.google.com/apps-script/reference/charts/charts#newPieChart()` | `https://developers.google.com/apps-script/reference/charts/pie-chart-builder` | Starts building a pie chart, as described in the [Google Chart Tools](https://developers.google.com/chart/interactive/docs/gallery/piechart) documentation. |
| `https://developers.google.com/apps-script/reference/charts/charts#newScatterChart()` | `https://developers.google.com/apps-script/reference/charts/scatter-chart-builder` | Starts building a scatter chart, as described in the [Google Chart Tools](https://developers.google.com/chart/interactive/docs/gallery/scatterchart) documentation. |
| `https://developers.google.com/apps-script/reference/charts/charts#newTableChart()` | `https://developers.google.com/apps-script/reference/charts/table-chart-builder` | Starts building a table chart, as described in the [Google Chart Tools](https://developers.google.com/chart/interactive/docs/gallery/table) documentation. |
| `https://developers.google.com/apps-script/reference/charts/charts#newTextStyle()` | `https://developers.google.com/apps-script/reference/charts/text-style-builder` | Creates a new text style builder. |

## Detailed documentation

### `newAreaChart()`

Starts building an area chart, as described in the [Google Chart
Tools](https://developers.google.com/chart/interactive/docs/gallery/areachart) documentation.

#### Return


`https://developers.google.com/apps-script/reference/charts/area-chart-builder` --- An AreaChartBuilder, which can be used to build an area chart.

*** ** * ** ***

### `newBarChart()`

Starts building a bar chart, as described in the [Google Chart
Tools](https://developers.google.com/chart/interactive/docs/gallery/barchart) documentation.

#### Return


`https://developers.google.com/apps-script/reference/charts/bar-chart-builder` --- A BarChartBuilder, which can be used to build a bar chart.

*** ** * ** ***

### `newColumnChart()`

Starts building a column chart, as described in the [Google Chart
Tools](https://developers.google.com/chart/interactive/docs/gallery/columnchart) documentation.

#### Return


`https://developers.google.com/apps-script/reference/charts/column-chart-builder` --- A ColumnChartBuilder, which can be used to build a column chart.

*** ** * ** ***

### `newDataTable()`

Creates an empty data table, which can have its values set manually.

Data tables hold the data for all chart types.

#### Return


`https://developers.google.com/apps-script/reference/charts/data-table-builder` --- A DataTableBuilder, which can hold data for charts.

*** ** * ** ***

### `newDataViewDefinition()`

Creates a new data view definition.

Use setters to define the different properties of the data view.

#### Return


`https://developers.google.com/apps-script/reference/charts/data-view-definition-builder` --- A DataViewDefinitionBuilder, which can be used to build a data view definition.

*** ** * ** ***

### `newLineChart()`

Starts building a line chart, as described in the [Google Chart
Tools](https://developers.google.com/chart/interactive/docs/gallery/linechart) documentation.

#### Return


`https://developers.google.com/apps-script/reference/charts/line-chart-builder` --- A LineChartBuilder, which can be used to build a line chart.

*** ** * ** ***

### `newPieChart()`

Starts building a pie chart, as described in the [Google Chart
Tools](https://developers.google.com/chart/interactive/docs/gallery/piechart) documentation.

#### Return


`https://developers.google.com/apps-script/reference/charts/pie-chart-builder` --- A PieChartBuilder, which can be used to build a pie chart.

*** ** * ** ***

### `newScatterChart()`

Starts building a scatter chart, as described in the [Google Chart
Tools](https://developers.google.com/chart/interactive/docs/gallery/scatterchart) documentation.

#### Return


`https://developers.google.com/apps-script/reference/charts/scatter-chart-builder` --- A ScatterChartBuilder, which can be used to build a scatter chart.

*** ** * ** ***

### `newTableChart()`

Starts building a table chart, as described in the [Google Chart
Tools](https://developers.google.com/chart/interactive/docs/gallery/table) documentation.

#### Return


`https://developers.google.com/apps-script/reference/charts/table-chart-builder` --- A TableChartBuilder, which can be used to build a table chart.

*** ** * ** ***

### `newTextStyle()`

Creates a new text style builder.

To change the default values, use the setter functions.

#### Return


`https://developers.google.com/apps-script/reference/charts/text-style-builder` --- A TextStyleBuilder, which can be used to build a text style configuration object.