mirror of
https://github.com/ansible/awx.git
synced 2026-02-27 15:58:45 -03:30
Use responsive helper in host count graph
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
angular.module('DashboardGraphs').
|
angular.module('DashboardGraphs').
|
||||||
directive('hostCountGraph', ['GetBasePath', 'Rest', function(getBasePath, Rest) {
|
directive('hostCountGraph', ['GetBasePath', 'Rest', 'adjustGraphSize', '$window', function(getBasePath, Rest, adjustGraphSize, $window) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
@@ -12,19 +12,8 @@ angular.module('DashboardGraphs').
|
|||||||
|
|
||||||
url = getBasePath('config');
|
url = getBasePath('config');
|
||||||
|
|
||||||
if (scope.removeResizeHostGraph) {
|
$window.addEventListener('resize', function() {
|
||||||
scope.removeResizeHostGraph();
|
adjustGraphSize(license_graph, element);
|
||||||
}
|
|
||||||
scope.removeResizeHostGraph= scope.$on('ResizeHostGraph', function () {
|
|
||||||
if($(window).width()<500){
|
|
||||||
$('.graph-container').height(300);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
var winHeight = $(window).height(),
|
|
||||||
available_height = winHeight - $('#main-menu-container .navbar').outerHeight() - $('#count-container').outerHeight() - 120;
|
|
||||||
$('.graph-container').height(available_height/2);
|
|
||||||
license_graph.update();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
@@ -96,53 +85,52 @@ angular.module('DashboardGraphs').
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
nv.addGraph({
|
var width = $('.graph-container').width(), // nv.utils.windowSize().width/3,
|
||||||
generate: function() {
|
height = $('.graph-container').height()*0.6; //nv.utils.windowSize().height/5,
|
||||||
var width = $('.graph-container').width(), // nv.utils.windowSize().width/3,
|
license_graph = nv.models.lineChart()
|
||||||
height = $('.graph-container').height()*0.6; //nv.utils.windowSize().height/5,
|
.margin({top: 15, right: 75, bottom: 40, left: 85})
|
||||||
license_graph = nv.models.lineChart()
|
.x(function(d,i) { return i ;})
|
||||||
.margin({top: 15, right: 75, bottom: 40, left: 85})
|
.useInteractiveGuideline(true) //We want nice looking tooltips and a guideline!
|
||||||
.x(function(d,i) { return i ;})
|
.transitionDuration(350) //how fast do you want the lines to transition?
|
||||||
.useInteractiveGuideline(true) //We want nice looking tooltips and a guideline!
|
.showLegend(true) //Show the legend, allowing users to turn on/off line series.
|
||||||
.transitionDuration(350) //how fast do you want the lines to transition?
|
.showYAxis(true) //Show the y-axis
|
||||||
.showLegend(true) //Show the legend, allowing users to turn on/off line series.
|
.showXAxis(true) //Show the x-axis
|
||||||
.showYAxis(true) //Show the y-axis
|
;
|
||||||
.showXAxis(true) //Show the x-axis
|
|
||||||
;
|
|
||||||
|
|
||||||
license_graph.xAxis
|
license_graph.xAxis
|
||||||
.axisLabel("Time")
|
.axisLabel("Time")
|
||||||
.tickFormat(function(d) {
|
.tickFormat(function(d) {
|
||||||
var dx = graphData[0].values[d] && graphData[0].values[d].x || 0;
|
var dx = graphData[0].values[d] && graphData[0].values[d].x || 0;
|
||||||
return dx ? d3.time.format('%m/%d')(new Date(Number(dx+'000'))) : '';
|
return dx ? d3.time.format('%m/%d')(new Date(Number(dx+'000'))) : '';
|
||||||
});
|
|
||||||
|
|
||||||
license_graph.yAxis //Chart y-axis settings
|
|
||||||
.axisLabel('Hosts')
|
|
||||||
.tickFormat(d3.format('.f'));
|
|
||||||
|
|
||||||
d3.select(element.find('svg')[0])
|
|
||||||
.datum(graphData).transition()
|
|
||||||
.attr('width', width)
|
|
||||||
.attr('height', height)
|
|
||||||
.duration(500)
|
|
||||||
.call(license_graph)
|
|
||||||
.style({
|
|
||||||
// 'width': width,
|
|
||||||
// 'height': height,
|
|
||||||
"font-family": 'Open Sans',
|
|
||||||
"font-style": "normal",
|
|
||||||
"font-weight":400,
|
|
||||||
"src": "url(/static/fonts/OpenSans-Regular.ttf)"
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// nv.utils.windowResize(license_graph.update);
|
|
||||||
scope.$emit('WidgetLoaded');
|
|
||||||
return license_graph;
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
license_graph.yAxis //Chart y-axis settings
|
||||||
|
.axisLabel('Hosts')
|
||||||
|
.tickFormat(d3.format('.f'));
|
||||||
|
|
||||||
|
d3.select(element.find('svg')[0])
|
||||||
|
.datum(graphData).transition()
|
||||||
|
.attr('width', width)
|
||||||
|
.attr('height', height)
|
||||||
|
.duration(500)
|
||||||
|
.call(license_graph)
|
||||||
|
.style({
|
||||||
|
// 'width': width,
|
||||||
|
// 'height': height,
|
||||||
|
"font-family": 'Open Sans',
|
||||||
|
"font-style": "normal",
|
||||||
|
"font-weight":400,
|
||||||
|
"src": "url(/static/fonts/OpenSans-Regular.ttf)"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// nv.utils.windowResize(license_graph.update);
|
||||||
|
scope.$emit('WidgetLoaded');
|
||||||
|
|
||||||
|
adjustGraphSize(license_graph, element);
|
||||||
|
|
||||||
|
return license_graph;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
Reference in New Issue
Block a user