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({