Class TextStyle

TextStyle

Um objeto de configuração de estilo de texto. Usado nas opções de gráficos para configurar o estilo de texto dos elementos que o aceitam, como título, eixo horizontal, eixo vertical, legenda e dica.

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

Métodos

MétodoTipo de retornoBreve descrição
getColor()StringRecebe a cor do estilo do texto.
getFontName()StringRecebe o nome da fonte do estilo de texto.
getFontSize()NumberRecebe o tamanho da fonte do estilo de texto.

Documentação detalhada

getColor()

Recebe a cor do estilo do texto.

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

Retorno

String: o valor de CSS para a cor (como "blue" ou "#00f").


getFontName()

Recebe o nome da fonte do estilo de texto.

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

Retorno

String: o nome da fonte.


getFontSize()

Recebe o tamanho da fonte do estilo de texto.

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

Retorno

Number: o tamanho da fonte em pixels.