export function pickArea(a, p) {
  var v = a[0].orient === 'horizontal' ? p[1] : p[0],
      z = a[0].orient === 'horizontal' ? 'y' : 'x',
      lo = 0,
      hi = a.length;

  if (hi === 1) return a[0];

  while (lo < hi) {
    var mid = lo + hi >>> 1;
    if (a[mid][z] < v) lo = mid + 1;
    else hi = mid;
  }
  lo = Math.max(0, lo - 1);
  hi = Math.min(a.length - 1, hi);

  return (v - a[lo][z]) < (a[hi][z] - v) ? a[lo] : a[hi];
}

export function pickLine(a, p) {
  var t = Math.pow(a[0].strokeWidth || 1, 2),
      i = a.length, dx, dy, dd;

  while (--i >= 0) {
    if (a[i].defined === false) continue;
    dx = a[i].x - p[0];
    dy = a[i].y - p[1];
    dd = dx * dx + dy * dy;
    if (dd < t) return a[i];
  }

  return null;
}

export function pickTrail(a, p) {
  var i = a.length, dx, dy, dd;

  while (--i >= 0) {
    if (a[i].defined === false) continue;
    dx = a[i].x - p[0];
    dy = a[i].y - p[1];
    dd = dx * dx + dy * dy;
    dx = a[i].size || 1;
    if (dd < dx*dx) return a[i];
  }

  return null;
}

@@ -142,23 +142,8 @@
     
-lo = 0,%0A      h
 i = 
@@ -154,270 +154,211 @@
 ngth
-;%0A%0A  if (hi === 1) return a%5B0%5D;%0A%0A  while (lo %3C hi) %7B%0A    var mid = lo + hi %3E%3E%3E 1;%0A    if (a%5Bmid
+,%0A      min = +Infinity, hit, d;%0A%0A  while (--i %3E= 0) %7B%0A    if (a%5Bi%5D.defined === false) continue;%0A    d = Math.abs(a%5Bi
 %5D%5Bz%5D 
-%3C v) lo = mid + 1;%0A    else hi
+- v);%0A    if (d %3C min) %7B%0A      min
  = 
-mi
 d;%0A  
-%7D%0A  lo = Math.max(0, lo - 1);%0A  hi = Math.min(a.length - 1, hi);%0A%0A  return (v - a%5Blo%5D%5Bz%5D) %3C (a%5Bhi%5D%5Bz%5D - v) ? a%5Blo%5D : a%5Bhi%5D
+    hit = a%5Bi%5D;%0A    %7D%0A  %7D%0A%0A  return hit
 ;%0A%7D%0A

Fix pickArea method. (vega/vega#1390)