diff --git a/public/app/plugins/panel/barchart/utils.test.ts b/public/app/plugins/panel/barchart/utils.test.ts index 3818df464dc..210bb5a52a9 100644 --- a/public/app/plugins/panel/barchart/utils.test.ts +++ b/public/app/plugins/panel/barchart/utils.test.ts @@ -158,13 +158,29 @@ describe('BarChart utils', () => { }); describe('prepareGraphableFrames', () => { - it('will warn when there is no data in the response', () => { + it('will warn when there is no frames in the response', () => { const result = prepareBarChartDisplayValues([], createTheme(), { stacking: StackingMode.None } as Options); const warning = assertIsDefined('warn' in result ? result : null); expect(warning.warn).toEqual('No data in response'); }); + it('will warn when there is no data in the response', () => { + const result = prepareBarChartDisplayValues( + [ + { + length: 0, + fields: [], + }, + ], + createTheme(), + { stacking: StackingMode.None } as Options + ); + const warning = assertIsDefined('warn' in result ? result : null); + + expect(warning.warn).toEqual('No data in response'); + }); + it('will warn when there is no string or time field', () => { const df = new MutableDataFrame({ fields: [ diff --git a/public/app/plugins/panel/barchart/utils.ts b/public/app/plugins/panel/barchart/utils.ts index e999f750022..dad84245c43 100644 --- a/public/app/plugins/panel/barchart/utils.ts +++ b/public/app/plugins/panel/barchart/utils.ts @@ -375,7 +375,7 @@ export function prepareBarChartDisplayValues( theme: GrafanaTheme2, options: Options ): BarChartDisplayValues | BarChartDisplayWarning { - if (!series?.length) { + if (!series.length || series.every((fr) => fr.length === 0)) { return { warn: 'No data in response' }; }