[llvm-commits] [LNT] r162142 - in /lnt/trunk/lnt/server/ui: templates/v4_graph.html views.py
Daniel Dunbar
daniel at zuster.org
Fri Aug 17 14:46:45 PDT 2012
Author: ddunbar
Date: Fri Aug 17 16:46:45 2012
New Revision: 162142
URL: http://llvm.org/viewvc/llvm-project?rev=162142&view=rev
Log:
graphs: Add tooltips for data points.
- About time...
Modified:
lnt/trunk/lnt/server/ui/templates/v4_graph.html
lnt/trunk/lnt/server/ui/views.py
Modified: lnt/trunk/lnt/server/ui/templates/v4_graph.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/v4_graph.html?rev=162142&r1=162141&r2=162142&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/v4_graph.html (original)
+++ lnt/trunk/lnt/server/ui/templates/v4_graph.html Fri Aug 17 16:46:45 2012
@@ -28,12 +28,54 @@
{# Add JS to initialize the graph. #}
{% block onload %}init(){% endblock %}
{% block javascript %}
+var g = {}
+
function init() {
var graph = $("#graph");
var graph_plots = {{graph_plots|tojson|safe}};
var graph_options = {{graph_options|tojson|safe}};
$.plot(graph, graph_plots, graph_options);
+
+ // Add tooltips.
+ graph.bind("plothover", function(e,p,i) {
+ update_tooltip(e, p, i, show_tooltip); });
+}
+
+// Show our overlay tooltip.
+g.current_tip_point = null;
+function show_tooltip(x, y, item, pos) {
+ var data = item.datapoint;
+ var tip_body = '<div id="tooltip">';
+ tip_body += "<b>Revision:</b>" + data[0].toFixed(0) + "<br>";
+ tip_body += "<b>Value:</b>" + data[1].toFixed(4) + "s" + "</div>";
+
+ $(tip_body).css( {
+ position: 'absolute',
+ display: 'none',
+ top: y + 5,
+ left: x + 5,
+ border: '1px solid #fdd',
+ padding: '2px',
+ 'background-color': '#fee',
+ opacity: 0.80
+ }).appendTo("body").fadeIn(200);
+}
+
+// Event handler function to update the tooltop.
+function update_tooltip(event, pos, item, show_fn) {
+ if (!item) {
+ $("#tooltip").remove();
+ g.current_tip_point = null;
+ return;
+ }
+
+ if (!g.current_tip_point || (g.current_tip_point[0] != item.datapoint[0] ||
+ g.current_tip_point[1] != item.datapoint[1])) {
+ $("#tooltip").remove();
+ g.current_tip_point = item.datapoint;
+ show_fn(pos.pageX, pos.pageY, item, pos);
+ }
}
{% endblock %}
Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=162142&r1=162141&r2=162142&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Fri Aug 17 16:46:45 2012
@@ -671,7 +671,9 @@
"shadowSize" : 0
},
"zoom" : {"interactive" : True },
- "pan" : { "interactive" : True }
+ "pan" : { "interactive" : True },
+ "grid" : {
+ "hoverable" : True }
}
return render_template("v4_graph.html", ts=ts, run=run,
More information about the llvm-commits
mailing list