Text

Texts can be displayed by creating a text layer. You can configure it as a fixed text (e.g. my dashboard) or bind it to a field (e.g. asset name).

Mapping values

You can map field values to texts in the advanced mode of the layer under encoding -> text -> map. On the left you should set the field value and on the right the text to be displayed. If the field value is not found in the map, the value configuration will be used.

{
  "name": "Status",
  "type": "text",
  "encoding": {
    "text": {
      "field": "type",
      "map": {
        "1": "Interrupted",
        "2": "Stopped",
        "3": "Running"
      },
      "value": "Unknown"
    }
  }
}

The JSON specification only supports strings as keys, but Hopara automatically converts them to numbers if applicable.

Formatting numbers

You can define the format a number should be displayed in the advanced mode of the layer under encoding -> text -> format. Hopara uses d3-format specification. Examples:

Format Description Value Output
, Add thousand separator 345432 345,432
.2f Round to 2 decimals 34.45678 34.46
,.2f Add thousand separator and round to 2 decimals 345432.45678 345,432.46

Formatting dates

You can define the format a date should be displayed in the advanced mode of the layer under encoding -> text -> format. Hopara uses d3-time-format specification. Examples:

Format Output
%d/%m/%Y 30/01/2024
%d/%m/%Y %H:%m 30/01/2024 23:15