@@ -5,7 +5,7 @@ import {addRoundedRectPath, drawPoint, renderText} from '../helpers/helpers.canv
55import {
66 callback as call , valueOrDefault , toFont ,
77 toPadding , getRtlAdapter , overrideTextDirection , restoreTextDirection ,
8- clipArea , unclipArea
8+ clipArea , unclipArea , _isBetween
99} from '../helpers/index' ;
1010import { _toLeftRightCenter , _alignStartEnd , _textX } from '../helpers/helpers.extras' ;
1111import { toTRBLCorners } from '../helpers/helpers.options' ;
@@ -493,13 +493,15 @@ export class Legend extends Element {
493493 _getLegendItemAt ( x , y ) {
494494 let i , hitBox , lh ;
495495
496- if ( x >= this . left && x <= this . right && y >= this . top && y <= this . bottom ) {
496+ if ( _isBetween ( x , this . left , this . right )
497+ && _isBetween ( y , this . top , this . bottom ) ) {
497498 // See if we are touching one of the dataset boxes
498499 lh = this . legendHitBoxes ;
499500 for ( i = 0 ; i < lh . length ; ++ i ) {
500501 hitBox = lh [ i ] ;
501502
502- if ( x >= hitBox . left && x <= hitBox . left + hitBox . width && y >= hitBox . top && y <= hitBox . top + hitBox . height ) {
503+ if ( _isBetween ( x , hitBox . left , hitBox . left + hitBox . width )
504+ && _isBetween ( y , hitBox . top , hitBox . top + hitBox . height ) ) {
503505 // Touching an element
504506 return this . legendItems [ i ] ;
505507 }
0 commit comments