chartjs-plugin-zoom icon indicating copy to clipboard operation
chartjs-plugin-zoom copied to clipboard

Allow normal touch scroll when pan.mode = 'x'

Open NicolasGoeddel opened this issue 4 years ago • 3 comments

Hi,

when viewing graphs on a small touch screen like on a smartphone with pan.mode set to x, the canvas always grabs the up-down scroll events even though it should only react on left-right swipes.

Can this be configured?

NicolasGoeddel avatar Mar 15 '20 11:03 NicolasGoeddel

Try add this code after here.

mc.set({touchAction: 'pan-y'})

ttakuru88 avatar Apr 07 '21 08:04 ttakuru88

I solved it by overwriting touch-action: none; with touch-action: pan-y;. touch-action: none; is inline style that is added to canvas element.

const myChart = new Chart(ctx, {
  ...
});
// add for overwrite inline style.
myChart.canvas.style.touchAction = "pan-y";

It's not a radical solution, but so far it has met the demands. Please open the link below on your smartphone and give it a try.

https://56hhd.csb.app/

I used vue.js, but I'll include sample code just in case.

https://codesandbox.io/s/chartjs-plugin-zoom-touch-scroll-y-56hhd?file=/src/components/ChartLine.vue

gombeedoe avatar Oct 28 '21 10:10 gombeedoe

Both solutions mess up the tooltip functionality and hiding series through the legend. Any idea how to also fix those while keeping vertical scrolling?

mano3m avatar Jan 06 '22 20:01 mano3m