echarts icon indicating copy to clipboard operation
echarts copied to clipboard

scroll event may prevent after use inside dataZoom

Open hhshii opened this issue 5 years ago • 41 comments

Version

4.2.1-rc.3

Reproduction link

https://codepen.io/gfwer/pen/maJGNz

Steps to reproduce

  1. add an inside dataZoom(in this instance I set zoomOnMouseWheel:'shift')
  2. mouse hover in the chart grid and scroll the mouse

What is expected?

page scroll

What is actually happening?

scroll event may prevent , I can 't scroll page when I move mouse over the chart grid

hhshii avatar Mar 11 '19 04:03 hhshii

Hi! We've received your issue and please be patient to get responded. 🎉 The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer.

Have a nice day! 🍵

echarts-bot[bot] avatar Mar 11 '19 04:03 echarts-bot[bot]

It's a bad experience if the page will scroll when you do zooming on the chart. If you still want to, you can set http://echarts.apache.org/option.html#dataZoom-inside.preventDefaultMouseMove to false

pissang avatar Mar 11 '19 04:03 pissang

@pissang I've set it in this instance

hhshii avatar Mar 11 '19 04:03 hhshii

@pissang I've update the code codepen even I set preventDefaultMouseMove to false,it still can 't scroll page

hhshii avatar Mar 12 '19 06:03 hhshii

This problem still seems to exist on 4.2.1 (but works fine on 4.1.0), I can't scrll page when the mouse hover in grid, here is my DataZoom option:

	{
		type: 'inside',
        zoomOnMouseWheel:'shift',
		preventDefaultMouseWheel: false
	}

A CodePen here

It seems event is stopped by eventTool.stop(e.event)

hhshii avatar Apr 12 '19 16:04 hhshii

@GFwer Has any solutions so far ?

FengHuangDong avatar Aug 02 '19 08:08 FengHuangDong

@GFwer Has any solutions so far ?

No, I have to revert to the old version...

hhshii avatar Aug 02 '19 09:08 hhshii

Is there any quick solution for this issue? It results in very very bad user experience!

easyremember avatar Aug 05 '19 14:08 easyremember

I face also the same problem and preventDefaultMouseWheel: false didn't help. Any Update ?

ahmadordi avatar Sep 16 '19 08:09 ahmadordi

I tried the latest version of echarts(4.5), and the problem is still exist

hhshii avatar Dec 06 '19 11:12 hhshii

Any workarounds?

shv-a avatar Apr 29 '20 07:04 shv-a

We are having the same issue.

nodesmichael avatar May 22 '20 13:05 nodesmichael

+1

55cc avatar Jun 09 '20 06:06 55cc

+1

Amanda1995pig avatar Jul 01 '20 07:07 Amanda1995pig

Any update ?

ahmadordi avatar Aug 19 '20 13:08 ahmadordi

+1

rong12345 avatar Nov 23 '20 02:11 rong12345

+1

techistoner avatar Dec 07 '20 02:12 techistoner

+1

Orangat avatar Feb 04 '21 16:02 Orangat

@pissang This appears to still be an issue in V5.

Preventing page scrolling, while having set a MODIFIER key for zoom - is a bad experience. At the very least this documented property should do as it describes.

Any chance we can get a fix in place?

cadriel avatar Feb 23 '21 19:02 cadriel

Hi, Any luck? I also need the same functionality where, I disable mouse wheel on the chart so that the page scroll should happen. I tried preventDefaultMouseMove and various other combinations available under the dataZoom options, but none of them seem to allow page scroll.

vkjv avatar Mar 08 '21 12:03 vkjv

Same here... :( http://iamferraz.com.br/gantt (click on toggle data zoom)

mfandre avatar Mar 23 '21 16:03 mfandre

更新最新版本echarts应该也可以解决,但是基于现有开发内容我做了如下操作: 更新至echarts4.9.0 (https://raw.githubusercontent.com/apache/echarts/4.9.0/dist/echarts.js) 替换src/Echarts/tpl.html中script标签中内容为上面echarts.js内容即可升级完成 配置如下: dataZoom: [ { id: 'dataZoomX', xAxisIndex: [0], type:'inside', moveOnMouseMove: true,//zoom后横向滑动 preventDefaultMouseMove: false, } ]

techistoner avatar Apr 01 '21 06:04 techistoner

any update? I meet the same problem

HUANGChaoLi avatar May 30 '21 05:05 HUANGChaoLi

+1 Same problem!

pooria-h avatar Oct 29 '21 20:10 pooria-h

Hello all,

I had the same problem but found the following work-around (or hack). The snipped is from Angular code; this.parentNativeElement points to the parent element that needs to scroll.

    this.chart.nativeElement.querySelector("canvas").onwheel = (event) => {
      if (!event.ctrlKey) {
        this.parentNativeElement.scrollBy(0, event.deltaY);
      }
    };

Almar avatar Dec 09 '21 10:12 Almar

@Almar

Nice job

On a Vue.js app:

const canvas = this.$refs.nameOfTheComponent.$el.childNodes[0].children[0];
canvas.onwheel = (event) => {
  if (!event.ctrlKey) {
    window.scrollBy(0, event.deltaY);
  }
};

pooria-h avatar Dec 09 '21 14:12 pooria-h

@Almar @pooria-h Any similar workaround for html/javascript?

Maazaowski avatar Dec 13 '21 18:12 Maazaowski

@Maazaowski, Yes, you can also solve the problem when using html/javascript. It is a workaround, so we're not solving the underlying problem. The mouse events are captured by the graph, which causes the problem. The workaround is basically a bypass – subscribing to the mouse events of the canvas element and then feeding them into the scroll container (the/a parent element of the graph).

To implement it yourself you’ll need to find a reference to the canvas element and the ‘scroll container’ (the parent element of the graph that needs to scroll). Your code should look something like the following (please mind that I did not test it).

Let scrollContainer = document.querySelector(“div#scrollcontainer”)
Let canvasElement = scrollContainer.querySelector(“canvas”);
canvasElement.onwheel = (event) => {
      if (!event.ctrlKey) {
        scrollContainer.scrollBy(0, event.deltaY);
      }
    };

Almar avatar Dec 14 '21 08:12 Almar

Problem still there in v 5.3.1 !

agardiol avatar Mar 15 '22 11:03 agardiol

Problem still there in v 5.3.1 !

+1 in 5.3.0

qingxiao avatar Mar 16 '22 12:03 qingxiao