Class TextStyle
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
سبک متن یک شی پیکربندی سبک متن. در گزینههای نمودارها برای پیکربندی سبک متن برای عناصری که آن را میپذیرند، مانند عنوان، محور افقی، محور عمودی، افسانه و راهنمای ابزار استفاده میشود.
// This example creates a chart specifying different text styles for the title
// and axes.
const sampleData = Charts.newDataTable()
.addColumn(Charts.ColumnType.STRING, 'Seasons')
.addColumn(Charts.ColumnType.NUMBER, 'Rainy Days')
.addRow(['Winter', 5])
.addRow(['Spring', 12])
.addRow(['Summer', 8])
.addRow(['Fall', 8])
.build();
const titleTextStyleBuilder =
Charts.newTextStyle().setColor('#0000FF').setFontSize(26).setFontName(
'Ariel');
const axisTextStyleBuilder =
Charts.newTextStyle().setColor('#3A3A3A').setFontSize(20).setFontName(
'Ariel');
const titleTextStyle = titleTextStyleBuilder.build();
const axisTextStyle = axisTextStyleBuilder.build();
const chart = Charts.newLineChart()
.setTitleTextStyle(titleTextStyle)
.setXAxisTitleTextStyle(axisTextStyle)
.setYAxisTitleTextStyle(axisTextStyle)
.setTitle('Rainy Days Per Season')
.setXAxisTitle('Season')
.setYAxisTitle('Number of Rainy Days')
.setDataTable(sampleData)
.build();
مستندات دقیق
get Color()
رنگ سبک متن را می گیرد.
// Creates a new text style that uses blue text and logs the color.
const textStyle = Charts.newTextStyle().setColor('blue').build();
Logger.log(textStyle.getColor());
بازگشت
String
- مقدار CSS برای رنگ (مانند "blue"
یا "#00f"
).
get Font Name()
نام فونت سبک متن را دریافت می کند.
// Creates a new text style that uses Ariel font and logs the font name.
const textStyle = Charts.newTextStyle().setFontName('Ariel').build();
Logger.log(textStyle.getFontName());
بازگشت
String
- نام فونت.
get Font Size()
اندازه فونت سبک متن را دریافت می کند.
// Creates a new text style that uses 18 pixel font size and logs the font size.
const textStyle = Charts.newTextStyle().setFontSize(18).build();
Logger.log(textStyle.getFontSize());
بازگشت
Number
- اندازه فونت بر حسب پیکسل.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003e\u003ccode\u003eTextStyle\u003c/code\u003e objects configure the visual appearance of text elements in charts, such as titles, axes, legends, and tooltips.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize text 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\u003eTextStyle\u003c/code\u003e object is used within chart options to apply these styles to specific chart elements.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetColor()\u003c/code\u003e, \u003ccode\u003egetFontName()\u003c/code\u003e, and \u003ccode\u003egetFontSize()\u003c/code\u003e methods retrieve the current style settings of a \u003ccode\u003eTextStyle\u003c/code\u003e object.\u003c/p\u003e\n"]]],[],null,["# Class TextStyle\n\nTextStyle\n\nA text style configuration object. Used in charts options to configure text style for elements\nthat accepts it, such as title, horizontal axis, vertical axis, legend and tooltip.\n\n```javascript\n// This example creates a chart specifying different text styles for the title\n// and axes.\nconst sampleData = Charts.newDataTable()\n .addColumn(Charts.ColumnType.STRING, 'Seasons')\n .addColumn(Charts.ColumnType.NUMBER, 'Rainy Days')\n .addRow(['Winter', 5])\n .addRow(['Spring', 12])\n .addRow(['Summer', 8])\n .addRow(['Fall', 8])\n .build();\n\nconst titleTextStyleBuilder =\n Charts.newTextStyle().setColor('#0000FF').setFontSize(26).setFontName(\n 'Ariel');\nconst axisTextStyleBuilder =\n Charts.newTextStyle().setColor('#3A3A3A').setFontSize(20).setFontName(\n 'Ariel');\nconst titleTextStyle = titleTextStyleBuilder.build();\nconst axisTextStyle = axisTextStyleBuilder.build();\n\nconst chart = Charts.newLineChart()\n .setTitleTextStyle(titleTextStyle)\n .setXAxisTitleTextStyle(axisTextStyle)\n .setYAxisTitleTextStyle(axisTextStyle)\n .setTitle('Rainy Days Per Season')\n .setXAxisTitle('Season')\n .setYAxisTitle('Number of Rainy Days')\n .setDataTable(sampleData)\n .build();\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------|-------------|---------------------------------------|\n| [getColor()](#getColor()) | `String` | Gets the color of the text style. |\n| [getFontName()](#getFontName()) | `String` | Gets the font name of the text style. |\n| [getFontSize()](#getFontSize()) | `Number` | Gets the font size of the text style. |\n\nDetailed documentation\n----------------------\n\n### `get``Color()`\n\nGets the color of the text style.\n\n```javascript\n// Creates a new text style that uses blue text and logs the color.\nconst textStyle = Charts.newTextStyle().setColor('blue').build();\nLogger.log(textStyle.getColor());\n```\n\n#### Return\n\n\n`String` --- The CSS value for the color (such as `\"blue\"` or `\"#00f\"`).\n\n*** ** * ** ***\n\n### `get``Font``Name()`\n\nGets the font name of the text style.\n\n```javascript\n// Creates a new text style that uses Ariel font and logs the font name.\nconst textStyle = Charts.newTextStyle().setFontName('Ariel').build();\nLogger.log(textStyle.getFontName());\n```\n\n#### Return\n\n\n`String` --- The font name.\n\n*** ** * ** ***\n\n### `get``Font``Size()`\n\nGets the font size of the text style.\n\n```javascript\n// Creates a new text style that uses 18 pixel font size and logs the font size.\nconst textStyle = Charts.newTextStyle().setFontSize(18).build();\nLogger.log(textStyle.getFontSize());\n```\n\n#### Return\n\n\n`Number` --- The font size in pixels."]]