[llvm-commits] [LNT] r162141 - in /lnt/trunk/lnt/server/ui: templates/v4_graph.html views.py

Daniel Dunbar daniel at zuster.org
Fri Aug 17 14:46:42 PDT 2012


Author: ddunbar
Date: Fri Aug 17 16:46:42 2012
New Revision: 162141

URL: http://llvm.org/viewvc/llvm-project?rev=162141&view=rev
Log:
Switch over to using Flot for graphs.

 - Life is too short to maintain our own ad hoc, informally-specified,
   bug-ridden, slow graph implementation. Ok, actually View2D's performance
   kills Flot, but Flot has a lot of features we would like to start taking
   advantage of.

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=162141&r1=162140&r2=162141&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:42 2012
@@ -7,9 +7,20 @@
 {% set components = [(ts.name, v4_url_for("v4_overview")),
                      ('machine', v4_url_for("v4_machine", id=machine.id))] %}
 {% block head %}
-        <script src="{{ url_for('.static', filename='popup.js') }}"></script>
-        <script src="{{ url_for('.static', filename='sorttable.js') }}"></script>
-        <script src="{{ url_for('.static', filename='View2D.js') }}"></script>
+  <script src="{{ url_for('.static', filename='popup.js') }}"></script>
+  <script src="{{ url_for('.static', filename='sorttable.js') }}"></script>
+  <script language="javascript" type="text/javascript"
+          src="{{ url_for('.static',
+                          filename='jquery/1.5/jquery.min.js') }}"> </script>
+  <script language="javascript" type="text/javascript"
+          src="{{ url_for('.static',
+                          filename='flot/jquery.flot.min.js') }}"> </script>
+  <script language="javascript" type="text/javascript"
+          src="{{ url_for('.static',
+                          filename='flot/jquery.flot.navigate.min.js') }}"> </script>
+  <script language="javascript" type="text/javascript"
+          src="{{ url_for('.static',
+                          filename='flot/jquery.flot.errorbars.js') }}"> </script>
 {% endblock %}
 
 {% block title %}Graph{% endblock %}
@@ -18,20 +29,11 @@
 {% block onload %}init(){% endblock %}
 {% block javascript %}
 function init() {
-    graph = new Graph2D("graph");
-    graph.clearColor = [1, 1, 1];
+  var graph = $("#graph");
 
-{% for plot in graph_plots %}
-    {{ plot }}
-{% endfor %}
-
-{% if use_day_axis %}
-    graph.xAxis.format = graph.xAxis.formats.day;
-{% else %}
-    graph.xAxis.format = graph.xAxis.formats.normal;
-{% endif %}
-
-    graph.draw();
+  var graph_plots = {{graph_plots|tojson|safe}};
+  var graph_options = {{graph_options|tojson|safe}};
+  $.plot(graph, graph_plots, graph_options);
 }
 {% endblock %}
 
@@ -103,7 +105,7 @@
 <table>
 <tr>
 <td rowspan=2 valign="top">
-  <canvas id="graph" width="600" height="400"></canvas>
+  <div id="graph" style="margin:0px;width:600px;height:400px;"></div>
 </td>
 <td valign="top">
 <table cellspacing=4 border=1>
@@ -120,9 +122,9 @@
 </td></tr>
 <tr><td align="right" valign="bottom">
 <font size="-2">
-Shift-Left Mouse: Pan<br>
-Alt/Meta-Left Mouse: Zoom<br>
-Wheel: Zoom (<i>Shift Slows</i>)<br>
+Left Mouse: Pan<br>
+Double Left Mouse: Zoom<br>
+Wheel: Zoom<br>
 </font>
 </td></tr>
 </table>

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=162141&r1=162140&r2=162141&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Fri Aug 17 16:46:42 2012
@@ -540,13 +540,13 @@
             if show_stddev:
                 mean = stats.mean(values)
                 sigma = stats.standard_deviation(values)
-                errorbar_data.append((x, mean - sigma, mean + sigma))
+                errorbar_data.append((x, mean, sigma))
 
             # Add the MAD error bar, if requested.
             if show_mad:
                 med = stats.median(values)
                 mad = stats.median_absolute_deviation(values, med)
-                errorbar_data.append((x, med - mad, med + mad))
+                errorbar_data.append((x, med, mad))
         
         # Compute the moving average and or moving median of our data if requested.
         if moving_average or moving_median:
@@ -578,10 +578,9 @@
         # Add the minimum line plot, if requested.
         if show_lineplot:
             num_points += len(data)        
-            graph_plots.append("graph.addPlot([%s], %s);" % (
-                    ','.join(['[%.4f,%.4f]' % (t,v)
-                              for t,v in pts]),
-                    "new Graph2D_LinePlotStyle(1, %r)" % col))
+            graph_plots.append({
+                    "data" : pts,
+                    "color" : util.toColorString(col) })
 
         # Add regression line, if requested.
         if show_linear_regression:
@@ -606,63 +605,81 @@
             if info is not None:
                 slope, intercept,_,_,_ = info
 
-                reglin_col = [c*.5 for c in col]
-                pts = ','.join('[%.4f,%.4f]' % pt
-                               for pt in [(x_min, 0.0 * slope + intercept),
-                                          (x_max, 1.0 * slope + intercept)])
-                style = "new Graph2D_LinePlotStyle(4, %r)" % ([.7, .7, .7],)
-                graph_plots.append("graph.addPlot([%s], %s);" % (
-                        pts,style))
-                style = "new Graph2D_LinePlotStyle(2, %r)" % (reglin_col,)
-                graph_plots.append("graph.addPlot([%s], %s);" % (
-                        pts,style))
+                reglin_col = [c * .7 for c in col]
+                reglin_pts = [(x_min, 0.0 * slope + intercept),
+                              (x_max, 1.0 * slope + intercept)]
+                graph_plots.insert(0, {
+                        "data" : reglin_pts,
+                        "color" : util.toColorString(reglin_col),
+                        "lines" : {
+                            "lineWidth" : 2 },
+                        "shadowSize" : 4 })
 
         # If we are comparing two revisions,
         if compare_to and show_highlight:
             reg_col = [0.0, 0.0, 1.0]
-            graph_plots.append("graph.addPlot([%i, %i],%s);" % (
-                    revision_range_region[0], revision_range_region[1],
-                    "new Graph2D_RangePlotStyle(%r)" % reg_col))
+            graph_plots.insert(0, {
+                    "data" : revision_range_region,
+                    "color" : util.toColorString(reg_col) })
 
         # Add the points plot, if used.
         if points_data:
             pts_col = (0,0,0)
-            graph_plots.append("graph.addPlot([%s], %s);" % (
-                ','.join(['[%.4f,%.4f]' % (t,v)
-                            for t,v in points_data]),
-                "new Graph2D_PointPlotStyle(1, %r)" % (pts_col,)))
+            graph_plots.append({
+                    "data" : points_data,
+                    "color" : util.toColorString(pts_col),
+                    "lines" : {
+                        "show" : False },
+                    "points" : {
+                        "show" : True,
+                        "radius" : .25,
+                        "fill" : True } })
 
         # Add the error bar plot, if used.
         if errorbar_data:
             bar_col = [c*.7 for c in col]
-            graph_plots.append("graph.addPlot([%s], %s);" % (
-                ','.join(['[%.4f,%.4f,%.4f]' % (x,y_min,y_max)
-                          for x,y_min,y_max in errorbar_data]),
-                "new Graph2D_ErrorBarPlotStyle(1, %r)" % (bar_col,)))
+            graph_plots.append({
+                    "data" : errorbar_data,
+                    "lines" : { "show" : False },
+                    "color" : util.toColorString(bar_col),
+                    "points" : {
+                        "errorbars" : "y",
+                        "yerr" : { "show" : True,
+                                   "lowerCap" : "-",
+                                   "upperCap" : "-",
+                                   "lineWidth" : 1 } } })
         
         # Add the moving average plot, if used.
         if moving_average_data:
             col = [0.32, 0.6, 0.0]
-            graph_plots.append("graph.addPlot([%s], %s);" % (
-                    ','.join(['[%.4f,%.4f]' % (t,v)
-                              for t,v in moving_average_data]),
-                    "new Graph2D_LinePlotStyle(1, %r)" % (col,)))
+            graph_plots.append({
+                    "data" : moving_average_data,
+                    "color" : util.toColorString(col) })
 
         
         # Add the moving median plot, if used.
         if moving_median_data:
             col = [0.75, 0.0, 1.0]
-            graph_plots.append("graph.addPlot([%s], %s);" % (
-                    ','.join(['[%.4f,%.4f]' % (t,v)
-                              for t,v in moving_median_data]),
-                    "new Graph2D_LinePlotStyle(1, %r)" % (col,)))            
+            graph_plots.append({
+                    "data" : moving_median_data,
+                    "color" : util.toColorString(col) })
+
+    graph_options = {
+        "series" : {
+            "lines" : {
+                "lineWidth" : 1 },
+            "shadowSize" : 0
+            },
+        "zoom" : {"interactive" : True },
+        "pan" : { "interactive" : True }
+        }
 
     return render_template("v4_graph.html", ts=ts, run=run,
                            compare_to=compare_to, options=options,
                            num_plots=num_plots, num_points=num_points,
                            neighboring_runs=neighboring_runs,
-                           graph_plots=graph_plots, legend=legend,
-                           use_day_axis=use_day_axis)
+                           graph_plots=graph_plots, graph_options=graph_options,
+                           legend=legend, use_day_axis=use_day_axis)
 
 @v4_route("/daily_report")
 def v4_daily_report_overview():





More information about the llvm-commits mailing list