Skip to content

Commit 7a4154f

Browse files
committed
make distance fn accept pt index as arg
1 parent b23fc92 commit 7a4154f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/plots/cartesian/graph_interact.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ function p2c(axArray, v) {
237237
}
238238

239239
function quadrature(dx, dy) {
240-
return function(di) {
241-
var x = dx(di),
242-
y = dy(di);
240+
return function(di, i) {
241+
var x = dx(di, i),
242+
y = dy(di, i);
243243
return Math.sqrt(x * x + y * y);
244244
};
245245
}
@@ -661,7 +661,7 @@ fx.getClosest = function(cd, distfn, pointData) {
661661
// to create pre-sorted data (by x or y), not sure how to
662662
// do this for 'closest'
663663
for(var i = 0; i < cd.length; i++) {
664-
var newDistance = distfn(cd[i]);
664+
var newDistance = distfn(cd[i], i);
665665
if(newDistance <= pointData.distance) {
666666
pointData.index = i;
667667
pointData.distance = newDistance;

0 commit comments

Comments
 (0)