From 976d25d6ae572c4052f57957bd5853f519ec8ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 10 Dec 2018 13:40:32 +0100 Subject: [PATCH] fixed issue with singlestat and repeated scopedVars, was only working for time series data sources, and only if there was any series, now scoped vars is always set, fixes #14367 --- public/app/plugins/panel/singlestat/module.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 26ce6b7722d..f83151a0c46 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -107,7 +107,10 @@ class SingleStatCtrl extends MetricsPanelCtrl { } onDataReceived(dataList) { - const data: any = {}; + const data: any = { + scopedVars: _.extend({}, this.panel.scopedVars), + }; + if (dataList.length > 0 && dataList[0].type === 'table') { this.dataType = 'table'; const tableData = dataList.map(this.tableHandler.bind(this)); @@ -117,6 +120,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { this.series = dataList.map(this.seriesHandler.bind(this)); this.setValues(data); } + this.data = data; this.render(); } @@ -320,7 +324,6 @@ class SingleStatCtrl extends MetricsPanelCtrl { } // Add $__name variable for using in prefix or postfix - data.scopedVars = _.extend({}, this.panel.scopedVars); data.scopedVars['__name'] = { value: this.series[0].label }; } this.setValueMapping(data);