Skip to content

Commit

Permalink
Don't trigger the zoom on legends area
Browse files Browse the repository at this point in the history
Fixes #256
  • Loading branch information
ikkala committed Jul 14, 2023
1 parent bfd207d commit b9b5165
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 b9b5165

Please sign in to comment.