* Handle an event * @param {ChartEvent} e - The event to handle
(e)
| 526 | * @param {ChartEvent} e - The event to handle |
| 527 | */ |
| 528 | handleEvent(e) { |
| 529 | const opts = this.options; |
| 530 | if (!isListened(e.type, opts)) { |
| 531 | return; |
| 532 | } |
| 533 | |
| 534 | // Chart event already has relative position in it |
| 535 | const hoveredItem = this._getLegendItemAt(e.x, e.y); |
| 536 | |
| 537 | if (e.type === 'mousemove' || e.type === 'mouseout') { |
| 538 | const previous = this._hoveredItem; |
| 539 | const sameItem = itemsEqual(previous, hoveredItem); |
| 540 | if (previous && !sameItem) { |
| 541 | call(opts.onLeave, [e, previous, this], this); |
| 542 | } |
| 543 | |
| 544 | this._hoveredItem = hoveredItem; |
| 545 | |
| 546 | if (hoveredItem && !sameItem) { |
| 547 | call(opts.onHover, [e, hoveredItem, this], this); |
| 548 | } |
| 549 | } else if (hoveredItem) { |
| 550 | call(opts.onClick, [e, hoveredItem, this], this); |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | function calculateItemSize(boxWidth, labelFont, ctx, legendItem, _itemHeight) { |
no test coverage detected