Class TextStyle

Estilo de texto

Un objeto de configuración de estilo de texto. Se usa en las opciones de gráficos para configurar el estilo del texto de los elementos que lo aceptan, como el título, el eje horizontal, el eje vertical, la leyenda y la información sobre la herramienta.

// 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 datos que se muestraDescripción breve
getColor()StringObtiene el color del estilo de texto.
getFontName()StringObtiene el nombre de fuente del estilo de texto.
getFontSize()NumberObtiene el tamaño de fuente del estilo de texto.

Documentación detallada

getColor()

Obtiene el color del estilo de 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());

Volver

String: Es el valor de CSS del color (como "blue" o "#00f").


getFontName()

Obtiene el nombre de fuente del 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());

Volver

String: el nombre de la fuente.


getFontSize()

Obtiene el tamaño de fuente del 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());

Volver

Number: El tamaño de fuente en píxeles.