MCPcopy
hub / github.com/chartjs/Chart.js / _getLegendItemAt

Method _getLegendItemAt

src/plugins/plugin.legend.js:503–522  ·  view source on GitHub ↗

* @private

(x, y)

Source from the content-addressed store, hash-verified

501 * @private
502 */
503 _getLegendItemAt(x, y) {
504 let i, hitBox, lh;
505
506 if (_isBetween(x, this.left, this.right)
507 && _isBetween(y, this.top, this.bottom)) {
508 // See if we are touching one of the dataset boxes
509 lh = this.legendHitBoxes;
510 for (i = 0; i < lh.length; ++i) {
511 hitBox = lh[i];
512
513 if (_isBetween(x, hitBox.left, hitBox.left + hitBox.width)
514 && _isBetween(y, hitBox.top, hitBox.top + hitBox.height)) {
515 // Touching an element
516 return this.legendItems[i];
517 }
518 }
519 }
520
521 return null;
522 }
523
524 /**
525 * Handle an event

Callers 1

handleEventMethod · 0.95

Calls 1

_isBetweenFunction · 0.85

Tested by

no test coverage detected