fix some tests & gallery entries
authorDan Vanderkam <danvdk@gmail.com>
Sat, 24 Oct 2015 17:41:00 +0000 (13:41 -0400)
committerDan Vanderkam <danvdk@gmail.com>
Sun, 25 Oct 2015 02:44:38 +0000 (22:44 -0400)
15 files changed:
gallery/drawing.js
gallery/edge-padding.js
gallery/independent-series.js
gallery/index.html
gallery/interaction-api.js
gallery/interaction.js
gallery/per-series.js
scripts/build-tests.sh
scripts/watch.sh [changed mode: 0644->0755]
src/dygraph.js
src/extras/rebase.js
src/extras/shapes.js
tests/drawing.html
tests/hairlines.html
tests/logscale.html

index c664650..d4da18d 100644 (file)
@@ -174,13 +174,19 @@ Gallery.register(
                 g.updateOptions({
                   dateWindow: dateWindow
                 });
-                Dygraph.cancelEvent(event);
+                event.preventDefault();
               }
             },
             strokeWidth: 1.5,
             gridLineColor: 'rgb(196, 196, 196)',
-            drawYGrid: false,
-            drawYAxis: false
+            axes: {
+              x: {
+                drawAxis: false
+              },
+              y: {
+                drawGrid: false
+              }
+            }
           });
           window.onmouseup = finishDraw;
       }
index b60e37c..be79054 100644 (file)
@@ -39,7 +39,7 @@ Gallery.register(
 
           var g = new Dygraph(gdiv, data, {
               labels: ['x', 'A', 'B'],
-              labelDivWidth: 100,
+              labelsDivWidth: 100,
               gridLineColor: '#ccc',
               includeZero: true,
               width: 250,
index 59da519..1a1e902 100644 (file)
@@ -155,7 +155,6 @@ Gallery.register(
       '8,8,   \n' +
       '10,10, \n',
       {
-        labels: ['x', 'A', 'B' ],
         connectSeparatedPoints: true,
         drawPoints: true
       }
index ddfe5ba..c953deb 100644 (file)
@@ -4,7 +4,7 @@
     <title>Dygraphs Gallery</title>
 
     <script src="../dist/dygraph.js"></script>
-    <script src="../extras/synchronizer.js"></script>
+    <script src="../src/extras/synchronizer.js"></script>
 
     <script src="lib/jquery-1.4.2.js"></script>
     <script src="../common/textarea.js"></script>
index ebdfce9..8f6d706 100644 (file)
@@ -84,7 +84,7 @@ var lastClickedGraph = null;
 
 function clickV3(event, g, context) {
   lastClickedGraph = g;
-  Dygraph.cancelEvent(event);
+  event.preventDefault();;
 }
 
 function scrollV3(event, g, context) {
@@ -106,7 +106,7 @@ function scrollV3(event, g, context) {
   var yPct = percentages[1];
 
   zoom(g, percentage, xPct, yPct);
-  Dygraph.cancelEvent(event);
+  event.preventDefault();
 }
 
 // Adjusts [x, y] toward each other by zoomInPercentage%
index 5936189..a903737 100644 (file)
@@ -50,9 +50,8 @@ Gallery.register(
     },
     run: function() {
       var lastClickedGraph;
-      // TODO(konigsberg): Add cleanup to remove callbacks.
-      Dygraph.addEvent(document, "mousewheel", function() { lastClickedGraph = null; });
-      Dygraph.addEvent(document, "click", function() { lastClickedGraph = null; });
+      document.addEventListener("mousewheel", function() { lastClickedGraph = null; });
+      document.addEventListener("click", function() { lastClickedGraph = null; });
       new Dygraph(document.getElementById("div_g"),
            NoisyData, { errorBars : true });
       new Dygraph(document.getElementById("div_g2"),
@@ -85,5 +84,9 @@ Gallery.register(
              },
              underlayCallback : captureCanvas
           });
+    },
+    clean: function() {
+      document.removeEventListener('mousewheel');
+      document.removeEventListener('click');
     }
   });
index 956cfc3..425043c 100644 (file)
@@ -25,20 +25,22 @@ Gallery.register(
               },
               {
                 strokeWidth: 2,
-                'parabola': {
-                  strokeWidth: 0.0,
-                  drawPoints: true,
-                  pointSize: 4,
-                  highlightCircleSize: 6
-                },
-                'line': {
-                  strokeWidth: 1.0,
-                  drawPoints: true,
-                  pointSize: 1.5
-                },
-                'sine wave': {
-                  strokeWidth: 3,
-                  highlightCircleSize: 10
+                series: {
+                  'parabola': {
+                    strokeWidth: 0.0,
+                    drawPoints: true,
+                    pointSize: 4,
+                    highlightCircleSize: 6
+                  },
+                  'line': {
+                    strokeWidth: 1.0,
+                    drawPoints: true,
+                    pointSize: 1.5
+                  },
+                  'sine wave': {
+                    strokeWidth: 3,
+                    highlightCircleSize: 10
+                  }
                 }
               }
           );
index 0fc2e9b..216296d 100755 (executable)
@@ -9,6 +9,4 @@ browserify \
   -t [ envify --NODE_ENV development ] \
   --debug \
   -o dist/tests.js \
-  auto_tests/tests/utils_test.js
-
-#  auto_tests/tests/*.js
+  auto_tests/tests/*.js
old mode 100644 (file)
new mode 100755 (executable)
index 1060aab..cb8639f 100644 (file)
@@ -3551,6 +3551,35 @@ Dygraph.PLUGINS = [
   GridPlugin
 ];
 
+// There are many symbols which have historically been available through the
+// Dygraph class. These are exported here for backwards compatibility.
 Dygraph.GVizChart = GVizChart;
+Dygraph.DASHED_LINE = utils.DASHED_LINE;
+Dygraph.DOT_DASH_LINE = utils.DOT_DASH_LINE;
+Dygraph.dateAxisLabelFormatter = utils.dateAxisLabelFormatter;
+Dygraph.toRGB_ = utils.toRGB_;
+Dygraph.findPos = utils.findPos;
+Dygraph.pageX = utils.pageX;
+Dygraph.pageY = utils.pageY;
+Dygraph.dateString_ = utils.dateString_;
+Dygraph.defaultInteractionModel = DygraphInteraction.defaultModel;
+Dygraph.nonInteractiveModel = Dygraph.nonInteractiveModel_ = DygraphInteraction.nonInteractiveModel_;
+Dygraph.Circles = utils.Circles;
+
+Dygraph.Plugins = {
+  Legend: LegendPlugin,
+  Axes: AxesPlugin,
+  // ...
+};
+Dygraph.DataHandlers = {
+  DefaultHandler
+};
+
+Dygraph.startPan = DygraphInteraction.startPan;
+Dygraph.startZoom = DygraphInteraction.startZoom;
+Dygraph.movePan = DygraphInteraction.movePan;
+Dygraph.moveZoom = DygraphInteraction.moveZoom;
+Dygraph.endPan = DygraphInteraction.endPan;
+Dygraph.endZoom = DygraphInteraction.endZoom;
 
 export default Dygraph;
index 1c518a8..2e93116 100644 (file)
 /*global Dygraph:false */
 
 (function() {
+
   "use strict";
 
+  // Matches DefaultHandler.parseFloat
+  var parseFloat = function(val) {
+    if (val === null) return NaN;
+    return val;
+  };
+
   Dygraph.DataHandlers.RebaseHandler = function(baseOpt) {
     this.baseOpt = baseOpt;
   };
@@ -66,7 +73,7 @@
     for (var i = 0; i <= lastIdx; ++i) {
       var item = series[i];
       var yraw = item[1];
-      var yval = yraw === null ? null : Dygraph.DataHandler.parseFloat(yraw);
+      var yval = yraw === null ? null : parseFloat(yraw);
       if (yval !== null) {
         if (i === firstIdx) {
           yval = (this.baseOpt === "percent") ? 0 : this.baseOpt;
@@ -77,7 +84,7 @@
       var point = {
         x: NaN,
         y: NaN,
-        xval: Dygraph.DataHandler.parseFloat(item[0]),
+        xval: parseFloat(item[0]),
         yval: yval,
         name: setName,
         idx: i + boundaryIdStart
index a453177..2df07a9 100644 (file)
@@ -68,7 +68,7 @@ var shapeFunction = function(sides, rotationRadians, delta) {
   };
 };
 
-Dygraph.update(Dygraph.Circles, {
+var customCircles = {
   TRIANGLE : shapeFunction(3),
   SQUARE : shapeFunction(4, Math.PI / 4),
   DIAMOND : shapeFunction(4),
@@ -113,6 +113,11 @@ Dygraph.update(Dygraph.Circles, {
     ctx.closePath();
     ctx.stroke();
   }
-});
+};
+
+for (var k in customCircles) {
+  if (!customCircles.hasOwnProperty(k)) continue;
+  Dygraph.Circles[k] = customCircles[k];
+}
 
 })();
index 50be892..270b44e 100644 (file)
               if (tool == 'zoom') {
                 Dygraph.defaultInteractionModel.mousedown(event, g, context);
               } else {
-                // prevents mouse drags from selecting page text.
-                if (event.preventDefault) {
-                  event.preventDefault();  // Firefox, Chrome, etc.
-                } else {
-                  event.returnValue = false;  // IE
-                  event.cancelBubble = true;
-                }
+                event.preventDefault();  // Firefox, Chrome, etc.
                 isDrawing = true;
                 setPoint(event, g, context);
               }
               g.updateOptions({
                 dateWindow: dateWindow
               });
-              Dygraph.cancelEvent(event);
+              event.preventDefault();
             }
           },
           strokeWidth: 1.5,
index 7ac23ee..1ffe163 100644 (file)
@@ -10,8 +10,8 @@
 
     <link rel='stylesheet' href='http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css' />
 
-    <script type="text/javascript" src="../extras/hairlines.js"></script>
-    <script type="text/javascript" src="../extras/super-annotations.js"></script>
+    <script type="text/javascript" src="../src/extras/hairlines.js"></script>
+    <script type="text/javascript" src="../src/extras/super-annotations.js"></script>
 
     <style>
       #demodiv {
index 01d5eb5..e7fadad 100644 (file)
@@ -27,8 +27,6 @@
     <div id="div_g1" style="width:600px; height:300px;"></div>
 
     <script type="text/javascript">
-      Dygraph.Interaction.DEBUG = true;
-
       function data0() {
         return "Date,A\n" +
         "20101201,5\n"+