mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
BarChart: Show "No data" message for zero-length frames (#79844)
This commit is contained in:
parent
feb7b38fba
commit
36a3508a0f
@ -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…
Reference in New Issue
Block a user