Open hugo-valcourt opened 1 year ago
Maybe args.inChartArea could be usefull ?
/**
* @desc Called before processing the specified `event`. If any plugin returns `false`,
* the event will be discarded.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {ChartEvent} args.event - The event object.
* @param {boolean} args.replay - True if this event is replayed from `Chart.update`
* @param {boolean} args.inChartArea - The event position is inside chartArea
* @param {object} options - The plugin options.
*/
beforeEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean, cancelable: true, inChartArea: boolean }, options: O): boolean | void;
/**
* @desc Called after the `event` has been consumed. Note that this hook
* will not be called if the `event` has been previously discarded.
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {ChartEvent} args.event - The event object.
* @param {boolean} args.replay - True if this event is replayed from `Chart.update`
* @param {boolean} args.inChartArea - The event position is inside chartArea
* @param {boolean} [args.changed] - Set to true if the plugin needs a render. Should only be changed to true, because this args object is passed through all plugins.
* @param {object} options - The plugin options.
*/
afterEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean, changed?: boolean, cancelable: false, inChartArea: boolean }, options: O): void;
Zoom can be trigger outside of the data region, into the Axis and Legend
"chart.js": "^4.2.0" "chartjs-plugin-zoom": "^2.0.0"
You can reproduce this on your website here : https://www.chartjs.org/chartjs-plugin-zoom/latest/samples/drag/category.html
On your example in the URL, try to zoom with a drag into the yAxis or the legend, the zoom will trigger.
Movie : https://user-images.githubusercontent.com/39559391/217556340-2b8fed1a-0344-40eb-a7f8-25f3d3f3961d.mov
Maybe related to https://github.com/chartjs/chartjs-plugin-zoom/issues/611 ?