3
0
mirror of https://github.com/grafana/grafana.git synced 2025-02-25 18:55:37 -06:00

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

* Panels: Remove value mapping of values that have been formatted
This commit is contained in:
Oscar Kilhed 2021-02-04 10:24:54 +01:00 committed by GitHub
parent 01b10ab436
commit 00ec37f55f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions
packages/grafana-data/src/field

View File

@ -164,6 +164,16 @@ describe('Format value', () => {
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', () => {
const instance = getDisplayProcessorFromConfig({
thresholds: {

View File

@ -90,14 +90,6 @@ export function getDisplayProcessor(options?: DisplayProcessorOptions): DisplayP
text = v.text;
suffix = v.suffix;
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