Fixes for line mouse events (#428)
Fixes for line mouse events (#428)

* Fixes for line mouse events

I found a couple of issues with the mouse event handling:

First, the isOnLabel logic didn't check whether the label was currently shown, so if a label had ever been draw in the past, its rectangle would continue to count for determining whether the mouse was on the line annotation.

Second, the logic I added for restricting mouse events to where the line actually is (#403) didn't work for horizontal or vertical lines.  For those, the denominator in interpolateY / interpolateX was 0, so the resulting value was infinity, which was clamped to 1; effectively, only the endpoint of the line could trigger a mouse enter event.

* Apply suggestions from code review

Co-authored-by: Jukka Kurkela <d9daa89e8f2d44f5a7150603c781256d9a28ed9c@gmail.com>

* Remove clamp call

As suggested in code review.

Co-authored-by: Jukka Kurkela <d9daa89e8f2d44f5a7150603c781256d9a28ed9c@gmail.com>
chartjs/chartjs-plugin-annotation,chartjs/chartjs-plugin-annotation,chartjs/chartjs-plugin-annotation