Mit Sammlungen den Überblick behalten Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
TextStyleBuilder
Ein Builder zum Erstellen von TextStyle-Objekten. Damit lassen sich die Eigenschaften des Texts wie Name, Farbe und Größe konfigurieren.
Im folgenden Beispiel wird gezeigt, wie Sie mit dem Builder einen Textstil erstellen. Ein vollständigeres Beispiel finden Sie in der Dokumentation zu TextStyle.
// Creates a new text style that uses 26-point, blue, Ariel font.consttextStyleBuilder=Charts.newTextStyle().setColor('#0000FF').setFontName('Ariel').setFontSize(26);conststyle=textStyleBuilder.build();
Erstellt ein Textstilkonfigurationsobjekt, das mit diesem Builder erstellt wurde, und gibt es zurück.
// Creates a new text style that uses 26-point blue font.consttextStyleBuilder=Charts.newTextStyle().setColor('#0000FF').setFontSize(26);conststyle=textStyleBuilder.build();
Rückflug
TextStyle: Ein Textstilobjekt, das mit diesem Builder erstellt wurde.
setColor(cssValue)
Legt die Farbe des Textformats fest.
// Creates a new text style that uses blue font.consttextStyleBuilder=Charts.newTextStyle().setColor('#0000FF');conststyle=textStyleBuilder.build();
Parameter
Name
Typ
Beschreibung
cssValue
String
Der CSS-Wert für die Farbe, z. B. "blue" oder "#00f".
Rückflug
TextStyleBuilder – Dieser Builder, der für die Verkettung nützlich ist.
setFontName(fontName)
Legt den Schriftartnamen des Textformats fest.
// Creates a new text style that uses Ariel font.consttextStyleBuilder=Charts.newTextStyle().setFontName('Ariel');conststyle=textStyleBuilder.build();
Parameter
Name
Typ
Beschreibung
fontName
String
Der Schriftartname, der für den Textstil verwendet werden soll.
Rückflug
TextStyleBuilder – Dieser Builder, der für die Verkettung nützlich ist.
setFontSize(fontSize)
Legt die Schriftgröße des Textformats fest.
// Creates a new text style that uses 26-point font.consttextStyleBuilder=Charts.newTextStyle().setFontSize(26);conststyle=textStyleBuilder.build();
Parameter
Name
Typ
Beschreibung
fontSize
Number
Die Schriftgröße in Pixeln, die für den Textstil verwendet werden soll.
Rückflug
TextStyleBuilder – Dieser Builder, der für die Verkettung nützlich ist.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-26 (UTC)."],[[["\u003cp\u003eTextStyleBuilder is used to create TextStyle objects for customizing chart text appearance.\u003c/p\u003e\n"],["\u003cp\u003eIt allows configuration of text properties such as color, font name, and font size using methods like \u003ccode\u003esetColor\u003c/code\u003e, \u003ccode\u003esetFontName\u003c/code\u003e, and \u003ccode\u003esetFontSize\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebuild\u003c/code\u003e method finalizes the configuration and returns a TextStyle object ready to be applied.\u003c/p\u003e\n"],["\u003cp\u003eTextStyleBuilder facilitates a chained approach for building the desired text style by returning the builder instance after each method call.\u003c/p\u003e\n"]]],["The `TextStyleBuilder` creates `TextStyle` objects, allowing text property configuration. Key actions include setting the text color via `setColor(cssValue)` using CSS values. The font is set using `setFontName(fontName)`, taking a string for the desired font. The font size is controlled with `setFontSize(fontSize)`, where the parameter represents pixel size. `build()` finalizes and returns the constructed `TextStyle` object. These methods can be chained.\n"],null,["TextStyleBuilder\n\nA builder used to create [TextStyle](/apps-script/reference/charts/text-style) objects. It allows configuration of the text's\nproperties such as name, color, and size.\n\nThe following example shows how to create a text style using the builder. For a more complete\nexample, refer to the documentation for [TextStyle](/apps-script/reference/charts/text-style).\n\n```javascript\n// Creates a new text style that uses 26-point, blue, Ariel font.\nconst textStyleBuilder =\n Charts.newTextStyle().setColor('#0000FF').setFontName('Ariel').setFontSize(\n 26);\nconst style = textStyleBuilder.build();\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------|-------------------------------------------------------|-----------------------------------------------------------------------------------------|\n| [build()](#build()) | [TextStyle](/apps-script/reference/charts/text-style) | Builds and returns a text style configuration object that was built using this builder. |\n| [setColor(cssValue)](#setColor(String)) | [TextStyleBuilder](#) | Sets the color of the text style. |\n| [setFontName(fontName)](#setFontName(String)) | [TextStyleBuilder](#) | Sets the font name of the text style. |\n| [setFontSize(fontSize)](#setFontSize(Number)) | [TextStyleBuilder](#) | Sets the font size of the text style. |\n\nDetailed documentation \n\n`build()` \nBuilds and returns a text style configuration object that was built using this builder.\n\n```javascript\n// Creates a new text style that uses 26-point blue font.\nconst textStyleBuilder =\n Charts.newTextStyle().setColor('#0000FF').setFontSize(26);\nconst style = textStyleBuilder.build();\n```\n\nReturn\n\n\n[TextStyle](/apps-script/reference/charts/text-style) --- A text style object built using this builder.\n\n*** ** * ** ***\n\n`set``Color(cssValue)` \nSets the color of the text style.\n\n```javascript\n// Creates a new text style that uses blue font.\nconst textStyleBuilder = Charts.newTextStyle().setColor('#0000FF');\nconst style = textStyleBuilder.build();\n```\n\nParameters\n\n| Name | Type | Description |\n|--------------|----------|-------------------------------------------------------------|\n| `css``Value` | `String` | The CSS value for the color (such as `\"blue\"` or `\"#00f\"`). |\n\nReturn\n\n\n[TextStyleBuilder](#) --- This builder, useful for chaining.\n\n*** ** * ** ***\n\n`set``Font``Name(fontName)` \nSets the font name of the text style.\n\n```javascript\n// Creates a new text style that uses Ariel font.\nconst textStyleBuilder = Charts.newTextStyle().setFontName('Ariel');\nconst style = textStyleBuilder.build();\n```\n\nParameters\n\n| Name | Type | Description |\n|--------------|----------|------------------------------------------|\n| `font``Name` | `String` | The font name to use for the text style. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- This builder, useful for chaining.\n\n*** ** * ** ***\n\n`set``Font``Size(fontSize)` \nSets the font size of the text style.\n\n```javascript\n// Creates a new text style that uses 26-point font.\nconst textStyleBuilder = Charts.newTextStyle().setFontSize(26);\nconst style = textStyleBuilder.build();\n```\n\nParameters\n\n| Name | Type | Description |\n|--------------|----------|----------------------------------------------------|\n| `font``Size` | `Number` | The font size in pixels to use for the text style. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- This builder, useful for chaining."]]