Google Apps Script

Class TextStyleBuilder

A builder used to create TextStyle objects. It allows configuration of the text's properties such as name, color, and size.

The following example shows how to create a text style using the builder. For a more complete example, refer to the documentation for TextStyle.

 
// Creates a new text style that uses 26-point, blue, Ariel font.
 var textStyleBuilder = Charts.newTextStyle()
     .setColor('#0000FF').setFontName('Ariel').setFontSize(26);
 var style = textStyleBuilder.build();
 

Methods

MethodReturn typeBrief description
build()TextStyleBuilds and returns a text style configuration object that was built using this builder.
setColor(cssValue)TextStyleBuilderSets the color of the text style.
setFontName(fontName)TextStyleBuilderSets the font name of the text style
setFontSize(fontSize)TextStyleBuilderSets the font size of the text style.

Detailed documentation

build()

Builds and returns a text style configuration object that was built using this builder.

 
// Creates a new text style that uses 26-point blue font.
 var textStyleBuilder = Charts.newTextStyle().setColor('#0000FF').setFontSize(26);
 var style = textStyleBuilder.build();
 

Return

TextStyle — a TextStyle object built using this builder


setColor(cssValue)

Sets the color of the text style.

 
// Creates a new text style that uses blue font.
 var textStyleBuilder = Charts.newTextStyle().setColor('#0000FF');
 var style = textStyleBuilder.build();
 

Parameters

NameTypeDescription
cssValueStringthe CSS value for the color (such as "blue" or "#00f").

Return

TextStyleBuilder — this builder, useful for chaining.


setFontName(fontName)

Sets the font name of the text style

 
// Creates a new text style that uses Ariel font.
 var textStyleBuilder = Charts.newTextStyle().setFontName('Ariel');
 var style = textStyleBuilder.build();
 

Parameters

NameTypeDescription
fontNameStringthe font name to use for the text style

Return

TextStyleBuilder — this builder, useful for chaining.


setFontSize(fontSize)

Sets the font size of the text style.

 
// Creates a new text style that uses 26-point font.
 var textStyleBuilder = Charts.newTextStyle().setFontSize(26);
 var style = textStyleBuilder.build();
 

Parameters

NameTypeDescription
fontSizeNumberthe font size in pixels to use for the text style

Return

TextStyleBuilder — this builder, useful for chaining.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.