Merge pull request #313 from CSGOpenSource/CSG-v1.0.1
authorDan Vanderkam <danvdk@gmail.com>
Fri, 31 Oct 2014 16:24:00 +0000 (12:24 -0400)
committerDan Vanderkam <danvdk@gmail.com>
Fri, 31 Oct 2014 16:24:00 +0000 (12:24 -0400)
Stack series per axis

CONTRIBUTING.md [new file with mode: 0644]
Makefile
auto_tests/tests/selection.js
bower.json [new file with mode: 0644]
check-combined-unaffected.sh [new file with mode: 0755]
datahandler/datahandler.js
docs/header.html
dygraph-utils.js
dygraph.js
release.sh

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644 (file)
index 0000000..3b5598b
--- /dev/null
@@ -0,0 +1,21 @@
+Filing a bug report? Please include the following:
+
+1. Link to a page which demonstrates the problem, preferably a jsfiddle (use [this jsfiddle](http://dygraphs.com/fiddle) as a template)
+2. Browser and Operating System that exhibit the problem
+
+It also helps if you include the non-compacted version of the JS on your
+page. For instance, instead of doing this:
+
+```html
+<script type="text/javascript" src="dygraph-combined.js"></script>
+```
+
+do this:
+
+```html
+<script type="text/javascript" src="dygraph-dev.js"></script>
+```
+
+This makes error messages and debugging simpler. The jsfiddle does this automatically.
+
+Sending a Pull Request? See our [guide to making dygraphs contributions](http://dygraphs.com/changes.html).
index 18522df..2047c7f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,7 @@ generate-gwt:
 
 test:
        @./test.sh
+       @./check-combined-unaffected.sh
 
 test-combined: move-combined test clean-combined-test
 
index 2e68c1f..ff220f6 100644 (file)
@@ -48,3 +48,43 @@ SelectionTestCase.prototype.testSetGetSelectionDense = function() {
   g.setSelection(3);
   assertEquals(3, g.getSelection());
 };
+
+SelectionTestCase.prototype.testSetGetSelectionMissingPoints = function() {
+  dataHandler = function() {};
+  dataHandler.prototype = new Dygraph.DataHandlers.DefaultHandler();
+  dataHandler.prototype.seriesToPoints = function(series, setName, boundaryIdStart) {
+    var val = null;
+    if (setName == 'A') {
+      val = 1;
+    } else if (setName == 'B') {
+      val = 2;
+    } else if (setName == 'C') {
+      val = 3;
+    }
+    return [{
+      x: NaN,
+      y: NaN,
+      xval: val,
+      yval: val,
+      name: setName,
+      idx: val - 1
+    }];
+  };
+  var graph = document.getElementById("graph");
+  var g = new Dygraph(graph,
+    "X,A,B,C\n" +
+    "1,1,null,null\n" +
+    "2,null,2,null\n" +
+    "3,null,null,3\n",
+    {
+      dataHandler: dataHandler
+    }
+  );
+
+  g.setSelection(0);
+  assertEquals(0, g.getSelection());
+  g.setSelection(1);
+  assertEquals(1, g.getSelection());
+  g.setSelection(2);
+  assertEquals(2, g.getSelection());
+};
diff --git a/bower.json b/bower.json
new file mode 100644 (file)
index 0000000..4aa054d
--- /dev/null
@@ -0,0 +1,45 @@
+{
+  "name": "dygraphs",
+  "version": "v1.0.1+bower",
+  "main": "dygraph-combined.js",
+  "ignore": [
+    "Makefile",
+    "NOTES",
+    "auto_tests",
+    "closure-todo.txt",
+    "common",
+    "compile-with-closure.sh",
+    "dashed-canvas.js",
+    "data.js",
+    "datahandler",
+    "docs",
+    "experimental",
+    "file-size-stats.sh",
+    "gadget.xml",
+    "gallery",
+    "generate-combined.sh",
+    "generate-documentation.py",
+    "generate-download.py",
+    "generate-jar.sh",
+    "generate-jsdoc.sh",
+    "gviz-api.js",
+    "gwt",
+    "jsTestDriver.conf",
+    "jsdoc-toolkit",
+    "jshint",
+    "lint.sh",
+    "node_modules",
+    "package.json",
+    "phantom-driver.js",
+    "phantom-perf.js",
+    "push-to-web.sh",
+    "release.sh",
+    "releases.json",
+    "screenshot.png",
+    "stacktrace.js",
+    "test.sh",
+    "tests",
+    "thumbnail.png",
+    "yuicompressor-2.4.2.jar"
+  ]
+}
diff --git a/check-combined-unaffected.sh b/check-combined-unaffected.sh
new file mode 100755 (executable)
index 0000000..de1721e
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+# Ensures that dygraph-combined.js is unaffected.
+# Helpful for pull requests, where this is a common mistake.
+
+grep 'var' dygraph-combined.js > /dev/null
+if [ $? -eq 0 ]; then
+  echo 'Please revert changes to dygraph-combined.js' >&2
+  echo 'You can do this by running:  ' >& 2
+  echo '' >& 2
+  echo '    git checkout dygraph-combined.js' >&2
+  echo '' >& 2
+  exit 1
+fi
+
+exit 0
index 2b637b5..b3eae91 100644 (file)
@@ -103,7 +103,8 @@ handler.prototype.extractSeries = function(rawData, seriesIndex, options) {
 };
 
 /**
- * Converts a series to a Point array.
+ * Converts a series to a Point array.  The resulting point array must be
+ * returned in increasing order of idx property.
  * 
  * @param {!Array.<[!number,?number,?]>} series The series in the unified 
  *          data format where series[i] = [x,y,{extras}].
index 689e1e2..37c2e90 100644 (file)
@@ -76,8 +76,8 @@
             <ul id="menu3" class="dropdown-menu" role="menu" aria-labelledby="drop6">
               <li role="presentation"><a role="menuitem" tabindex="-1" href="changes.html">Contributors Guide</a></li>
               <li role="presentation"><a role="menuitem" tabindex="-1" href="http://github.com/danvk/dygraphs">Source (Github)</a></li>
-              <li role="presentation"><a role="menuitem" tabindex="-1" href="https://code.google.com/p/dygraphs/issues/list">Issue Tracker</a></li>
-              <li role="presentation"><a role="menuitem" tabindex="-1" href="https://code.google.com/p/dygraphs/issues/entry">Report a Bug</a></li>
+              <li role="presentation"><a role="menuitem" tabindex="-1" href="https://github.com/danvk/dygraphs/issues">Issue Tracker</a></li>
+              <li role="presentation"><a role="menuitem" tabindex="-1" href="https://github.com/danvk/dygraphs/issues/new">Report a Bug</a></li>
             </ul>
           </li>
         </ul> <!-- /tabs -->
index 63fc1e0..dc93023 100644 (file)
@@ -787,13 +787,20 @@ Dygraph.createCanvas = function() {
  */
 Dygraph.getContextPixelRatio = function(context) {
   try {
-    var devicePixelRatio = window.devicePixelRatio || 1,
-        backingStoreRatio = context.webkitBackingStorePixelRatio ||
+    var devicePixelRatio = window.devicePixelRatio;
+    var backingStoreRatio = context.webkitBackingStorePixelRatio ||
                             context.mozBackingStorePixelRatio ||
                             context.msBackingStorePixelRatio ||
                             context.oBackingStorePixelRatio ||
-                            context.backingStorePixelRatio || 1;
-    return devicePixelRatio / backingStoreRatio;
+                            context.backingStorePixelRatio;
+    if (devicePixelRatio !== undefined &&
+        backingStorePixelRatio !== undefined) {
+      return devicePixelRatio / backingStoreRatio;
+    } else {
+      // If either value is undefined, the ratio is meaningless so we want to
+      // return 1.
+      return 1;
+    }
   } catch (e) {
     return 1;
   }
index 1aa43ea..038bf8b 100644 (file)
@@ -2124,10 +2124,23 @@ Dygraph.prototype.setSelection = function(row, opt_seriesName, opt_locked) {
     this.lastRow_ = row;
     for (var setIdx = 0; setIdx < this.layout_.points.length; ++setIdx) {
       var points = this.layout_.points[setIdx];
+      // Check if the point at the appropriate index is the point we're looking
+      // for.  If it is, just use it, otherwise search the array for a point
+      // in the proper place.
       var setRow = row - this.getLeftBoundary_(setIdx);
-      if (setRow < points.length) {
+      if (setRow < points.length && points[setRow].idx == row) {
         var point = points[setRow];
         if (point.yval !== null) this.selPoints_.push(point);
+      } else {
+        for (var pointIdx = 0; pointIdx < points.length; ++pointIdx) {
+          var point = points[pointIdx];
+          if (point.idx == row) {
+            if (point.yval !== null) {
+              this.selPoints_.push(point);
+            }
+            break;
+          }
+        }
       }
     }
   } else {
index 01089e4..909e109 100755 (executable)
@@ -26,6 +26,18 @@ if [ $? -ne 0 ]; then
   exit 1
 fi
 
+grep "$VERSION" package.json
+if [ $? -ne 0 ]; then
+  echo "Version in package.json doesn't match command line argument." >&2
+  exit 1
+fi
+
+grep "v$VERSION" bower.json
+if [ $? -ne 0 ]; then
+  echo "Version in bower.json doesn't match command line argument." >&2
+  exit 1
+fi
+
 make lint test test-combined
 if [ $? -ne 0 ]; then
   echo "Tests failed. Won't release!" >&2