Make seriesToPoints_ and stackPoints_ private. They are being rendered as part of...
[dygraphs.git] / dygraph.js
index d771e18..879ce8d 100644 (file)
@@ -1412,7 +1412,7 @@ Dygraph.prototype.drawZoomRect_ = function(direction, startX, endX, startY,
   if (prevDirection == Dygraph.HORIZONTAL) {
     ctx.clearRect(Math.min(startX, prevEndX), this.layout_.getPlotArea().y,
                   Math.abs(startX - prevEndX), this.layout_.getPlotArea().h);
-  } else if (prevDirection == Dygraph.VERTICAL){
+  } else if (prevDirection == Dygraph.VERTICAL) {
     ctx.clearRect(this.layout_.getPlotArea().x, Math.min(startY, prevEndY),
                   this.layout_.getPlotArea().w, Math.abs(startY - prevEndY));
   }
@@ -1697,7 +1697,7 @@ Dygraph.prototype.eventToDomCoords = function(event) {
  */
 Dygraph.prototype.findClosestRow = function(domX) {
   var minDistX = Infinity;
-  var pointIdx = -1, setIdx = -1;
+  var closestRow = -1;
   var sets = this.layout_.points;
   for (var i = 0; i < sets.length; i++) {
     var points = sets[i];
@@ -1708,14 +1708,12 @@ Dygraph.prototype.findClosestRow = function(domX) {
       var dist = Math.abs(point.canvasx - domX);
       if (dist < minDistX) {
         minDistX = dist;
-        setIdx = i;
-        pointIdx = j;
+        closestRow = point.idx;
       }
     }
   }
 
-  // TODO(danvk): remove this function; it's trivial and has only one use.
-  return this.idxToRow_(setIdx, pointIdx);
+  return closestRow;
 };
 
 /**
@@ -1862,8 +1860,8 @@ Dygraph.prototype.mouseMove_ = function(event) {
  * @private
  */
 Dygraph.prototype.getLeftBoundary_ = function(setIdx) {
-  if(!isNaN(setIdx) && setIdx < boundaryIds_.length){
-    return boundaryIds_[setIdx][0];
+  if (this.boundaryIds_[setIdx]) {
+      return this.boundaryIds_[setIdx][0];
   } else {
     for (var i = 0; i < this.boundaryIds_.length; i++) {
       if (this.boundaryIds_[i] !== undefined) {
@@ -1874,19 +1872,6 @@ Dygraph.prototype.getLeftBoundary_ = function(setIdx) {
   }
 };
 
-/**
- * Transforms layout_.points index into data row number.
- * @param int layout_.points index
- * @return int row number, or -1 if none could be found.
- * @private
- */
-Dygraph.prototype.idxToRow_ = function(setIdx, rowIdx) {
-  if (rowIdx < 0) return -1;
-
-  var boundary = this.getLeftBoundary_(setIdx);
-  return boundary + rowIdx;
-};
-
 Dygraph.prototype.animateSelection_ = function(direction) {
   var totalSteps = 10;
   var millis = 30;
@@ -2227,7 +2212,7 @@ Dygraph.prototype.predraw_ = function() {
     this.plotter_.clear();
   }
 
-  if(!this.is_initial_draw_) {
+  if (!this.is_initial_draw_) {
     this.canvas_ctx_.restore();
     this.hidden_ctx_.restore();
   }
@@ -2297,6 +2282,7 @@ Dygraph.PointType = undefined;
 /**
  * Converts a series to a Point array.
  *
+ * @private
  * @param {Array.<Array.<(?number|Array<?number>)>} series Array where
  *     series[row] = [x,y] or [x, [y, err]] or [x, [y, yplus, yminus]].
  * @param {boolean} bars True if error bars or custom bars are being drawn.
@@ -2348,6 +2334,7 @@ Dygraph.seriesToPoints_ = function(series, bars, setName, boundaryIdStart) {
  *     to reflect the stacked values.
  * @param {string} fillMethod Interpolation method, one of 'all', 'inside', or
  *     'none'.
+ * @private
  */
 Dygraph.stackPoints_ = function(
     points, cumulativeYval, seriesExtremes, fillMethod) {
@@ -2855,7 +2842,7 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) {
     }
     
     
-    if(independentTicks) {
+    if (independentTicks) {
       axis.independentTicks = independentTicks;
       var opts = this.optionsViewForAxis_('y' + (i ? '2' : ''));
       var ticker = opts('ticker');
@@ -3042,7 +3029,7 @@ Dygraph.prototype.rollingAverage = function(originalData, rollPeriod) {
   } else {
     // Calculate the rolling average for the first rollPeriod - 1 points where
     // there is not enough data to roll over the full number of points
-    if (!this.attr_("errorBars")){
+    if (!this.attr_("errorBars")) {
       if (rollPeriod == 1) {
         return originalData;
       }