shutterstock/rickshaw — pull request #189 by mmeisel (2013-01-26 21:23:30+00:00)
Title: Allow hover for next-to-last point in series

The hover detail calculation makes it very difficult to hover over the next-to-last point in the series. You can easily see this in the lines example (http://code.shutterstock.com/rickshaw/examples/lines.html), just try to hover over the next-to-last point. I'm describing the same problem as issue #137, but, as you can see, it actually applies to all chart types.

Some more detail about the problem: Since the maximum of the linear scale is data.length instead of data.length - 1, hovering between the next-to-last and last points gives an approximateIndex of data.length - 1 instead of data.length - 2. This means the loop is never entered, and data.length - 1 is used as the dataIndex. Of course, by just changing the range of the linear scale to [0, data.length - 1], it wouldn't be possible to hover over the last point.

My solution is to simply hover over the *closest* point instead of the previous one by using Math.round() instead of Math.floor(). Along with changing the range to [0, data.length - 1], I believe this solves the problem (including issue #137) in the general case.