TextStyle オブジェクトを作成するために使用されるビルダー。名前、色、サイズなど、テキストのプロパティを構成できます。
次の例は、ビルダーを使用してテキスト スタイルを作成する方法を示しています。完全な例については、TextStyle のドキュメントをご覧ください。
// Creates a new text style that uses 26-point, blue, Ariel font. const textStyleBuilder = Charts.newTextStyle().setColor('#0000FF').setFontName('Ariel').setFontSize( 26); const style = textStyleBuilder.build();
メソッド
| メソッド | 戻り値の型 | 概要 |
|---|---|---|
build() | Text | このビルダーを使用して作成されたテキスト スタイル構成オブジェクトを作成して返します。 |
set | Text | テキスト スタイルの色を設定します。 |
set | Text | テキスト スタイルのフォント名を設定します。 |
set | Text | テキスト スタイルのフォントサイズを設定します。 |
詳細なドキュメント
build()
このビルダーを使用して作成されたテキスト スタイル構成オブジェクトを作成して返します。
// Creates a new text style that uses 26-point blue font. const textStyleBuilder = Charts.newTextStyle().setColor('#0000FF').setFontSize(26); const style = textStyleBuilder.build();
戻る
TextStyle \- このビルダーを使用して作成されたテキスト スタイル オブジェクト。
setColor(cssValue)
テキスト スタイルの色を設定します。
// Creates a new text style that uses blue font. const textStyleBuilder = Charts.newTextStyle().setColor('#0000FF'); const style = textStyleBuilder.build();
パラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
css | String | 色の CSS 値("blue" や "#00f" など)。 |
戻る
TextStyleBuilder \- このビルダーは、チェーン処理に便利です。
setFontName(fontName)
テキスト スタイルのフォント名を設定します。
// Creates a new text style that uses Ariel font. const textStyleBuilder = Charts.newTextStyle().setFontName('Ariel'); const style = textStyleBuilder.build();
パラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
font | String | テキスト スタイルに使用するフォント名。 |
戻る
TextStyleBuilder \- このビルダーは、チェーン処理に便利です。
setFontSize(fontSize)
テキスト スタイルのフォントサイズを設定します。
// Creates a new text style that uses 26-point font. const textStyleBuilder = Charts.newTextStyle().setFontSize(26); const style = textStyleBuilder.build();
パラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
font | Number | テキスト スタイルに使用するフォントサイズ(ピクセル単位)。 |
戻る
TextStyleBuilder \- このビルダーは、チェーン処理に便利です。