Flip hover detail to prevent going off the screen

This commit is contained in:
Bernerd Schaefer 2013-04-12 10:39:37 +02:00
parent 8c9597cb39
commit 461e02d2b8
2 changed files with 24 additions and 1 deletions

View file

@ -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;

View file

@ -377,7 +377,19 @@ Prometheus.Graph.prototype.updateGraph = function(reloadGraph) {
var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
var content = swatch + series.labels["name"] + ": <strong>" + y + '</strong><br>';
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({