function dygraphsBinarySearch(g, xVal) {
  var low = 0,
      high = g.numRows() - 1;

  while (low <= high) {
    var idx = (high + low) >> 1;
    var x = g.getValue(idx, 0);
    if (x < xVal) {
      low = idx + 1;
    } else if (x > xVal) {
      high = idx - 1;
    } else {
      return idx;
    }
  }

  // TODO: give an option to find the closest point, i.e. not demand an exact match.
  return null;
}
// Returns the index corresponding to xVal, or null if there is none.
Returns the index corresponding to xVal, or null if there is none.
Returns the index corresponding to xVal or null if there is none .
function dygraphsBinarySearch(g, xVal) {
  var low = 0,
      high = g.numRows() - 1;
  while (low <= high) {
    var idx = (high + low) >> 1;
    var x = g.getValue(idx, 0);
    if (x < xVal) {
      low = idx + 1;
    } else if (x > xVal) {
      high = idx - 1;
    } else {
      return idx;
    }
  }
  return null;
}
function dygraphsBinarySearch ( g , xVal ) { var low = 0 , high = g . numRows ( ) - 1 ; while ( low <= high ) { var idx = ( high + low ) >> 1 ; var x = g . getValue ( idx , 0 ) ; if ( x < xVal ) { low = idx + 1 ; } else if ( x > xVal ) { high = idx - 1 ; } else { return idx ; } } return null ; }
Returns the index corresponding to xVal, or null if there is none.
Returns the index corresponding to xVal or null if there is none .
// TODO: give an option to find the closest point, i.e. not demand an exact match.