Class EmbeddedComboChartBuilder

Embedded Combo Chart Builder

Builder for combo charts. For more details, see the Google Visualization documentation .

Methods

Method Return type Brief description
Embedded Chart Builder Adds a range to the chart this builder modifies.
Embedded Area Chart Builder Sets the chart type to AreaChart and returns an Embedded Area Chart Builder .
Embedded Bar Chart Builder Sets the chart type to BarChart and returns an Embedded Bar Chart Builder .
Embedded Column Chart Builder Sets the chart type to ColumnChart and returns an Embedded Column Chart Builder .
Embedded Combo Chart Builder Sets the chart type to ComboChart and returns an Embedded Combo Chart Builder .
Embedded Histogram Chart Builder Sets the chart type to HistogramChart and returns an Embedded Histogram Chart Builder .
Embedded Line Chart Builder Sets the chart type to LineChart and returns an Embedded Line Chart Builder .
Embedded Pie Chart Builder Sets the chart type to PieChart and returns an Embedded Pie Chart Builder .
Embedded Scatter Chart Builder Sets the chart type to ScatterChart and returns an Embedded Scatter Chart Builder .
Embedded Table Chart Builder Sets the chart type to TableChart and returns an Embedded Table Chart Builder .
Embedded Chart Builds the chart to reflect all changes made to it.
Embedded Chart Builder Removes all ranges from the chart this builder modifies.
Chart Type Returns the current chart type.
Container Info Return the chart Container Info , which encapsulates where the chart appears on the sheet.
Range[] Returns a copy of the list of ranges currently providing data for this chart.
Embedded Chart Builder Removes the specified range from the chart this builder modifies.
Embedded Combo Chart Builder Reverses the drawing of series in the domain axis.
Embedded Combo Chart Builder Sets the background color for the chart.
Embedded Chart Builder Changes the type of chart.
Embedded Combo Chart Builder Sets the colors for the lines in the chart.
Embedded Chart Builder Sets the strategy to use for hidden rows and columns.
Embedded Combo Chart Builder Sets the position of the legend with respect to the chart.
Embedded Combo Chart Builder Sets the text style of the chart legend.
Embedded Chart Builder Sets the merge strategy to use when more than one range exists.
Embedded Chart Builder Sets the number of rows or columns of the range that should be treated as headers.
Embedded Chart Builder Sets advanced options for this chart.
Embedded Chart Builder Sets the position, changing where the chart appears on the sheet.
Embedded Combo Chart Builder Sets the range for the chart.
Embedded Combo Chart Builder Uses stacked lines, meaning that line and bar values are stacked (accumulated).
Embedded Combo Chart Builder Sets the title of the chart.
Embedded Combo Chart Builder Sets the text style of the chart title.
Embedded Chart Builder Sets whether the chart's rows and columns are transposed.
Embedded Combo Chart Builder Sets the horizontal axis text style.
Embedded Combo Chart Builder Adds a title to the horizontal axis.
Embedded Combo Chart Builder Sets the horizontal axis title text style.
Embedded Combo Chart Builder Sets the vertical axis text style.
Embedded Combo Chart Builder Adds a title to the vertical axis.
Embedded Combo Chart Builder Sets the vertical axis title text style.
Embedded Combo Chart Builder Makes the range axis into a logarithmic scale (requires all values to be positive).

Detailed documentation

add Range(range)

Adds a range to the chart this builder modifies. Does not add the range if it has already been added to the chart.

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 sheet 
 . 
 getRange 
 ( 
 'A1:B8' 
 )) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ) 
  
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
range
Range The range to add.

Return

Embedded Chart Builder — this builder, for chaining


as Area Chart()

Sets the chart type to AreaChart and returns an Embedded Area Chart Builder .

Return

Embedded Area Chart Builder — a builder for an area chart


as Bar Chart()

Sets the chart type to BarChart and returns an Embedded Bar Chart Builder .

Return

Embedded Bar Chart Builder — a builder for a bar chart


as Column Chart()

Sets the chart type to ColumnChart and returns an Embedded Column Chart Builder .

Return

Embedded Column Chart Builder — a builder for a column chart


as Combo Chart()

Sets the chart type to ComboChart and returns an Embedded Combo Chart Builder .

Return

Embedded Combo Chart Builder — a builder for a combo chart


as Histogram Chart()

Sets the chart type to HistogramChart and returns an Embedded Histogram Chart Builder .

Return

Embedded Histogram Chart Builder — a builder for a histogram chart


as Line Chart()

Sets the chart type to LineChart and returns an Embedded Line Chart Builder .

Return

Embedded Line Chart Builder — a builder for a line chart


as Pie Chart()

Sets the chart type to PieChart and returns an Embedded Pie Chart Builder .

Return

Embedded Pie Chart Builder — a builder for a pie chart


as Scatter Chart()

Sets the chart type to ScatterChart and returns an Embedded Scatter Chart Builder .

Return

Embedded Scatter Chart Builder — a builder for a scatter chart


as Table Chart()

Sets the chart type to TableChart and returns an Embedded Table Chart Builder .

Return

Embedded Table Chart Builder — a builder for a table chart


build()

Builds the chart to reflect all changes made to it.

This method does not automatically draw the chart on top of the spreadsheet. A new chart must be inserted via sheet.insertChart(chart) , and an existing chart should be updated via sheet.updateChart(chart) .

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 range 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A1:B5' 
 ); 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 range 
 ) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ) 
  
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Return

Embedded Chart — the created chart, which must still be added to the spreadsheet


clear Ranges()

Removes all ranges from the chart this builder modifies.

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 // This code updates the chart to use only the new ranges while preserving the 
 // existing formatting of the chart. 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 getCharts 
 ()[ 
 0 
 ]; 
 const 
  
 newChart 
  
 = 
  
 chart 
 . 
 modify 
 () 
  
 . 
 clearRanges 
 () 
  
 . 
 addRange 
 ( 
 sheet 
 . 
 getRange 
 ( 
 'A1:A5' 
 )) 
  
 . 
 addRange 
 ( 
 sheet 
 . 
 getRange 
 ( 
 'B1:B5' 
 )) 
  
 . 
 build 
 (); 
 sheet 
 . 
 updateChart 
 ( 
 newChart 
 ); 

Return

Embedded Chart Builder — this builder, for chaining


get Chart Type()

Returns the current chart type.

Return

Chart Type — the chart type


get Container()

Return the chart Container Info , which encapsulates where the chart appears on the sheet.

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 chartBuilder 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 sheet 
 . 
 getRange 
 ( 
 'A1:B8' 
 )) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ); 
 // This method returns the exact same data as Chart#getContainerInfo() 
 const 
  
 containerInfo 
  
 = 
  
 chartBuilder 
 . 
 getContainer 
 (); 
 // Logs the values used in setPosition() 
 Logger 
 . 
 log 
 ( 
  
 'Anchor Column: %s\r\nAnchor Row %s\r\nOffset X %s\r\nOffset Y %s' 
 , 
  
 containerInfo 
 . 
 getAnchorColumn 
 (), 
  
 containerInfo 
 . 
 getAnchorRow 
 (), 
  
 containerInfo 
 . 
 getOffsetX 
 (), 
  
 containerInfo 
 . 
 getOffsetY 
 (), 
 ); 

Return

Container Info — an object containing the chart container's position


get Ranges()

Returns a copy of the list of ranges currently providing data for this chart. Use add Range(range) and remove Range(range) to modify this list.

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 chartBuilder 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 sheet 
 . 
 getRange 
 ( 
 'A1:B8' 
 )) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ); 
 const 
  
 ranges 
  
 = 
  
 chartBuilder 
 . 
 getRanges 
 (); 
 // There's only one range as a data source for this chart, 
 // so this logs "A1:B8" 
 for 
  
 ( 
 const 
  
 i 
  
 in 
  
 ranges 
 ) 
  
 { 
  
 const 
  
 range 
  
 = 
  
 ranges 
 [ 
 i 
 ]; 
  
 Logger 
 . 
 log 
 ( 
 range 
 . 
 getA1Notation 
 ()); 
 } 

Return

Range[] — an array of ranges that serve as the chart to be built's data source


remove Range(range)

Removes the specified range from the chart this builder modifies. Does not throw an error if the range is not in this chart.

The range removed must match up with a range added via add Range(range) ; otherwise no change is made to the chart. This method cannot be used to partially remove values from a range.

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 firstRange 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A1:B5' 
 ); 
 const 
  
 secondRange 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A6:B8' 
 ); 
 const 
  
 chartBuilder 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 firstRange 
 ) 
  
 // This range will render in a different color 
  
 . 
 addRange 
 ( 
 secondRange 
 ) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ); 
 // Note that you can use either of these two formats, but the range 
 // MUST match up with a range that was added via addRange(), or it 
 // will not be removed, and will not throw an exception 
 chartBuilder 
 . 
 removeRange 
 ( 
 firstRange 
 ); 
 chartBuilder 
 . 
 removeRange 
 ( 
 sheet 
 . 
 getRange 
 ( 
 'A6:B8' 
 )); 
 const 
  
 chart 
  
 = 
  
 chartBuilder 
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
range
Range The range to remove.

Return

Embedded Chart Builder — this builder, for chaining


reverse Categories()

Reverses the drawing of series in the domain axis. For vertical-range charts (such as line, area or column charts), this means the horizontal axis is drawn from right to left. For horizontal-range charts (such as bar charts), this means the vertical axis is drawn from top to bottom. For pie charts, this means the slices are drawn counterclockwise.

 // Creates a pie chart builder and sets drawing of the slices in a 
 // counter-clockwise manner. 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newPieChart 
 (); 
 builder 
 . 
 reverseCategories 
 (); 

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Background Color(cssValue)

Sets the background color for the chart.

 // Creates a line chart builder and sets the background color to gray 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setBackgroundColor 
 ( 
 'gray' 
 ); 

Parameters

Name Type Description
css Value
String The CSS value for the color (such as "blue" or "#00f" ).

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Chart Type(type)

Changes the type of chart. Not all embedded chart types are currently supported. See Chart Type .

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 range 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A1:B5' 
 ); 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 range 
 ) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ) 
  
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
type
Chart Type The type to change this chart into.

Return

Embedded Chart Builder — this builder, for chaining


set Colors(cssValues)

Sets the colors for the lines in the chart.

 // Creates a line chart builder and sets the first two lines to be drawn in 
 // green and red, respectively. 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setColors 
 ([ 
 'green' 
 , 
  
 'red' 
 ]); 

Parameters

Name Type Description
css Values
String[] An array of color CSS values, such as ["red", "#acf"] . The nth element in the array represents the color of the nth line in the chart.

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Hidden Dimension Strategy(strategy)

Sets the strategy to use for hidden rows and columns. Defaults to IGNORE_ROWS .

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 range 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A1:B5' 
 ); 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 range 
 ) 
  
 . 
 setHiddenDimensionStrategy 
 ( 
  
 Charts 
 . 
 ChartHiddenDimensionStrategy 
 . 
 IGNORE_COLUMNS 
 , 
  
 ) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ) 
  
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
strategy
Chart Hidden Dimension Strategy The strategy to use for hidden rows and columns.

Return

Embedded Chart Builder — this builder, for chaining


set Legend Position(position)

Sets the position of the legend with respect to the chart. By default, there is no legend.

 // Creates a line chart builder and sets the legend position to right. 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setLegendPosition 
 ( 
 Charts 
 . 
 Position 
 . 
 RIGHT 
 ); 

Parameters

Name Type Description
position
Position The position of the legend.

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Legend Text Style(textStyle)

Sets the text style of the chart legend.

 // Creates a line chart builder and sets it up for a  blue, 26-point legend. 
 const 
  
 textStyleBuilder 
  
 = 
  
 Charts 
 . 
 newTextStyle 
 (). 
 setColor 
 ( 
 '#0000FF' 
 ). 
 setFontSize 
 ( 
 26 
 ); 
 const 
  
 style 
  
 = 
  
 textStyleBuilder 
 . 
 build 
 (); 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setLegendTextStyle 
 ( 
 style 
 ); 

Parameters

Name Type Description
text Style
Text Style The text style to use for the chart legend.

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Merge Strategy(mergeStrategy)

Sets the merge strategy to use when more than one range exists. If MERGE_ROWS , rows are merged; if MERGE_COLUMNS , columns are merged. Defaults to MERGE_COLUMNS .

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 range 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A1:B10' 
 ); 
 const 
  
 range2 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'C:C10' 
 ); 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 range 
 ) 
  
 . 
 addRange 
 ( 
 range2 
 ) 
  
 . 
 setMergeStrategy 
 ( 
 Charts 
 . 
 ChartMergeStrategy 
 . 
 MERGE_ROWS 
 ) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ) 
  
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
merge Strategy
Chart Merge Strategy The merge strategy to use.

Return

Embedded Chart Builder — this builder, for chaining


set Num Headers(headers)

Sets the number of rows or columns of the range that should be treated as headers.

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 range 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A1:B5' 
 ); 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 range 
 ) 
  
 . 
 setNumHeaders 
 ( 
 1 
 ) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ) 
  
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
headers
Integer The number of rows or columns to treat as headers. Negative values cause headers to be auto-detected.

Return

Embedded Chart Builder — this builder, for chaining


set Option(option, value)

Sets advanced options for this chart. To view a list of the available options, see Chart configuration options .

This method doesn't validate the option you specify is valid for this chart type nor if the value is of the correct format/structure.

This example shows how to change the title and set a legend.

 const 
  
 spreadsheet 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 spreadsheet 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setOption 
 ( 
 'title' 
 , 
  
 'Earnings projections' 
 ) 
  
 . 
 setOption 
 ( 
 'legend' 
 , 
  
 { 
  
 position 
 : 
  
 'top' 
 , 
  
 textStyle 
 : 
  
 { 
  
 color 
 : 
  
 'blue' 
 , 
  
 fontSize 
 : 
  
 16 
  
 }, 
  
 }). 
 build 
 (); 

Parameters

Name Type Description
option
String The name of the option.
value
Object The value of the option.

Return

Embedded Chart Builder — This builder, for chaining.


set Position(anchorRowPos, anchorColPos, offsetX, offsetY)

Sets the position, changing where the chart appears on the sheet. anchor Row Pos and anchor Col Pos are 1-indexed.

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 range 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A1:B5' 
 ); 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 range 
 ) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ) 
  
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
anchor Row Pos
Integer The chart's top side is anchored in this row.
anchor Col Pos
Integer The chart's left side is anchored in this column.
offsetX
Integer The chart's upper right-hand corner is offset by this many pixels.
offsetY
Integer The chart's lower left-hand corner is offset by this many pixels.

Return

Embedded Chart Builder — this builder, for chaining


set Range(start, end)

Sets the range for the chart.

If any data points fall outside the range, the range is expanded to include those data points.

Parameters

Name Type Description
start
Number The value for the lowest grid line of the range axis.
end
Number The value for the highest grid line of the range axis.

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Stacked()

Uses stacked lines, meaning that line and bar values are stacked (accumulated). By default, there is no stacking.

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Title(chartTitle)

Sets the title of the chart. The title is displayed centered above the chart.

 // Creates a line chart builder and title to 'My Line Chart'. 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setTitle 
 ( 
 'My Line Chart' 
 ); 

Parameters

Name Type Description
chart Title
String the chart title.

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Title Text Style(textStyle)

Sets the text style of the chart title.

 // Creates a line chart builder and sets it up for a  blue, 26-point title. 
 const 
  
 textStyleBuilder 
  
 = 
  
 Charts 
 . 
 newTextStyle 
 (). 
 setColor 
 ( 
 '#0000FF' 
 ). 
 setFontSize 
 ( 
 26 
 ); 
 const 
  
 style 
  
 = 
  
 textStyleBuilder 
 . 
 build 
 (); 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setTitleTextStyle 
 ( 
 style 
 ); 

Parameters

Name Type Description
text Style
Text Style The text style to use for the chart title. You can create a Text Style Builder object by calling Charts.newTextStyle() .

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set Transpose Rows And Columns(transpose)

Sets whether the chart's rows and columns are transposed. If set to true , the rows and columns are switched. Defaults to false .

 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSpreadsheet 
 (); 
 const 
  
 sheet 
  
 = 
  
 ss 
 . 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 range 
  
 = 
  
 sheet 
 . 
 getRange 
 ( 
 'A1:B5' 
 ); 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 newChart 
 () 
  
 . 
 setChartType 
 ( 
 Charts 
 . 
 ChartType 
 . 
 BAR 
 ) 
  
 . 
 addRange 
 ( 
 range 
 ) 
  
 . 
 setTransposeRowsAndColumns 
 ( 
 true 
 ) 
  
 . 
 setPosition 
 ( 
 5 
 , 
  
 5 
 , 
  
 0 
 , 
  
 0 
 ) 
  
 . 
 build 
 (); 
 sheet 
 . 
 insertChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
transpose
Boolean If true , the rows and columns used to construct the chart are transposed.

Return

Embedded Chart Builder — this builder, for chaining


set XAxis Text Style(textStyle)

Sets the horizontal axis text style.

 // Creates a line chart builder and sets the X-axis text style to blue, 18-point 
 // font. 
 const 
  
 textStyle 
  
 = 
  
 Charts 
 . 
 newTextStyle 
 (). 
 setColor 
 ( 
 'blue' 
 ). 
 setFontSize 
 ( 
 18 
 ). 
 build 
 (); 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setXAxisTextStyle 
 ( 
 textStyle 
 ); 

Parameters

Name Type Description
text Style
Text Style The text style to use for the horizontal axis title. You can create a Text Style Builder object by calling Charts.newTextStyle() .

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set XAxis Title(title)

Adds a title to the horizontal axis. The title is centered and appears below the axis value labels.

 // Creates a line chart builder and sets the X-axis title. 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setTitle 
 ( 
 'X-axis Title' 
 ); 

Parameters

Name Type Description
title
String The title for the X-axis.

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set XAxis Title Text Style(textStyle)

Sets the horizontal axis title text style.

 // Creates a line chart builder and sets the X-axis title text style to blue, 
 // 18-point font. 
 const 
  
 textStyle 
  
 = 
  
 Charts 
 . 
 newTextStyle 
 (). 
 setColor 
 ( 
 'blue' 
 ). 
 setFontSize 
 ( 
 18 
 ). 
 build 
 (); 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setXAxisTitleTextStyle 
 ( 
 textStyle 
 ); 

Parameters

Name Type Description
text Style
Text Style The text style to use for the horizontal axis title. You can create a Text Style Builder object by calling Charts.newTextStyle() .

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set YAxis Text Style(textStyle)

Sets the vertical axis text style.

 // Creates a line chart builder and sets the Y-axis text style to blue, 18-point 
 // font. 
 const 
  
 textStyle 
  
 = 
  
 Charts 
 . 
 newTextStyle 
 (). 
 setColor 
 ( 
 'blue' 
 ). 
 setFontSize 
 ( 
 18 
 ). 
 build 
 (); 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setYAxisTextStyle 
 ( 
 textStyle 
 ); 

Parameters

Name Type Description
text Style
Text Style The text style to use for the horizontal axis title. You can create a Text Style Builder object by calling Charts.newTextStyle() .

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set YAxis Title(title)

Adds a title to the vertical axis. The title is centered and appears to the left of the value labels.

 // Creates a line chart builder and sets the Y-axis title. 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setYAxisTitle 
 ( 
 'Y-axis Title' 
 ); 

Parameters

Name Type Description
title
String The title for the Y-axis.

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


set YAxis Title Text Style(textStyle)

Sets the vertical axis title text style.

 // Creates a line chart builder and sets the Y-axis title text style to blue, 
 // 18-point font. 
 const 
  
 textStyle 
  
 = 
  
 Charts 
 . 
 newTextStyle 
 (). 
 setColor 
 ( 
 'blue' 
 ). 
 setFontSize 
 ( 
 18 
 ). 
 build 
 (); 
 const 
  
 builder 
  
 = 
  
 Charts 
 . 
 newLineChart 
 (); 
 builder 
 . 
 setYAxisTitleTextStyle 
 ( 
 textStyle 
 ); 

Parameters

Name Type Description
text Style
Text Style The text style to use for the horizontal axis title. You can create a Text Style Builder object by calling Charts.newTextStyle() .

Return

Embedded Combo Chart Builder — This builder, useful for chaining.


use Log Scale()

Makes the range axis into a logarithmic scale (requires all values to be positive). The range axis are the vertical axis for vertical charts (such as line, area, or column) and the horizontal axis for horizontal charts (such as bar).

Return

Embedded Combo Chart Builder — This builder, useful for chaining.

Create a Mobile Website
View Site in Mobile | Classic
Share by: