From f42adc1cc0c67bfa59244ef6b00fcd8794c522bc Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Mon, 1 Jul 2013 14:47:43 +0200 Subject: [PATCH] Display Y-axis outside of graph. --- web/static/css/graph.css | 23 +++++++++++++++++++---- web/static/js/graph.js | 8 ++++++-- web/static/js/graph_template.handlebar | 5 ++++- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/web/static/css/graph.css b/web/static/css/graph.css index ca9eda1ef..97d5601df 100644 --- a/web/static/css/graph.css +++ b/web/static/css/graph.css @@ -16,18 +16,33 @@ a:active { color: black; } .graph { position: relative; + left: 40px; min-height: 400px; } -svg { - border: 1px solid #aaa; - margin-bottom: 5px; +.graph svg { + border-top: 1px solid #aaa; + border-right: 1px solid #aaa; + border-bottom: 1px solid #aaa; } .legend { display: inline-block; vertical-align: top; - margin: 0 0 0 0px; + margin: 0 0 0 40px; +} + +.graph_area { + position: relative; + font-family: Arial, Helvetica, sans-serif; + margin: 5px 0 5px 0; +} + +.y_axis { + position: absolute; + top: 1px; + bottom: 0; + width: 40px; } .graph .detail .x_label.flipped { diff --git a/web/static/js/graph.js b/web/static/js/graph.js index 7aa612508..0bc08584f 100644 --- a/web/static/js/graph.js +++ b/web/static/js/graph.js @@ -100,6 +100,7 @@ Prometheus.Graph.prototype.initialize = function() { }) self.graph = graphWrapper.find(".graph"); + self.yAxis = graphWrapper.find(".y_axis"); self.legend = graphWrapper.find(".legend"); self.spinner = graphWrapper.find(".spinner"); self.evalStats = graphWrapper.find(".eval_stats"); @@ -400,7 +401,7 @@ Prometheus.Graph.prototype.showGraph = function() { self.rickshawGraph = new Rickshaw.Graph({ element: self.graph[0], height: Math.max(self.graph.innerHeight(), 100), - width: Math.max(self.graph.innerWidth(), 200), + width: Math.max(self.graph.innerWidth() - 80, 200), renderer: (self.stacked.is(":checked") ? "stack" : "line"), interpolation: "linear", series: self.data, @@ -411,7 +412,9 @@ Prometheus.Graph.prototype.showGraph = function() { var yAxis = new Rickshaw.Graph.Axis.Y({ graph: self.rickshawGraph, + orientation: "left", tickFormat: Rickshaw.Fixtures.Number.formatKMBT, + element: self.yAxis[0], }); self.rickshawGraph.render(); @@ -422,6 +425,7 @@ Prometheus.Graph.prototype.updateGraph = function(reloadGraph) { if (self.data.length == 0) { return; } self.legend.empty(); if (self.rickshawGraph == null || reloadGraph) { + self.yAxis.empty(); self.graph.empty(); self.showGraph(); } else { @@ -483,7 +487,7 @@ Prometheus.Graph.prototype.updateGraph = function(reloadGraph) { Prometheus.Graph.prototype.resizeGraph = function() { var self = this; self.rickshawGraph.configure({ - width: Math.max(self.graph.innerWidth(), 200), + width: Math.max(self.graph.innerWidth() - 80, 200), }); self.rickshawGraph.render(); } diff --git a/web/static/js/graph_template.handlebar b/web/static/js/graph_template.handlebar index 5a7b1f064..cff9b7cfb 100644 --- a/web/static/js/graph_template.handlebar +++ b/web/static/js/graph_template.handlebar @@ -48,7 +48,10 @@ -
+
+
+
+