Class TextStyle

TextStyle

Đối tượng cấu hình kiểu văn bản. Được dùng trong các tuỳ chọn biểu đồ để định cấu hình kiểu văn bản cho các phần tử chấp nhận kiểu văn bản đó, chẳng hạn như tiêu đề, trục ngang, trục tung, chú giải và chú giải công cụ.

// This example creates a chart specifying different text styles for the title and axes.
  var 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();

  var titleTextStyleBuilder = Charts.newTextStyle()
      .setColor('#0000FF').setFontSize(26).setFontName('Ariel');
  var axisTextStyleBuilder = Charts.newTextStyle()
      .setColor('#3A3A3A').setFontSize(20).setFontName('Ariel');
  var titleTextStyle = titleTextStyleBuilder.build();
  var axisTextStyle = axisTextStyleBuilder.build();

  var chart = Charts.newLineChart()
      .setTitleTextStyle(titleTextStyle)
      .setXAxisTitleTextStyle(axisTextStyle)
      .setYAxisTitleTextStyle(axisTextStyle)
      .setTitle('Rainy Days Per Season')
      .setXAxisTitle('Season')
      .setYAxisTitle('Number of Rainy Days')
      .setDataTable(sampleData)
      .build();

Phương thức

Phương thứcKiểu dữ liệu trả vềMô tả ngắn
getColor()StringLấy màu của kiểu văn bản.
getFontName()StringLấy tên phông chữ của kiểu văn bản.
getFontSize()NumberLấy kích thước phông chữ của kiểu văn bản.

Tài liệu chi tiết

getColor()

Lấy màu của kiểu văn bản.

// Creates a new text style that uses blue text and logs the color.
var textStyle = Charts.newTextStyle().setColor('blue').build();
Logger.log(textStyle.getColor());

Cầu thủ trả bóng

String – Giá trị CSS cho màu (chẳng hạn như "blue" hoặc "#00f").


getFontName()

Lấy tên phông chữ của kiểu văn bản.

// Creates a new text style that uses Ariel font and logs the font name.
var textStyle = Charts.newTextStyle().setFontName('Ariel').build();
Logger.log(textStyle.getFontName());

Cầu thủ trả bóng

String – Tên phông chữ.


getFontSize()

Lấy kích thước phông chữ của kiểu văn bản.

// Creates a new text style that uses 18 pixel font size and logs the font size.
var textStyle = Charts.newTextStyle().setFontSize(18).build();
Logger.log(textStyle.getFontSize());

Cầu thủ trả bóng

Number – Kích thước phông chữ tính bằng pixel.