Merge branch 'master' of git://github.com/flooey/dygraphs
[dygraphs.git] / dygraph.js
index 4b9b6f1..fb71149 100644 (file)
@@ -1359,7 +1359,7 @@ Dygraph.numericTicks = function(minV, maxV, self) {
       scale = base_scale * mults[j];
       low_val = Math.floor(minV / scale) * scale;
       high_val = Math.ceil(maxV / scale) * scale;
-      nTicks = (high_val - low_val) / scale;
+      nTicks = Math.abs(high_val - low_val) / scale;
       var spacing = self.height_ / nTicks;
       // wish I could break out of both loops at once...
       if (spacing > pixelsPerTick) break;
@@ -1381,6 +1381,9 @@ Dygraph.numericTicks = function(minV, maxV, self) {
     k_labels = [ "k", "M", "G", "T" ];
   }
 
+  // Allow reverse y-axis if it's explicitly requested.
+  if (low_val > high_val) scale *= -1;
+
   for (var i = 0; i < nTicks; i++) {
     var tickV = low_val + i * scale;
     var absTickV = Math.abs(tickV);
@@ -2149,7 +2152,7 @@ Dygraph.prototype.updateOptions = function(attrs) {
 
   // TODO(danvk): this doesn't match the constructor logic
   this.layout_.updateOptions({ 'errorBars': this.attr_("errorBars") });
-  if (attrs['file'] && attrs['file'] != this.file_) {
+  if (attrs['file']) {
     this.file_ = attrs['file'];
     this.start_();
   } else {