From 461e02d2b8cc227200c5b35ea0fa741263ffa2e0 Mon Sep 17 00:00:00 2001 From: Bernerd Schaefer Date: Fri, 12 Apr 2013 10:39:37 +0200 Subject: [PATCH] Flip hover detail to prevent going off the screen --- web/static/css/graph.css | 11 +++++++++++ web/static/js/graph.js | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/web/static/css/graph.css b/web/static/css/graph.css index 32840e5a3..062036409 100644 --- a/web/static/css/graph.css +++ b/web/static/css/graph.css @@ -22,6 +22,17 @@ svg { margin: 0 0 0 0px; } +.graph .detail .item.flipped { + right: 10px; +} + +.graph .detail .item.flipped:before { + content: "\25b8"; + left: auto; + right: 1px; + font-size: 0.8em; +} + .graph .detail .item.active { line-height: 1.4em; padding: 0.5em; diff --git a/web/static/js/graph.js b/web/static/js/graph.js index 7921ab7eb..a921bd00c 100644 --- a/web/static/js/graph.js +++ b/web/static/js/graph.js @@ -377,7 +377,19 @@ Prometheus.Graph.prototype.updateGraph = function(reloadGraph) { var swatch = ''; var content = swatch + series.labels["name"] + ": " + y + '
'; return content + self.renderLabels(series.labels); - } + }, + onRender: function() { + var width = this.graph.width; + var element = jQuery(this.element); + + jQuery(".item", element).each(function() { + if ($(this).outerWidth() + element.offset().left > width) { + $(this).addClass("flipped") + } else { + $(this).removeClass("flipped") + } + }) + }, }); var legend = new Rickshaw.Graph.Legend({