Commit aea74f0e by Torkel Ödegaard Committed by GitHub

Merge pull request #14426 from grafana/fix-singlestat-repeat-variable-issue

fixed issue with singlestat and repeated scopedVars
parents 6f061ab1 976d25d6
...@@ -107,7 +107,10 @@ class SingleStatCtrl extends MetricsPanelCtrl { ...@@ -107,7 +107,10 @@ class SingleStatCtrl extends MetricsPanelCtrl {
} }
onDataReceived(dataList) { onDataReceived(dataList) {
const data: any = {}; const data: any = {
scopedVars: _.extend({}, this.panel.scopedVars),
};
if (dataList.length > 0 && dataList[0].type === 'table') { if (dataList.length > 0 && dataList[0].type === 'table') {
this.dataType = 'table'; this.dataType = 'table';
const tableData = dataList.map(this.tableHandler.bind(this)); const tableData = dataList.map(this.tableHandler.bind(this));
...@@ -117,6 +120,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { ...@@ -117,6 +120,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
this.series = dataList.map(this.seriesHandler.bind(this)); this.series = dataList.map(this.seriesHandler.bind(this));
this.setValues(data); this.setValues(data);
} }
this.data = data; this.data = data;
this.render(); this.render();
} }
...@@ -320,7 +324,6 @@ class SingleStatCtrl extends MetricsPanelCtrl { ...@@ -320,7 +324,6 @@ class SingleStatCtrl extends MetricsPanelCtrl {
} }
// Add $__name variable for using in prefix or postfix // Add $__name variable for using in prefix or postfix
data.scopedVars = _.extend({}, this.panel.scopedVars);
data.scopedVars['__name'] = { value: this.series[0].label }; data.scopedVars['__name'] = { value: this.series[0].label };
} }
this.setValueMapping(data); this.setValueMapping(data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment