Fix errors/warnings in tests/*.html
authorDan Vanderkam <danvdk@gmail.com>
Sun, 25 Oct 2015 02:17:58 +0000 (22:17 -0400)
committerDan Vanderkam <danvdk@gmail.com>
Sun, 25 Oct 2015 02:44:38 +0000 (22:44 -0400)
22 files changed:
scripts/casperscript.js [new file with mode: 0644]
src/dygraph-tickers.js
src/dygraph.js
src/extras/smooth-plotter.js
tests/customLabel.html
tests/customLabelCss3.html
tests/dashed-canvas.html
tests/exported-symbols.html
tests/iframe.html
tests/interaction.html
tests/interaction.js
tests/labelsKMB.html
tests/logscale.html
tests/multi-scale.html
tests/plugins.html
tests/range-selector.html
tests/smooth-plots.html
tests/spacing.html
tests/two-axes-vr.html
tests/two-axes.html
tests/value-axis-formatters.html
tests/x-axis-formatter.html

diff --git a/scripts/casperscript.js b/scripts/casperscript.js
new file mode 100644 (file)
index 0000000..a7ad3d1
--- /dev/null
@@ -0,0 +1,28 @@
+// This script can be used to check for errors/console warnings in _all_ the
+// files in tests/*.html.
+//
+// Suggested usage:
+//
+//     npm install casperjs
+//     for x in tests/*.html; casperjs scripts/casperscript.js $x
+
+var casper = require('casper').create({
+  verbose: true
+});
+var filename = casper.cli.args[0];
+
+casper.echo(filename);
+casper.on('remote.message', function(message) {
+  this.echo('page console: ' + message);
+});
+
+casper.on('resource.error', function(e) {
+  this.echo('resource.error: ' + e);
+});
+casper.on('page.error', function(e) {
+  this.echo('error! ' + e);
+});
+
+casper.start(filename, function() { });
+
+casper.run();
index 31ae852..f152bf9 100644 (file)
@@ -443,16 +443,3 @@ export var getDateAxis = function(start_time, end_time, granularity, opts, dg) {
   }
   return ticks;
 };
-
-// These are set here so that this file can be included after dygraph.js
-// or independently.
-// if (Dygraph &&
-//     Dygraph.DEFAULT_ATTRS &&
-//     Dygraph.DEFAULT_ATTRS['axes'] &&
-//     Dygraph.DEFAULT_ATTRS['axes']['x'] &&
-//     Dygraph.DEFAULT_ATTRS['axes']['y'] &&
-//     Dygraph.DEFAULT_ATTRS['axes']['y2']) {
-//   Dygraph.DEFAULT_ATTRS['axes']['x']['ticker'] = Dygraph.dateTicker;
-//   Dygraph.DEFAULT_ATTRS['axes']['y']['ticker'] = Dygraph.numericTicks;
-//   Dygraph.DEFAULT_ATTRS['axes']['y2']['ticker'] = Dygraph.numericTicks;
-// }
index cb8639f..634520c 100644 (file)
@@ -3582,4 +3582,11 @@ Dygraph.moveZoom = DygraphInteraction.moveZoom;
 Dygraph.endPan = DygraphInteraction.endPan;
 Dygraph.endZoom = DygraphInteraction.endZoom;
 
+Dygraph.numericLinearTicks = DygraphTickers.numericLinearTicks;
+Dygraph.numericTicks = DygraphTickers.numericTicks;
+Dygraph.dateTicker = DygraphTickers.dateTicker;
+Dygraph.Granularity = DygraphTickers.Granularity;
+Dygraph.getDateAxis = DygraphTickers.getDateAxis;
+Dygraph.floatFormat = utils.floatFormat;
+
 export default Dygraph;
index d0182f4..69685ec 100644 (file)
@@ -75,6 +75,10 @@ function getControlPoints(p0, p1, p2, opt_alpha, opt_allowFalseExtrema) {
   return [l1x, l1y, r1x, r1y];
 }
 
+// i.e. is none of (null, undefined, NaN)
+function isOK(x) {
+  return !!x && !isNaN(x);
+};
 
 // A plotter which uses splines to create a smooth curve.
 // See tests/plotters.html for a demo.
@@ -88,7 +92,6 @@ function smoothPlotter(e) {
 
   // right control point for previous point
   var lastRightX = points[0].canvasx, lastRightY = points[0].canvasy;
-  var isOK = Dygraph.isOK;  // i.e. is none of (null, undefined, NaN)
 
   for (var i = 1; i < points.length; i++) {
     var p0 = points[i - 1],
index 1402325..c4ebee7 100644 (file)
               rollPeriod: 14,
               errorBars: true,
               labelsSeparateLines: true,
-              yAxisLabelWidth: 20
+              axes: {
+                y: {
+                  axisLabelWidth: 20
+                }
+              }
             }
           );
     </script>
index 462a4d6..2b1b55a 100644 (file)
                 'boxShadow': '4px 4px 4px #888'
               },
               labelsSeparateLines: true,
-              yAxisLabelWidth: 20
+              axes: {
+                y: {
+                  axisLabelWidth: 20
+                }
+              }
             }
           );
     </script>
index e12d998..c80b3fc 100644 (file)
@@ -1,7 +1,4 @@
 <html>
-<head>
-  <script src="../src/polyfills/dashed-canvas.js"></script>
-</head>
 <body>
 <p>You should see solid black and blue lines with a dashed red line in between
 them:</p>
index 4a80f67..0800823 100644 (file)
         windowProps[k] = true;
       }
     </script>
-    <!--
     <script type="text/javascript" src="../dist/dygraph.js"></script>
-    -->
-    <script type="text/javascript" src="../dygraph-combined.js"></script>
     <script type="text/javascript">
       for (k in window) {
         if (!windowProps.hasOwnProperty(k)) {
index 9e98626..d3189f9 100644 (file)
@@ -35,7 +35,7 @@
     <iframe id="iframe" width=400 height=520 src="http://en.wikipedia.org/">iframe here</iframe>
 
     <p>Click on various places in the chart, then drag the mouse over the iframe
-    and release it. When you mouse back over the charts, strange things will
+    and release it. When you mouse back over the charts, strange things shouldn't
     happen.</p>
 
     <script type="text/javascript">
index a9b99c1..8b64843 100644 (file)
     </table>
         
     <script type="text/javascript">
-      Dygraph.addEvent(document, "mousewheel", function() { lastClickedGraph = null; });
-      Dygraph.addEvent(document, "click", function() { lastClickedGraph = null; });
+      document.addEventListener("mousewheel", function() {
+        lastClickedGraph = null;
+      }, false);
+      document.addEventListener("click", function() { lastClickedGraph = null; }, false);
       var g = new Dygraph(document.getElementById("div_g"),
            NoisyData, { errorBars : true });
       var s = document.getElementById("g2_console");
index 4b85211..6ce65a8 100644 (file)
@@ -83,7 +83,8 @@ var lastClickedGraph = null;
 
 function clickV3(event, g, context) {
   lastClickedGraph = g;
-  Dygraph.cancelEvent(event);
+  event.preventDefault();
+  event.stopPropagation();
 }
 
 function scrollV3(event, g, context) {
@@ -105,7 +106,8 @@ function scrollV3(event, g, context) {
   var yPct = percentages[1];
 
   zoom(g, percentage, xPct, yPct);
-  Dygraph.cancelEvent(event);
+  event.preventDefault();
+  event.stopPropagation();
 }
 
 // Adjusts [x, y] toward each other by zoomInPercentage%
index 662cc86..3b44160 100644 (file)
       });
       var g3 = new Dygraph(document.getElementById("labelsKMG2yValueFormatter"), data, {
         labelsKMG2: true,
-        yValueFormatter: formatValue,
+        axes: {
+          y: {
+            valueFormatter: formatValue
+          }
+        },
         labels: ['Base', 'Power']
       });
 
index e7fadad..fda64dd 100644 (file)
         "7,0\n"+
         "8,100\n"+
         "9,500\n"+
-        "101,500\n"+
         "30,500\n"+
         "50,400\n"+
         "100,300\n"+
+        "101,500\n"+
         "300,200\n"+
         "1000,100\n"+
         "";
index 7c6c651..478111b 100644 (file)
                 title: 'Four series on the same scale',
                 xlabel: 'Date',
                 ylabel: 'Count',
-                yAxisLabelWidth: 80
+                axes: {
+                  y: {
+                    axisLabelWidth: 80
+                  }
+                }
               }
           );
     </script>
index c92cda7..92cd104 100644 (file)
@@ -5,7 +5,7 @@
     <script type="text/javascript" src="../dist/dygraph.js"></script>
 
     <!-- Include the Javascript for the plug-in -->
-    <script type="text/javascript" src="../extras/unzoom.js"></script>
+    <script type="text/javascript" src="../src/extras/unzoom.js"></script>
   </head>
   <body>
     <h2>Plugins Demo</h2>
index 4b13fc3..b257fe4 100644 (file)
                 drawAxis : false
               }
             },
+            labels: ['X', 'Y'],
             showRangeSelector: true,
             rangeSelectorHeight: 30
           }
index dbd9e4e..55ebb1c 100644 (file)
@@ -3,7 +3,7 @@
   <head>
     <title>Plotters demo</title>
     <script type="text/javascript" src="../dist/dygraph.js"></script>
-    <script type="text/javascript" src="../extras/smooth-plotter.js"></script>
+    <script type="text/javascript" src="../src/extras/smooth-plotter.js"></script>
 
     <style type="text/css">
       body {
index 21a8ae5..18f4e4d 100644 (file)
             document.getElementById("div_g"),
             data, {
               rollPeriod: 7,
-              pixelsPerYLabel: 20
+              axes: {
+                y: {
+                  pixelsPerLabel: 20
+                }
+              }
             }
           );
       g2 = new Dygraph(
             document.getElementById("div_g2"),
             data, {
               rollPeriod: 7,
-              pixelsPerYLabel: 20
+              axes: {
+                y: {
+                  pixelsPerLabel: 20
+                }
+              }
             }
           );
     </script>
index 712578e..b714b36 100644 (file)
             },
             ylabel: 'Primary y-axis',
             y2label: 'Secondary y-axis',
-            yAxisLabelWidth: 60
+            axes: {
+              y: {
+                axisLabelWidth: 60
+              }
+            }
           }
       );
 
@@ -89,7 +93,8 @@
             },
             axes: {
               y: {
-                valueRange: [40, 80]
+                valueRange: [40, 80],
+                axisLabelWidth: 60
               },
               y2: {
                 // set axis-related properties here
               }
             },
             ylabel: 'Primary y-axis',
-            y2label: 'Secondary y-axis',
-            yAxisLabelWidth: 60
+            y2label: 'Secondary y-axis'
           }
       );
 
index f583263..f652389 100644 (file)
@@ -53,6 +53,9 @@
               },
             },
             axes: {
+              y: {
+                axisLabelWidth: 60
+              },
               y2: {
                 // set axis-related properties here
                 labelsKMB: true
@@ -60,7 +63,6 @@
             },
             ylabel: 'Primary y-axis',
             y2label: 'Secondary y-axis',
-            yAxisLabelWidth: 60
           }
       );
       
index c7b8a16..31d61ea 100644 (file)
@@ -57,8 +57,6 @@
               'Y3': { axis: 'y2' },
               'Y4': { axis: 'y2' }
             },
-            xAxisLabelWidth: 100,
-            yAxisLabelWidth: 100,
             axes: {
               x: {
                 valueFormatter: function(ms) {
@@ -68,6 +66,7 @@
                   return 'xalf(' + formatDate(d) + ')';
                 },
                 pixelsPerLabel: 100,
+                axisLabelWidth: 100,
               },
               y: {
                 valueFormatter: function(y) {
@@ -75,7 +74,8 @@
                 },
                 axisLabelFormatter: function(y) {
                   return 'yalf(' + y.toPrecision(2) + ')';
-                }
+                },
+                axisLabelWidth: 100
               },
               y2: {
                 valueFormatter: function(y2) {
index a2f7827..ef884e3 100644 (file)
@@ -31,6 +31,9 @@
           "2009/07/12 05:00:00,3,6\n" +
           "2009/07/12 06:00:00,4,6"
       }
+      function zeropad(x) {
+        return (x < 10) ? '0' + x : x;
+      }
 
       var g1 = new Dygraph(
             document.getElementById("normal"),
             document.getElementById("seconds"),
             HourlyData(),
             { 
-              xAxisLabelWidth: 70,
               axes: {
                 x: {
+                  axisLabelWidth: 70,
                   axisLabelFormatter: function(d, gran) {
-                    return Dygraph.zeropad(d.getHours()) + ":"
-                        + Dygraph.zeropad(d.getMinutes()) + ":"
-                        + Dygraph.zeropad(d.getSeconds());
+                    return zeropad(d.getHours()) + ":"
+                        + zeropad(d.getMinutes()) + ":"
+                        + zeropad(d.getSeconds());
                   }
                 }
               }