Commit f795a157 by Marcus Andersson Committed by GitHub

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.
parent 47b2650a
...@@ -161,6 +161,18 @@ describe('FieldDisplay', () => { ...@@ -161,6 +161,18 @@ describe('FieldDisplay', () => {
expect(display[0].display.numeric).toEqual(0); 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', () => { describe('Value mapping', () => {
it('should apply value mapping', () => { it('should apply value mapping', () => {
const mappingConfig = [ const mappingConfig = [
......
...@@ -275,6 +275,8 @@ function createNoValuesFieldDisplay(options: GetFieldDisplayValuesOptions): Fiel ...@@ -275,6 +275,8 @@ function createNoValuesFieldDisplay(options: GetFieldDisplayValuesOptions): Fiel
name: displayName, name: displayName,
field: { field: {
...defaults, ...defaults,
max: defaults.max ?? 0,
min: defaults.min ?? 0,
}, },
display: { display: {
text, text,
......
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