Skip to content

Commit

Permalink
Issue grafana#4740 - able to use $SeriesName variable in prefix of po…
Browse files Browse the repository at this point in the history
…stfix.
  • Loading branch information
alexanderzobnin committed Jun 21, 2016
1 parent 87ab97b commit cc433c1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion public/app/plugins/panel/singlestat/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -296,7 +303,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
}

function getSpan(className, fontSize, value) {
value = templateSrv.replace(value);
value = templateSrv.replace(value, data.scopedVars);
return '<span class="' + className + '" style="font-size:' + fontSize + '">' +
value + '</span>';
}
Expand Down

0 comments on commit cc433c1

Please sign in to comment.