Skip to content

Commit

Permalink
Merge pull request #5 from ikkala/4.x
Browse files Browse the repository at this point in the history
 Don't trigger the zoom on legends area
  • Loading branch information
trullock authored Oct 1, 2024
2 parents f2fb4bb + b9b5165 commit d219258
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/handlers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {directionEnabled, debounce, keyNotPressed, getModifierKey, keyPressed} from './utils';
import {zoom, zoomRect} from './core';
import {callback as call, getRelativePosition} from 'chart.js/helpers';
import {callback as call, getRelativePosition, _isPointInArea} from 'chart.js/helpers';
import {getState} from './state';

function removeHandler(chart, type) {
Expand Down Expand Up @@ -58,6 +58,12 @@ function zoomStart(chart, event, zoomOptions) {
}

export function mouseDown(chart, event) {
const rect = event.target.getBoundingClientRect();
const offsetX = event.clientX - rect.left;
const offsetY = event.clientY - rect.top;
if (chart.legend && _isPointInArea({x: offsetX, y: offsetY}, chart.legend)) {
return;
}
const state = getState(chart);
const {pan: panOptions, zoom: zoomOptions = {}} = state.options;
if (
Expand Down

0 comments on commit d219258

Please sign in to comment.