Commit 6ce34f45 authored by olau@iola.dk's avatar olau@iola.dk

Make sure points on top take precedence when finding nearby points when hovering


git-svn-id: https://flot.googlecode.com/svn/trunk@212 1e0a6537-2640-0410-bfb7-f154510ff394
parent b1e5068c
......@@ -1791,7 +1791,7 @@
// returns the data item the mouse is over, or null if none is found
function findNearbyItem(mouseX, mouseY, seriesFilter) {
var maxDistance = options.grid.mouseActiveRadius,
lowestDistance = maxDistance * maxDistance + 1,
smallestDistance = maxDistance * maxDistance + 1,
item = null, foundPoint = false, i, j;
for (i = 0; i < series.length; ++i) {
......@@ -1824,9 +1824,12 @@
// data units, because the scales of the axes may be different
var dx = Math.abs(axisx.p2c(x) - mouseX),
dy = Math.abs(axisy.p2c(y) - mouseY),
dist = dx * dx + dy * dy; // no idea in taking sqrt
if (dist < lowestDistance) {
lowestDistance = dist;
dist = dx * dx + dy * dy; // we save the sqrt
// use <= to ensure last point takes precedence
// (last generally means on top of)
if (dist <= smallestDistance) {
smallestDistance = dist;
item = [i, j / ps];
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment