format

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

Defines the format for displaying the value. The format will be applied to the mapped value in the default tooltip or 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. It's possible to set the format for all positional aesthetics:

  • field = "^X" - for all positional x;

  • field = "^Y" - for all positional y.

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}"

The string template in format will allow to change lines for the default tooltip without 'line' specifying. Also, the template will change the line for outliers. Aes and var formats are not interchangeable, i.e. var format will not be applied to aes, mapped to this variable.