|
@@ -18,7 +18,6 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) {
|
|
|
|
|
|
|
|
$scope.panelMeta = new PanelMeta({
|
|
$scope.panelMeta = new PanelMeta({
|
|
|
description: 'Singlestat panel',
|
|
description: 'Singlestat panel',
|
|
|
- titlePos: 'left',
|
|
|
|
|
fullscreen: true,
|
|
fullscreen: true,
|
|
|
metricsEditor: true
|
|
metricsEditor: true
|
|
|
});
|
|
});
|
|
@@ -35,9 +34,14 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) {
|
|
|
format: 'none',
|
|
format: 'none',
|
|
|
prefix: '',
|
|
prefix: '',
|
|
|
postfix: '',
|
|
postfix: '',
|
|
|
|
|
+ nullText: null,
|
|
|
|
|
+ valueMaps: [
|
|
|
|
|
+ { value: 'null', op: '=', text: 'N/A' }
|
|
|
|
|
+ ],
|
|
|
|
|
+ nullPointMode: 'connected',
|
|
|
valueName: 'avg',
|
|
valueName: 'avg',
|
|
|
prefixFontSize: '50%',
|
|
prefixFontSize: '50%',
|
|
|
- valueFontSize: '100%',
|
|
|
|
|
|
|
+ valueFontSize: '80%',
|
|
|
postfixFontSize: '50%',
|
|
postfixFontSize: '50%',
|
|
|
thresholds: '',
|
|
thresholds: '',
|
|
|
colorBackground: false,
|
|
colorBackground: false,
|
|
@@ -99,7 +103,7 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) {
|
|
|
alias: seriesData.target,
|
|
alias: seriesData.target,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- series.flotpairs = series.getFlotPairs('connected');
|
|
|
|
|
|
|
+ series.flotpairs = series.getFlotPairs($scope.panel.nullPointMode);
|
|
|
|
|
|
|
|
return series;
|
|
return series;
|
|
|
};
|
|
};
|
|
@@ -170,15 +174,12 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) {
|
|
|
if (!$scope.series || $scope.series.length === 0) {
|
|
if (!$scope.series || $scope.series.length === 0) {
|
|
|
data.flotpairs = [];
|
|
data.flotpairs = [];
|
|
|
data.mainValue = Number.NaN;
|
|
data.mainValue = Number.NaN;
|
|
|
- data.mainValueFormated = 'NaN';
|
|
|
|
|
|
|
+ data.mainValueFormated = $scope.getFormatedValue(null);
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
var series = $scope.series[0];
|
|
var series = $scope.series[0];
|
|
|
data.mainValue = series.stats[$scope.panel.valueName];
|
|
data.mainValue = series.stats[$scope.panel.valueName];
|
|
|
- var decimalInfo = $scope.getDecimalsForValue(data.mainValue);
|
|
|
|
|
- var formatFunc = kbn.valueFormats[$scope.panel.format];
|
|
|
|
|
-
|
|
|
|
|
- data.mainValueFormated = formatFunc(data.mainValue, decimalInfo.decimals, decimalInfo.scaledDecimals);
|
|
|
|
|
|
|
+ data.mainValueFormated = $scope.getFormatedValue(data.mainValue);
|
|
|
data.flotpairs = series.flotpairs;
|
|
data.flotpairs = series.flotpairs;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -192,6 +193,44 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) {
|
|
|
$scope.$emit('render');
|
|
$scope.$emit('render');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ $scope.getFormatedValue = function(mainValue) {
|
|
|
|
|
+
|
|
|
|
|
+ // first check value to text mappings
|
|
|
|
|
+ for(var i = 0; i < $scope.panel.valueMaps.length; i++) {
|
|
|
|
|
+ var map = $scope.panel.valueMaps[i];
|
|
|
|
|
+ // special null case
|
|
|
|
|
+ if (map.value === 'null') {
|
|
|
|
|
+ if (mainValue === null || mainValue === void 0) {
|
|
|
|
|
+ return map.text;
|
|
|
|
|
+ }
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ // value/number to text mapping
|
|
|
|
|
+ var value = parseFloat(map.value);
|
|
|
|
|
+ if (value === mainValue) {
|
|
|
|
|
+ return map.text;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (mainValue === null || mainValue === void 0) {
|
|
|
|
|
+ return "no value";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var decimalInfo = $scope.getDecimalsForValue(mainValue);
|
|
|
|
|
+ var formatFunc = kbn.valueFormats[$scope.panel.format];
|
|
|
|
|
+ return formatFunc(mainValue, decimalInfo.decimals, decimalInfo.scaledDecimals);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ $scope.removeValueMap = function(map) {
|
|
|
|
|
+ var index = _.indexOf($scope.panel.valueMaps, map);
|
|
|
|
|
+ $scope.panel.valueMaps.splice(index, 1);
|
|
|
|
|
+ $scope.render();
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ $scope.addValueMap = function() {
|
|
|
|
|
+ $scope.panel.valueMaps.push({value: '', op: '=', text: '' });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
$scope.init();
|
|
$scope.init();
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|