BarChart: Show "No data" message for zero-length frames (#79844)

pull/78292/head
Leon Sorokin 1 year ago committed by GitHub
parent feb7b38fba
commit 36a3508a0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      public/app/plugins/panel/barchart/utils.test.ts
  2. 2
      public/app/plugins/panel/barchart/utils.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: [

@ -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' };
}

Loading…
Cancel
Save