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();

เมธอด

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
getColor()Stringรับสีของรูปแบบข้อความ
getFontName()Stringรับชื่อแบบอักษรของรูปแบบข้อความ
getFontSize()Numberรับขนาดแบบอักษรของรูปแบบข้อความ

เอกสารประกอบโดยละเอียด

getColor()

รับสีของรูปแบบข้อความ

// 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")


getFontName()

รับชื่อแบบอักษรของรูปแบบข้อความ

// 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 — ชื่อแบบอักษร


getFontSize()

รับขนาดแบบอักษรของรูปแบบข้อความ

// 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 — ขนาดแบบอักษรเป็นพิกเซล