mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Update labels on hover for realtime dashboard graph
This commit is contained in:
parent
1c46ce11f5
commit
f0f996c6d1
3 changed files with 59 additions and 5 deletions
|
@ -43,10 +43,43 @@ var realtimeGraph = function(updatePath) {
|
||||||
|
|
||||||
graph.render();
|
graph.render();
|
||||||
|
|
||||||
var hoverDetail = new Rickshaw.Graph.HoverDetail({
|
var legend = document.querySelector('#realtime-legend');
|
||||||
graph: graph,
|
var Hover = Rickshaw.Class.create(Rickshaw.Graph.HoverDetail, {
|
||||||
yFormatter: function(y) { return Math.floor(y) }
|
render: function(args) {
|
||||||
|
legend.innerHTML = args.formattedXValue;
|
||||||
|
|
||||||
|
args.detail.sort(function(a, b) { return a.order - b.order }).forEach( function(d) {
|
||||||
|
var line = document.createElement('div');
|
||||||
|
line.className = 'line';
|
||||||
|
|
||||||
|
var swatch = document.createElement('div');
|
||||||
|
swatch.className = 'swatch';
|
||||||
|
swatch.style.backgroundColor = d.series.color;
|
||||||
|
|
||||||
|
var label = document.createElement('div');
|
||||||
|
label.className = 'tag';
|
||||||
|
label.innerHTML = d.name + ": " + Math.floor(d.formattedYValue);
|
||||||
|
|
||||||
|
line.appendChild(swatch);
|
||||||
|
line.appendChild(label);
|
||||||
|
|
||||||
|
legend.appendChild(line);
|
||||||
|
|
||||||
|
var dot = document.createElement('div');
|
||||||
|
dot.className = 'dot';
|
||||||
|
dot.style.top = graph.y(d.value.y0 + d.value.y) + 'px';
|
||||||
|
dot.style.borderColor = d.series.color;
|
||||||
|
|
||||||
|
this.element.appendChild(dot);
|
||||||
|
|
||||||
|
dot.className = 'dot active';
|
||||||
|
|
||||||
|
this.show();
|
||||||
|
|
||||||
|
}, this );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
var hover = new Hover( { graph: graph } );
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
poller = setInterval(function() {
|
poller = setInterval(function() {
|
||||||
|
|
|
@ -394,6 +394,27 @@ div.interval-slider input {
|
||||||
width: 160px;
|
width: 160px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#realtime-legend {
|
||||||
|
width: 440px;
|
||||||
|
text-align: left;
|
||||||
|
margin-top: 5px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
#realtime-legend .tag {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
#realtime-legend .line {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 0 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 790px) {
|
||||||
|
#realtime-legend {
|
||||||
|
float: none;
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Beacon
|
/* Beacon
|
||||||
********************************** */
|
********************************** */
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h5></h5>
|
|
||||||
<div id="realtime"></div>
|
<div id="realtime"></div>
|
||||||
|
<div id="realtime-legend"></div>
|
||||||
|
|
||||||
<h5>
|
<h5>
|
||||||
<span class="history-heading"><%= t('History') %></span>
|
<span class="history-heading"><%= t('History') %></span>
|
||||||
|
|
Loading…
Add table
Reference in a new issue