From cc433c1fbdd7c118e768875ac1f0bc17aa9db5b7 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 21 Jun 2016 15:48:18 +0300 Subject: [PATCH 1/2] Issue #4740 - able to use $SeriesName variable in prefix of postfix. --- public/app/plugins/panel/singlestat/module.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 59da49ca3d5..078f682be20 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -199,6 +199,13 @@ class SingleStatCtrl extends MetricsPanelCtrl { data.valueFormated = formatFunc(data.value, decimalInfo.decimals, decimalInfo.scaledDecimals); data.valueRounded = kbn.roundValue(data.value, decimalInfo.decimals); } + + // Add $SeriesName variable for using in prefix or postfix + data.scopedVars = { + SeriesName: { + value: this.series[0].label + } + }; } // check value to text mappings if its enabled @@ -296,7 +303,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { } function getSpan(className, fontSize, value) { - value = templateSrv.replace(value); + value = templateSrv.replace(value, data.scopedVars); return '' + value + ''; } From e593cc3e9f34a32b8ffb4641225c9bc4d60b8a1f Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 23 Jun 2016 19:35:50 +0300 Subject: [PATCH 2/2] Issue #4740 - change variable $SeriesName to $seriesName. --- public/app/plugins/panel/singlestat/module.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 078f682be20..a1998a778a3 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -200,9 +200,9 @@ class SingleStatCtrl extends MetricsPanelCtrl { data.valueRounded = kbn.roundValue(data.value, decimalInfo.decimals); } - // Add $SeriesName variable for using in prefix or postfix + // Add $seriesName variable for using in prefix or postfix data.scopedVars = { - SeriesName: { + seriesName: { value: this.series[0].label } };