Commit 00ec37f5 by Oscar Kilhed Committed by GitHub

Panels: Remove value mapping of values that have been formatted #26763 (#30868)

* Panels: Remove value mapping of values that have been formatted
parent 01b10ab4
...@@ -164,6 +164,16 @@ describe('Format value', () => { ...@@ -164,6 +164,16 @@ describe('Format value', () => {
expect(instance(value).numeric).toEqual(1); expect(instance(value).numeric).toEqual(1);
}); });
it('should not map 1kW to the value for 1W', () => {
const valueMappings: ValueMapping[] = [{ id: 0, text: 'mapped', type: MappingType.ValueToText, value: '1' }];
const value = '1000';
const instance = getDisplayProcessorFromConfig({ decimals: 1, mappings: valueMappings, unit: 'watt' });
const result = instance(value);
expect(result.text).toEqual('1.0');
});
it('With null value and thresholds should use base color', () => { it('With null value and thresholds should use base color', () => {
const instance = getDisplayProcessorFromConfig({ const instance = getDisplayProcessorFromConfig({
thresholds: { thresholds: {
......
...@@ -90,14 +90,6 @@ export function getDisplayProcessor(options?: DisplayProcessorOptions): DisplayP ...@@ -90,14 +90,6 @@ export function getDisplayProcessor(options?: DisplayProcessorOptions): DisplayP
text = v.text; text = v.text;
suffix = v.suffix; suffix = v.suffix;
prefix = v.prefix; prefix = v.prefix;
// Check if the formatted text mapped to a different value
if (mappings && mappings.length > 0) {
const mappedValue = getMappedValue(mappings, text);
if (mappedValue) {
text = mappedValue.text;
}
}
} }
// Return the value along with scale info // Return the value along with scale info
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment