diff --git a/docs/widgets/services/customapi.md b/docs/widgets/services/customapi.md index 2e23f1d8a..e13874610 100644 --- a/docs/widgets/services/customapi.md +++ b/docs/widgets/services/customapi.md @@ -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 diff --git a/src/widgets/customapi/component.jsx b/src/widgets/customapi/component.jsx index 62405faf2..19a89a316 100644 --- a/src/widgets/customapi/component.jsx +++ b/src/widgets/customapi/component.jsx @@ -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) {