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

Method handleEvent

src/plugins/plugin.legend.js:528–552  ·  view source on GitHub ↗

* Handle an event * @param {ChartEvent} e - The event to handle

(e)

Source from the content-addressed store, hash-verified

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
555function calculateItemSize(boxWidth, labelFont, ctx, legendItem, _itemHeight) {

Callers 9

opacity.jsFile · 0.45
corner-radius.jsFile · 0.45
point-style.jsFile · 0.45
box-padding.jsFile · 0.45
positioning.jsFile · 0.45
caret-position.jsFile · 0.45
afterEventFunction · 0.45

Calls 3

_getLegendItemAtMethod · 0.95
isListenedFunction · 0.85
itemsEqualFunction · 0.85

Tested by

no test coverage detected