[DRE-commits] [SCM] Tracking the Debian/Ruby wheezy transition branch, master, updated. 530cdac22c28bac03bcedb229247ff48206fa680

Antonio Terceiro terceiro at softwarelivre.org
Wed Apr 6 19:06:18 UTC 2011


The following commit has been merged in the master branch:
commit 43816aa405023369b90e5a85a1f39b24b8f141bc
Author: Antonio Terceiro <terceiro at softwarelivre.org>
Date:   Wed Apr 6 11:37:41 2011 -0700

    Display Y value for each point as tooltip

diff --git a/progressbar.js b/progressbar.js
index 0de484f..89578b9 100644
--- a/progressbar.js
+++ b/progressbar.js
@@ -21,9 +21,6 @@ $(function() {
       return year + "/" + month + "/" + day;
     }
 
-    initial_date_label = to_date_string(initial_date);
-    final_date_label = to_date_string(final_date);
-
     $.plot(
       $('#progress'),
       [
@@ -32,9 +29,46 @@ $(function() {
       ],
       {
         series: { points: { show: true }, lines: { show: true } },
-        xaxis: { ticks: [[initial_date, initial_date_label], [final_date, final_date_label]] }
+        grid: { hoverable: true },
+        xaxis: {
+          min: initial_date,
+          max: final_date + 1, // always leave some empty space in the chart
+          ticks: [[initial_date, to_date_string(initial_date)], [final_date, to_date_string(final_date)]]
+        }
       }
     );
 
+    // based on http://people.iola.dk/olau/flot/examples/interacting.html
+    function showTooltip(x, y, contents) {
+      $('<div id="tooltip">' + contents + '</div>').css( {
+        position: 'absolute',
+        display: 'none',
+        top: y - 30,
+        left: x + 10,
+        border: '1px solid #c4a000',
+        padding: '2px',
+        'background-color': '#fce94f',
+        opacity: 0.80
+      }).appendTo("body").fadeIn(200);
+    }
+
+    var previousPoint = null;
+    $("#progress").bind("plothover", function (event, pos, item) {
+      if (item) {
+        if (previousPoint != item.dataIndex) {
+          previousPoint = item.dataIndex;
+
+          $("#tooltip").remove();
+          var y = item.datapoint[1];
+          showTooltip(item.pageX, item.pageY, y)
+        }
+      }
+      else {
+        $("#tooltip").remove();
+        previousPoint = null;
+      }
+    });
+
+
   });
 });

-- 
Tracking the Debian/Ruby wheezy transition



More information about the Pkg-ruby-extras-commits mailing list