Add tests for labelsKMB, labelsKMG2, sigFigs, digitsAfterDecimal and maxNumberWidth
[dygraphs.git] / dygraph.js
index cd9f147..cee63e8 100644 (file)
@@ -80,7 +80,7 @@ var Dygraph = function(div, data, opts, opt_fourth_param) {
 };
 
 Dygraph.NAME = "Dygraph";
-Dygraph.VERSION = "1.0.0";
+Dygraph.VERSION = "1.0.1";
 Dygraph.__repr__ = function() {
   return "[" + this.NAME + " " + this.VERSION + "]";
 };
@@ -857,7 +857,7 @@ Dygraph.prototype.toDataYCoord = function(y, axis) {
   var yRange = this.yAxisRange(axis);
 
   if (typeof(axis) == "undefined") axis = 0;
-  if (!this.axes_[axis].logscale) {
+  if (!this.attributes_.getForAxis("logscale", axis)) {
     return yRange[0] + (area.y + area.h - y) / area.h * (yRange[1] - yRange[0]);
   } else {
     // Computing the inverse of toDomCoord.
@@ -1161,28 +1161,32 @@ Dygraph.prototype.setColors_ = function() {
   var num = labels.length - 1;
   this.colors_ = [];
   this.colorsMap_ = {};
+
+  // These are used for when no custom colors are specified.
+  var sat = this.attr_('colorSaturation') || 1.0;
+  var val = this.attr_('colorValue') || 0.5;
+  var half = Math.ceil(num / 2);
+
   var colors = this.attr_('colors');
-  var i;
-  if (!colors) {
-    var sat = this.attr_('colorSaturation') || 1.0;
-    var val = this.attr_('colorValue') || 0.5;
-    var half = Math.ceil(num / 2);
-    for (i = 1; i <= num; i++) {
-      if (!this.visibility()[i-1]) continue;
-      // alternate colors for high contrast.
-      var idx = i % 2 ? Math.ceil(i / 2) : (half + i / 2);
-      var hue = (1.0 * idx/ (1 + num));
-      var colorStr = Dygraph.hsvToRGB(hue, sat, val);
-      this.colors_.push(colorStr);
-      this.colorsMap_[labels[i]] = colorStr;
+  var visibility = this.visibility();
+  for (var i = 0; i < num; i++) {
+    if (!visibility[i]) {
+      continue;
     }
-  } else {
-    for (i = 0; i < num; i++) {
-      if (!this.visibility()[i]) continue;
-      var colorStr = colors[i % colors.length];
-      this.colors_.push(colorStr);
-      this.colorsMap_[labels[1 + i]] = colorStr;
+    var label = labels[i + 1];
+    var colorStr = this.attributes_.getForSeries('color', label);
+    if (!colorStr) {
+      if (colors) {
+        colorStr = colors[i % colors.length];
+      } else {
+        // alternate colors for high contrast.
+        var idx = i % 2 ? (half + (i + 1)/ 2) : Math.ceil((i + 1) / 2);
+        var hue = (1.0 * idx / (1 + num));
+        colorStr = Dygraph.hsvToRGB(hue, sat, val);
+      }
     }
+    this.colors_.push(colorStr);
+    this.colorsMap_[label] = colorStr;
   }
 };
 
@@ -3629,6 +3633,3 @@ Dygraph.addAnnotationRule = function() {
 
   this.warn("Unable to add default annotation CSS rule; display may be off.");
 };
-
-// Older pages may still use this name.
-var DateGraph = Dygraph;