Fix: make sure that we the gauge panel can handle scenario with no data. (#24938)

* make sure that we can handle the empty data scenario in the gauge.

* reverted Guague.tsx and set default values on no data.
This commit is contained in:
Marcus Andersson 2020-05-27 14:51:15 +02:00 committed by GitHub
parent 47b2650a99
commit f795a1577c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -161,6 +161,18 @@ describe('FieldDisplay', () => {
expect(display[0].display.numeric).toEqual(0);
});
it('Should always return defaults with min/max 0 when there is no data', () => {
const options = createEmptyDisplayOptions({
fieldConfig: {
defaults: {},
},
});
const display = getFieldDisplayValues(options);
expect(display[0].field.min).toEqual(0);
expect(display[0].field.max).toEqual(0);
});
describe('Value mapping', () => {
it('should apply value mapping', () => {
const mappingConfig = [

View File

@ -275,6 +275,8 @@ function createNoValuesFieldDisplay(options: GetFieldDisplayValuesOptions): Fiel
name: displayName,
field: {
...defaults,
max: defaults.max ?? 0,
min: defaults.min ?? 0,
},
display: {
text,