add prefix and fix example

This commit is contained in:
sgrtye 2024-02-14 22:10:56 +00:00
parent ccd1b64426
commit cdadf44c27
2 changed files with 12 additions and 2 deletions

View File

@ -103,7 +103,7 @@ mappings:
## Data Transformation
You can manipulate data with the following tools `remap`, `scale` and `suffix`, for example:
You can manipulate data with the following tools `remap`, `scale`, `prefix` and `suffix`, for example:
```yaml
- field: key4
@ -120,7 +120,11 @@ You can manipulate data with the following tools `remap`, `scale` and `suffix`,
label: Power
format: float
scale: 0.001 # can be number or string e.g. 1/16
suffix: kW
suffix: "kW"
- field: key6
label: Price
format: float
suffix: "$"
```
## List View

View File

@ -90,6 +90,12 @@ function formatValue(t, transformation, rawValue) {
// nothing
}
// Apply fixed prefix.
const prefix = transformation?.prefix;
if (prefix) {
value = `${prefix} ${value}`;
}
// Apply fixed suffix.
const suffix = transformation?.suffix;
if (suffix) {