web/data/cubicweb.flot.js
branchstable
changeset 7567 d6366de1d0dc
parent 5658 7b9553a9db65
--- a/web/data/cubicweb.flot.js	Tue Jun 28 11:20:33 2011 +0200
+++ b/web/data/cubicweb.flot.js	Tue Jun 28 13:16:09 2011 +0200
@@ -13,16 +13,25 @@
 
 var previousPoint = null;
 function onPlotHover(event, pos, item) {
+    var $fig = $(event.target);
     if (item) {
         if (previousPoint != item.datapoint) {
             previousPoint = item.datapoint;
             $("#tooltip").remove();
             var x = item.datapoint[0].toFixed(2),
-            y = item.datapoint[1].toFixed(2);
-            if (item.datapoint.length == 3) {
-                x = new Date(item.datapoint[2]);
-                x = x.toLocaleDateString() + ' ' + x.toLocaleTimeString();
+                y = item.datapoint[1].toFixed(2);
+            if ($fig.data('mode') == 'time') {
+                x = new Date(item.datapoint[0]);
+                var dateformat = $fig.data('dateformat');
+                if (dateformat) {
+                    x = x.strftime(dateformat);
+                } else {
+                    x = x.toLocaleDateString() + ' ' + x.toLocaleTimeString();
+                }
             } else if (item.datapoint.length == 4) {
+                // NOTE: this has no chance to work with jquery flot >= 0.6 because
+                // jquery flot normalizes datapoints and only keeps 2 columns. Either
+                // use processRawData hook or use the 'dateformat' option.
                 x = new Date(item.datapoint[2]);
                 x = x.strftime(item.datapoint[3]);
             }