Merge branch 'master' of github.com:danvk/dygraphs
authorDan Vanderkam <dan@dygraphs.com>
Sun, 10 Apr 2011 21:56:18 +0000 (17:56 -0400)
committerDan Vanderkam <dan@dygraphs.com>
Sun, 10 Apr 2011 21:56:18 +0000 (17:56 -0400)
1  2 
dygraph.js

diff --combined dygraph.js
@@@ -1699,11 -1699,10 +1699,11 @@@ Dygraph.prototype.generateLegendHTML_ 
      var labels = this.attr_('labels');
      var html = '';
      for (var i = 1; i < labels.length; i++) {
 -      var c = new RGBColor(this.plotter_.colors[labels[i]]);
 -      if (i > 1) html += (sepLines ? '<br/>' : ' ');
 -      html += "<b><font color='" + c.toHex() + "'>&mdash;" + labels[i] +
 -        "</font></b>";
 +      if (!this.visibility()[i - 1]) continue;
 +      var c = this.plotter_.colors[labels[i]];
 +      if (html != '') html += (sepLines ? '<br/>' : ' ');
 +      html += "<b><span style='color: " + c + ";'>&mdash;" + labels[i] +
 +        "</span></b>";
      }
      return html;
    }
      if (!Dygraph.isOK(pt.canvasy)) continue;
      if (sepLines) html += "<br/>";
  
 -    var c = new RGBColor(this.plotter_.colors[pt.name]);
 +    var c = this.plotter_.colors[pt.name];
      var yval = fmtFunc(pt.yval, displayDigits);
      // TODO(danvk): use a template string here and make it an attribute.
 -    html += " <b><font color='" + c.toHex() + "'>"
 -      + pt.name + "</font></b>:"
 +    html += " <b><span style='color: " + c + ";'>"
 +      + pt.name + "</span></b>:"
        + yval;
    }
    return html;
@@@ -1811,6 -1810,7 +1811,6 @@@ Dygraph.prototype.setSelection = functi
      this.lastx_ = this.selPoints_[0].xval;
      this.updateSelection_();
    } else {
 -    this.lastx_ = -1;
      this.clearSelection();
    }
  
@@@ -2629,13 -2629,6 +2629,13 @@@ Dygraph.prototype.drawGraph_ = function
    if (is_initial_draw) {
      // Generate a static legend before any particular point is selected.
      this.attr_('labelsDiv').innerHTML = this.generateLegendHTML_();
 +  } else {
 +    if (typeof(this.selPoints_) !== 'undefined' && this.selPoints_.length) {
 +      this.lastx_ = this.selPoints_[0].xval;
 +      this.updateSelection_();
 +    } else {
 +      this.clearSelection();
 +    }
    }
  
    if (this.attr_("drawCallback") !== null) {
@@@ -2777,25 -2770,14 +2777,14 @@@ Dygraph.prototype.computeYAxisRanges_ 
      seriesForAxis[idx].push(series);
    }
  
-   // If no series are defined or visible then fill in some reasonable defaults.
-   if (seriesForAxis.length == 0) {
-     var axis = this.axes_[0];
-     axis.computedValueRange = [0, 1];
-     var ret =
-       Dygraph.numericTicks(axis.computedValueRange[0],
-                            axis.computedValueRange[1],
-                            this,
-                            axis);
-     axis.ticks = ret.ticks;
-     this.numYDigits_ = ret.numDigits;
-     return;
-   }
    // Compute extreme values, a span and tick marks for each axis.
    for (var i = 0; i < this.axes_.length; i++) {
      var axis = this.axes_[i];
   
-     {
+     if (!seriesForAxis[i]) {
+       // If no series are defined or visible then use a reasonable default
+       axis.extremeRange = [0, 1];
+     } else {
        // Calculate the extremes of extremes.
        var series = seriesForAxis[i];
        var minY = Infinity;  // extremes[series[0]][0];