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
This commit is contained in:
parent
01b10ab436
commit
00ec37f55f
packages/grafana-data/src/field
@ -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: {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user