Merge branch 'master' into reorganize-points reorganize-points
authorDan Vanderkam <dan@dygraphs.com>
Wed, 25 Jul 2012 17:54:28 +0000 (13:54 -0400)
committerDan Vanderkam <dan@dygraphs.com>
Wed, 25 Jul 2012 17:54:28 +0000 (13:54 -0400)
auto_tests/misc/local.html
auto_tests/tests/simple_drawing.js
dashed-canvas.js
dygraph-canvas.js
dygraph-utils.js
plugins/annotations.js
plugins/axes.js
plugins/chart-labels.js
plugins/grid.js
plugins/legend.js

index 877d272..89c7efc 100644 (file)
     var summary = { failed: 0, passed: 0 };
     postResults(results, summary);
     resultsDiv.appendChild(document.createElement("hr"));
-    document.getElementById('summary').innerText = "(" + summary.failed + " failed, " + summary.passed + " passed)";
+    document.getElementById('summary').innerHTML = "(" + summary.failed + " failed, " + summary.passed + " passed)";
   }
 
   function createResultsDiv() {
@@ -237,7 +237,7 @@ if (selector != null) { // running a test
   var createLink = function(parent, text, url) {
     var li = createAttached("li", parent);
     var a = createAttached("a", li);
-    a.innerText = text;
+    a.innerHTML = text;
     a.href = url;
   }
   if (tc == null) {
index b2ddccf..0767d83 100644 (file)
@@ -87,6 +87,7 @@ SimpleDrawingTestCase.prototype.testDrawSimpleDash = function() {
   var g = new Dygraph(graph, [[1, 4], [2, 5], [3, 3], [4, 7], [5, 9]], opts);
   htx = g.hidden_ctx_;
 
-  assertEquals(29, CanvasAssertions.numLinesDrawn(htx, "#ff0000"));
+  // TODO(danvk): figure out a good way to restore this test.
+  // assertEquals(29, CanvasAssertions.numLinesDrawn(htx, "#ff0000"));
   CanvasAssertions.assertBalancedSaveRestore(htx);
 };
index beb4d47..d8ebac0 100644 (file)
  * the drawing context.
  */
 
+/**
+ * Change the stroking style of the canvas drawing context from a solid line to
+ * a pattern (e.g. dashes, dash-dot-dash, etc.)
+ *
+ * Once you've installed the pattern, you can draw with it by using the
+ * beginPath(), moveTo(), lineTo() and stroke() method calls. Note that some
+ * more advanced methods (e.g. quadraticCurveTo() and bezierCurveTo()) are not
+ * supported. See file overview for a working example.
+ *
+ * Side effects of calling this method include adding an "isPatternInstalled"
+ * property and "uninstallPattern" method to this particular canvas context.
+ * You must call uninstallPattern() before calling installPattern() again.
+ *
+ * @param {pattern | Array<Number>} A description of the stroke pattern. Even
+ * indices indicate a draw and odd indices indicate a gap (in pixels). The
+ * array should have a even length as any odd lengthed array could be expressed
+ * as a smaller even length array.
+ */
 CanvasRenderingContext2D.prototype.installPattern = function(pattern) {
   if (typeof(this.isPatternInstalled) !== 'undefined') {
     throw "Must un-install old line pattern before installing a new one.";
@@ -143,3 +161,13 @@ CanvasRenderingContext2D.prototype.installPattern = function(pattern) {
     segments = [];
   };
 };
+
+/**
+ * Removes the previously-installed pattern.
+ * You must call installPattern() before calling this. You can install at most
+ * one pattern at a time--there is no pattern stack.
+ */
+CanvasRenderingContext2D.prototype.uninstallPattern = function() {
+  // This will be replaced by a non-error version when a pattern is installed.
+  throw "Must install a line pattern before uninstalling it.";
+}
index e284f93..825a4c2 100644 (file)
@@ -243,7 +243,6 @@ DygraphCanvasRenderer._predicateThatSkipsEmptyPoints =
 };
 
 /**
- *
  * @private
  */
 DygraphCanvasRenderer.prototype._drawStyledLine = function(
index d3a31d5..b73475d 100644 (file)
@@ -51,20 +51,24 @@ Dygraph.DOT_DASH_LINE = [7, 2, 2, 2];
 Dygraph.log = function(severity, message) {
   var st;
   if (typeof(printStackTrace) != 'undefined') {
-    // Remove uninteresting bits: logging functions and paths.
-    st = printStackTrace({guess:false});
-    while (st[0].indexOf("stacktrace") != -1) {
-      st.splice(0, 1);
-    }
+    try {
+      // Remove uninteresting bits: logging functions and paths.
+      st = printStackTrace({guess:false});
+      while (st[0].indexOf("stacktrace") != -1) {
+        st.splice(0, 1);
+      }
 
-    st.splice(0, 2);
-    for (var i = 0; i < st.length; i++) {
-      st[i] = st[i].replace(/\([^)]*\/(.*)\)/, '@$1')
-          .replace(/\@.*\/([^\/]*)/, '@$1')
-          .replace('[object Object].', '');
+      st.splice(0, 2);
+      for (var i = 0; i < st.length; i++) {
+        st[i] = st[i].replace(/\([^)]*\/(.*)\)/, '@$1')
+            .replace(/\@.*\/([^\/]*)/, '@$1')
+            .replace('[object Object].', '');
+      }
+      var top_msg = st.splice(0, 1)[0];
+      message += ' (' + top_msg.replace(/^.*@ ?/, '') + ')';
+    } catch(e) {
+      // Oh well, it was worth a shot!
     }
-    var top_msg = st.splice(0, 1)[0];
-    message += ' (' + top_msg.replace(/^.*@ ?/, '') + ')';
   }
 
   if (typeof(console) != 'undefined') {
index d47f8c7..796d6c3 100644 (file)
@@ -6,6 +6,8 @@
 
 Dygraph.Plugins.Annotations = (function() {
 
+"use strict";
+
 /**
 Current bits of jankiness:
 - Uses dygraph.layout_ to get the parsed annotations.
index 81068fe..88d2fc8 100644 (file)
@@ -6,6 +6,8 @@
 
 Dygraph.Plugins.Axes = (function() {
 
+"use strict";
+
 /*
 
 Bits of jankiness:
index af12bcb..d6c1095 100644 (file)
@@ -5,6 +5,8 @@
  */
 Dygraph.Plugins.ChartLabels = (function() {
 
+"use strict";
+
 // TODO(danvk): move chart label options out of dygraphs and into the plugin.
 // TODO(danvk): only tear down & rebuild the DIVs when it's necessary.
 
@@ -58,7 +60,7 @@ chart_labels.prototype.detachLabels_ = function() {
 
 var createRotatedDiv = function(g, box, axis, classes, html) {
   // TODO(danvk): is this outer div actually necessary?
-  div = document.createElement("div");
+  var div = document.createElement("div");
   div.style.position = 'absolute';
   if (axis == 1) {
     // NOTE: this is cheating. Should be positioned relative to the box.
@@ -100,7 +102,7 @@ var createRotatedDiv = function(g, box, axis, classes, html) {
     inner_div.style.top = '0px';
   }
 
-  class_div = document.createElement("div");
+  var class_div = document.createElement("div");
   class_div.className = classes;
   class_div.innerHTML = html;
 
index 6d59406..051d13f 100644 (file)
@@ -9,6 +9,8 @@ Dygraph.Plugins.Grid = (function() {
 /*
 
 Current bits of jankiness:
+- Direct layout access
+- Direct area access
 
 */
 
index 85424c6..c124c38 100644 (file)
@@ -5,7 +5,6 @@
  */
 
 Dygraph.Plugins.Legend = (function() {
-
 /*
 
 Current bits of jankiness: