diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index 1a8fb3c0481..01f7a485aa6 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -26,8 +26,7 @@ class GraphCtrl extends MetricsPanelCtrl { alertState: any; annotationsPromise: any; - datapointsCount: number; - datapointsOutside: boolean; + dataWarning: any; colors: any = []; subTabIndex: number; processor: DataProcessor; @@ -178,14 +177,26 @@ class GraphCtrl extends MetricsPanelCtrl { this.dataList = dataList; this.seriesList = this.processor.getSeriesList({dataList: dataList, range: this.range}); - this.datapointsCount = this.seriesList.reduce((prev, series) => { + this.dataWarning = null; + const datapointsCount = this.seriesList.reduce((prev, series) => { return prev + series.datapoints.length; }, 0); - this.datapointsOutside = false; - for (let series of this.seriesList) { - if (series.isOutsideRange) { - this.datapointsOutside = true; + if (datapointsCount === 0) { + this.dataWarning = { + title: 'No data points', + tip: 'No datapoints returned from data query' + }; + } else { + + for (let series of this.seriesList) { + if (series.isOutsideRange) { + this.dataWarning = { + title: 'Data points outside time range', + tip: 'Can be caused by timezone mismatch or missing time filter in query', + }; + break; + } } } diff --git a/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts b/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts index d06c66e253a..ab91b87ece9 100644 --- a/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts +++ b/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts @@ -35,7 +35,7 @@ describe('GraphCtrl', function() { }); it('should set datapointsOutside', function() { - expect(ctx.ctrl.datapointsOutside).to.be(true); + expect(ctx.ctrl.dataWarning.title).to.be('Data points outside time range'); }); }); @@ -55,21 +55,21 @@ describe('GraphCtrl', function() { }); it('should set datapointsOutside', function() { - expect(ctx.ctrl.datapointsOutside).to.be(false); + expect(ctx.ctrl.dataWarning).to.be(null); }); }); describe('datapointsCount given 2 series', function() { beforeEach(function() { var data = [ - {target: 'test.cpu1', datapoints: [[45, 1234567890], [60, 1234567899]]}, - {target: 'test.cpu2', datapoints: [[45, 1234567890]]}, + {target: 'test.cpu1', datapoints: []}, + {target: 'test.cpu2', datapoints: []}, ]; ctx.ctrl.onDataReceived(data); }); - it('should set datapointsCount to sum of datapoints', function() { - expect(ctx.ctrl.datapointsCount).to.be(3); + it('should set datapointsCount warning', function() { + expect(ctx.ctrl.dataWarning.title).to.be('No data points'); }); }); diff --git a/public/app/plugins/panel/graph/template.ts b/public/app/plugins/panel/graph/template.ts index ec6cd8d0907..6ded97ce33a 100644 --- a/public/app/plugins/panel/graph/template.ts +++ b/public/app/plugins/panel/graph/template.ts @@ -2,17 +2,8 @@ var template = `