Skip to content
Snippets Groups Projects
Commit d172cfe6 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #8887: some improvements, and added total and used capacity

parent 1b1b27f6
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,9 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc ...@@ -27,7 +27,9 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc
}, },
plotOptions: { plotOptions: {
line: { line: {
stacking: '' stacking: '',
lineWidth: 0,
marker:{enabled:false}
}, },
area: { area: {
stacking: 'normal', stacking: 'normal',
...@@ -67,10 +69,13 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc ...@@ -67,10 +69,13 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc
function updateChartData() { function updateChartData() {
var resourceUsagesDict = $scope.dataService.resourceUsagesDict; var resourceUsagesDict = $scope.dataService.resourceUsagesDict;
var numResources = $scope.dataService.resources.length; var numResources = $scope.dataService.resources.length;
if(numResources > 0) {
var resource = $scope.dataService.selected_resource; var resource = $scope.dataService.selected_resource;
if(resource) {
if(!resource || numResources == 0) {
$scope.chartSeries.splice(0, $scope.chartSeries.length);
$scope.chartConfig.title.text = "No resource selected";
return;
}
//set title to resource name //set title to resource name
$scope.chartConfig.title.text = resource.name; $scope.chartConfig.title.text = resource.name;
...@@ -137,18 +142,17 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc ...@@ -137,18 +142,17 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc
var series = $scope.chartSeries.find(function(series) {return series.name == status}); var series = $scope.chartSeries.find(function(series) {return series.name == status});
if(series) { if(!series) {
series.data = usage_data; series = {name: status, type: 'area', step: true, lineWidth:0, marker:{enabled:false} };
$scope.chartSeries.push(series);
} }
else {
var color = '#bfbfbf'; series.data = usage_data;
switch(status) { switch(status) {
case 'claimed': color = '#ffa64d'; break; case 'claimed': series.color = '#ffa64d'; break;
case 'conflict': color = '#ff0000'; break; case 'conflict': series.color = '#ff0000'; break;
case 'allocated': color = '#66ff66'; break; case 'allocated': series.color = '#66ff66'; break;
}
series = {name: status, type: 'area', step: true, color: color, data: usage_data };
$scope.chartSeries.push(series);
} }
} }
...@@ -165,7 +169,7 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc ...@@ -165,7 +169,7 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc
//plot horizontal line for resource used capacity //plot horizontal line for resource used capacity
var used_cap_series = $scope.chartSeries.find(function(series) {return series.name == 'used capacity'}); var used_cap_series = $scope.chartSeries.find(function(series) {return series.name == 'used capacity'});
if(!used_cap_series) { if(!used_cap_series) {
used_cap_series = {name: 'used capacity', type: 'line', color: '#ff9966', lineWidth:3, marker:{enabled:false}}; used_cap_series = {name: 'used capacity', type: 'line', color: '#ff9966', lineWidth:3, marker:{enabled:false}, dashStyle:'Dash'};
$scope.chartSeries.push(used_cap_series); $scope.chartSeries.push(used_cap_series);
} }
var used_capacity = resource.total_capacity - resource.available_capacity; var used_capacity = resource.total_capacity - resource.available_capacity;
...@@ -180,8 +184,6 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc ...@@ -180,8 +184,6 @@ chartResourceUsageControllerMod.controller('ChartResourceUsageController', ['$sc
$scope.chartSeries.splice(i, 1); $scope.chartSeries.splice(i, 1);
} }
} }
}
}
}; };
$scope.$watch('dataService.selected_resource', updateChartData); $scope.$watch('dataService.selected_resource', updateChartData);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment