Merge branch 'master' of https://github.com/danvk/dygraphs into no-width-no-work
[dygraphs.git] / dashed-canvas.js
index af2470e..853d67b 100644 (file)
@@ -46,6 +46,8 @@
  * as a smaller even length array.
  */
 CanvasRenderingContext2D.prototype.installPattern = function(pattern) {
+  "use strict";
+
   if (typeof(this.isPatternInstalled) !== 'undefined') {
     throw "Must un-install old line pattern before installing a new one.";
   }
@@ -115,10 +117,10 @@ CanvasRenderingContext2D.prototype.installPattern = function(pattern) {
 
         // Set last pattern index we used for this pattern.
         var patternIndex = dashedLineToHistory[0];
-        x = 0;
+        var x = 0;
         while (len > x) {
           // Get the length of the pattern segment we are dealing with.
-          segment = pattern[patternIndex];
+          var segment = pattern[patternIndex];
           // If our last draw didn't complete the pattern segment all the way
           // we will try to finish it. Otherwise we will try to do the whole
           // segment.
@@ -161,3 +163,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.";
+}