Commit 7808d798 by joshiste Committed by Johannes Stelzer

Added support für RichGagues in metrics-view

parent 78243e15
...@@ -82,23 +82,72 @@ angular.module('springBootAdmin') ...@@ -82,23 +82,72 @@ angular.module('springBootAdmin')
//*** Extract data for Counter-Chart and Gauge-Chart //*** Extract data for Counter-Chart and Gauge-Chart
$scope.counterData = [ { key : "value", values: [] } ]; $scope.counterData = [ { key : "value", values: [] } ];
$scope.gaugeData = [ { key : "value", values: [] } ]; $scope.gaugeData = [ { key : "value", values: [] },
{ key : "average", values: [] },
{ key : "min", values: [] },
{ key : "max", values: [] },
{ key : "count", values: [] } ];
for (var metric in application.metrics) { for (var metric in application.metrics) {
var matchCounter = /counter\.(.+)/.exec(metric); var matchCounter = /counter\.(.+)/.exec(metric);
if ( matchCounter !== null) { if ( matchCounter !== null) {
$scope.counterData[0].values.push([ matchCounter[1], application.metrics[metric] ]); $scope.counterData[0].values.push([ matchCounter[1], application.metrics[metric] ]);
continue;
}
var matchGaugeValue = /gauge\.(.+)\.val/.exec(metric);
if ( matchGaugeValue !== null) {
$scope.gaugeData[0].values.push([ matchGaugeValue[1], application.metrics[metric] ]);
continue;
}
var matchGaugeAvg = /gauge\.(.+)\.avg/.exec(metric);
if ( matchGaugeAvg !== null) {
$scope.gaugeData[1].values.push([ matchGaugeAvg[1], application.metrics[metric] ]);
continue;
}
var matchGaugeMin = /gauge\.(.+)\.min/.exec(metric);
if ( matchGaugeMin !== null) {
$scope.gaugeData[2].values.push([ matchGaugeMin[1], application.metrics[metric] ]);
continue;
}
var matchGaugeMax = /gauge\.(.+)\.max/.exec(metric);
if ( matchGaugeMax !== null) {
$scope.gaugeData[3].values.push([ matchGaugeMax[1], application.metrics[metric] ]);
continue;
}
var matchGaugeCount = /gauge\.(.+)\.count/.exec(metric);
if ( matchGaugeCount !== null) {
$scope.gaugeData[4].values.push([ matchGaugeCount[1], application.metrics[metric] ]);
continue;
}
var matchGaugeAlpha = /gauge\.(.+)\.alpha/.exec(metric);
if ( matchGaugeAlpha !== null) {
continue;
}
var matchGaugeValue = /gauge\.(.+)/.exec(metric);
if ( matchGaugeValue !== null) {
$scope.gaugeData[0].values.push([ matchGaugeValue[1], application.metrics[metric] ]);
}
} }
var matchGauge = /gauge\.(.+)/.exec(metric); //in case no richGauges are present remove empty groups
if ( matchGauge !== null) { var i = $scope.gaugeData.length;
$scope.gaugeData[0].values.push([ matchGauge[1], application.metrics[metric] ]); while (--i) {
if ($scope.gaugeData[i].values.length === 0) {
$scope.gaugeData.splice(i, 1);
} }
} }
}); });
}); });
var colorArray = ['#6db33f', '#a5b2b9', '#34302d' ]; var colorArray = ['#6db33f', '#a5b2b9', '#34302d' , '#fec600' ,'#4e681e' ];
$scope.colorFunction = function() { $scope.colorFunction = function() {
return function(d, i) { return function(d, i) {
return colorArray[i % colorArray.length]; return colorArray[i % colorArray.length];
...@@ -119,7 +168,7 @@ angular.module('springBootAdmin') ...@@ -119,7 +168,7 @@ angular.module('springBootAdmin')
$scope.toolTipContentFunction = function(){ $scope.toolTipContentFunction = function(){
return function(key, x, y, e, graph) { return function(key, x, y, e, graph) {
return e.point[0] + ': ' + e.point[1] ; return '<b>' + key + '</b> ' +e.point[0] + ': ' + e.point[1] ;
} }
} }
......
...@@ -68,13 +68,14 @@ ...@@ -68,13 +68,14 @@
<tr> <tr>
<td> <td>
<h1 style="text-align: center;">Gauge</h1> <h1 style="text-align: center;">Gauge</h1>
<div class="center-block" style="width: 800px; height: {{ 75 + gaugeData[0].values.length * 15 }}px; position:relative;"> <div class="center-block" style="width: 800px; height: {{ 75 + gaugeData[0].values.length * (10 + gaugeData.length *5) }}px; position:relative;">
<nvd3-multi-bar-horizontal-chart id="gaugesChart" nodata="not available" <nvd3-multi-bar-horizontal-chart id="gaugesChart" nodata="not available"
data="gaugeData" data="gaugeData"
color="colorFunction()" color="colorFunction()"
tooltips="true" tooltipContent="toolTipContentFunction()" tooltips="true" tooltipContent="toolTipContentFunction()"
showYAxis="true" yAxisTickFormat="intFormatFunction()" showYAxis="true" yAxisTickFormat="intFormatFunction()"
showXAxis="true" xAxisTickFormat="abbreviateFunction(30, 1, 3)" showXAxis="true" xAxisTickFormat="abbreviateFunction(30, 1, 3)"
showLegend="{{ gaugeData.length > 1 ? 'true' : 'false' }} " legendColor="colorFunction()"
margin="{ top: 25, left: 250, right: 25, bottom: 50}"> margin="{ top: 25, left: 250, right: 25, bottom: 50}">
</nvd3-multi-bar-horizontal-chart> </nvd3-multi-bar-horizontal-chart>
</div> </div>
......
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