From 564633ecbcd8e532d6b156bb9c2ab5921f5bed80 Mon Sep 17 00:00:00 2001 From: Bernerd Schaefer Date: Thu, 11 Apr 2013 18:17:33 +0200 Subject: [PATCH] Render graph labels vertically This helps to make the timeseries with many labels fit on the screen. --- web/static/css/graph.css | 19 ++++++++++++++++++- web/static/js/graph.js | 15 ++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/web/static/css/graph.css b/web/static/css/graph.css index 0e2718cca..2a82fa885 100644 --- a/web/static/css/graph.css +++ b/web/static/css/graph.css @@ -9,7 +9,6 @@ body { .graph { position: relative; min-height: 400px; - overflow-x: hidden; } svg { @@ -22,3 +21,21 @@ svg { vertical-align: top; margin: 0 0 0 0px; } + +.graph .detail .item.active { + line-height: 1.4em; + padding: 0.5em; +} + +.graph .detail .item.active .labels { + font-size: 11px; + line-height: 11px; +} + +.graph .detail .item .detail_swatch { + float: right; + display: inline-block; + width: 10px; + height: 10px; + margin: 2px 2px 0 8px; + } diff --git a/web/static/js/graph.js b/web/static/js/graph.js index 4a6163d85..4ed17dbe7 100644 --- a/web/static/js/graph.js +++ b/web/static/js/graph.js @@ -318,6 +318,7 @@ Prometheus.Graph.prototype.transformData = function(json) { var data = json.Value.map(function(ts) { return { name: self.metricToTsName(ts.Metric), + labels: ts.Metric, data: ts.Values.map(function(value) { return { x: value.Timestamp, @@ -369,7 +370,19 @@ Prometheus.Graph.prototype.updateGraph = function(reloadGraph) { } var hoverDetail = new Rickshaw.Graph.HoverDetail({ - graph: self.rickshawGraph + graph: self.rickshawGraph, + formatter: function(series, x, y) { + var swatch = ''; + var content = swatch + series.labels["name"] + ": " + parseInt(y) + '
'; + var labelStrings = [] + for (label in series.labels) { + if (label != "name") { + labelStrings.push(""+label + ": " + series.labels[label]); + } + } + var labels = "
"+ labelStrings.join("
") + "
"; + return content + labels; + } }); var legend = new Rickshaw.Graph.Legend({