format

fun format(field: String, format: String): layerLabels

Defines the format for displaying the value. The format will be applied to the corresponding value specified in the line template.

Parameters

field

Aesthetic or variable name to apply the format to. The field name starts with a '^' prefix for aesthetics, variable names are specified without prefix or with a '@' prefix.

format

A number format ('1.f'), a string template ('{.1f}') or a date/time format ('%d.%m.%y'). The numeric format for non-numeric value will be ignored.

If you need to include a brace character in the literal text, it can be escaped by doubling: {{ and }}, e.g.,

  • .format('^color', '{{ {.1f} }}') -> "{ 17.0 }"

  • .format('model', '{} {{text}}') -> "mustang {text}"

Aes and var formats are not interchangeable, i.e. var format will not be applied to aes, mapped to this variable.