Merge pull request #67 from kberg/master
authorDan Vanderkam <dan@dygraphs.com>
Mon, 27 Jun 2011 20:23:21 +0000 (13:23 -0700)
committerDan Vanderkam <dan@dygraphs.com>
Mon, 27 Jun 2011 20:23:21 +0000 (13:23 -0700)
Test and fix for issue 203

docs/changes.html
dygraph-layout.js
dygraph-options-reference.js
tests/dygraph-many-points-benchmark.html

index 9d7bb90..b12cc26 100644 (file)
@@ -2,7 +2,7 @@
 <html>
   <head>
     <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
-    <title>dygraphs input types</title>
+    <title>Guide to making dygraphs changes</title>
     <style type="text/css">
       code { white-space: pre; border: 1px dashed black; display: inline; }
       pre  { white-space: pre; border: 1px dashed black; }
index 9c70965..99ae50c 100644 (file)
@@ -222,6 +222,13 @@ DygraphLayout.prototype._evaluateAnnotations = function() {
   }
 
   this.annotated_points = [];
+
+  // Exit the function early if there are no annotations.
+  if (!this.annotations || !this.annotations.length) {
+    return;
+  }
+  
+  // TODO(antrob): loop through annotations not points.
   for (var i = 0; i < this.points.length; i++) {
     var p = this.points[i];
     var k = p.xval + "," + p.name;
index 8709ffa..5bc7f63 100644 (file)
@@ -352,12 +352,11 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "description": "Function to call to format values along the x axis."
   },
   "clickCallback": {
-    "snippet": "function(e, date){<br>&nbsp;&nbsp;alert(date);<br>}",
+    "snippet": "function(e, date_millis){<br>&nbsp;&nbsp;alert(new Date(date_millis));<br>}",
     "default": "null",
     "labels": ["Callbacks"],
-    "type": "function(e, date, points)",
-    // NOTE(konigsberg): Is this description correct?
-    "description": "A function to call when the canvas is clicked. The function should take three arguments, the event object for the click, the date that was clicked, and the closest points along that date. The points have these properties:\n * xval/yval: The data coordinates of the point (with dates/times as millis since epoch) \n * canvasx/canvasy: The canvas coordinates at which the point is drawn. \n name: The name of the data series to which the point belongs"
+    "type": "function(e, x, points)",
+    "description": "A function to call when the canvas is clicked. The function should take three arguments, the event object for the click, the x-value that was clicked (for dates this is millis since epoch), and the closest points along that date. The points have these properties:\n * xval/yval: The data coordinates of the point (with dates/times as millis since epoch) \n * canvasx/canvasy: The canvas coordinates at which the point is drawn. \n name: The name of the data series to which the point belongs"
   },
   "yAxisLabelFormatter": {
     "default": "yValueFormatter",
index 2919706..b4f7471 100644 (file)
           document.getElementById('message').innerHTML =
               "completed in " + (end - start) + " milliseconds.";
         } else {
+          var avg = 0;
+          for (var i = 0; i < millisecondss.length; i++) {
+            avg+=millisecondss[i];
+          }
+          avg/=millisecondss.length; 
           document.getElementById('message').innerHTML =
-              "Durations: " + millisecondss;
+              "Durations: " + millisecondss + " Average: " + avg;
         }
 
         if (durations.length > 0) {