christophkowatschik-create commented on issue #10079:
URL: https://github.com/apache/echarts/issues/10079#issuecomment-7100955560

   Hope you guys will bear with me, as I've never worked with topics like this 
before. I'm using openHAB with ECharts, and this particular behaviour is really 
annoying. ;-)
   
   Initially, I assumed the problem was somewhere in my own chart 
configuration. However, after quite a bit of troubleshooting with the help of 
ChatGPT, I ended up here.
   
   The following investigation and proposed solution are **not my personal 
technical contribution**. They were worked out with ChatGPT, and I haven't 
independently verified the proposed code changes. I thought I'd share the 
findings anyway, in case someone with more experience finds them useful, wants 
to develop the idea further, or simply concludes that the approach isn't 
appropriate.
   
   ### What we found
   
   I'm using ECharts 5.6.0 through openHAB 5.2.3, with an `inside` dataZoom 
configured as follows:
   
   ```javascript
   zoomOnMouseWheel: 'shift',
   moveOnMouseWheel: false,
   moveOnMouseMove: false,
   preventDefaultMouseMove: false
   ```
   
   The expected behaviour is straightforward:
   
   - Normal mouse wheel: scroll the surrounding page.
   - Shift + mouse wheel: zoom the chart around the current mouse position.
   
   Unfortunately, normal scrolling is blocked whenever the mouse pointer is 
over the chart.
   
   Using Chrome DevTools, we confirmed that wheel events are cancelled even 
when Shift is not pressed (`defaultPrevented === true`).
   
   The debugger also showed that the shared `RoamController` receives these 
effective options:
   
   ```javascript
   {
       zoomOnMouseWheel: true,
       moveOnMouseMove: true,
       moveOnMouseWheel: true,
       preventDefaultMouseMove: false
   }
   ```
   
   ### Possible explanation
   
   Looking at the ECharts source with ChatGPT, the following appears to explain 
the behaviour:
   
   In `src/component/dataZoom/roams.ts`, `mergeControllerParams()` enables all 
three interaction types on the shared `RoamController`.
   
   In `src/component/helper/RoamController.ts`, the wheel event can then be 
cancelled through `eventTool.stop(e.event)` before the individual dataZoom 
listener checks whether the configured interaction is actually permitted.
   
   Consequently, ECharts may correctly reject a zoom operation because Shift 
isn't pressed, but the browser's normal page scrolling has already been 
prevented.
   
   This also seems consistent with the findings reported in the previous 
comments.
   
   ### Possible solution
   
   The suggestion from ChatGPT is to defer cancelling the browser's wheel event 
until the individual dataZoom configurations have been checked.
   
   In principle:
   
   1. Keep the existing shared `RoamController` architecture.
   2. Determine whether at least one associated dataZoom accepts the current 
wheel interaction, including its modifier-key requirements.
   3. Only call `preventDefault()` when an interaction is actually accepted.
   4. Otherwise, leave the browser's native scrolling behaviour untouched.
   
   A simplified illustration of the idea:
   
   ```typescript
   // Conceptual pseudocode only — not tested or a drop-in patch
   
   let interactionAccepted = false;
   
   coordSysRecord.dataZoomInfoMap.each((dzInfo) => {
       if (
           event.isAvailableBehavior(dzInfo.model.option) &&
           !dzInfo.model.get('disabled', true)
       ) {
           interactionAccepted = true;
           // Existing interaction handling
       }
   });
   
   if (interactionAccepted) {
       // Prevent native scrolling and handle the chart interaction
   }
   ```
   
   Obviously, this would need proper integration into the event-handling code 
and testing, particularly when multiple dataZoom components share a controller. 
It should also preserve the existing mouse-position-based zoom behaviour and 
avoid changing unrelated chart interactions.
   
   Again, **this is only a suggested approach generated with ChatGPT**, not an 
implemented or tested patch.
   
   Perhaps someone familiar with the ECharts internals could comment on whether 
this makes sense, or whether there is a better way to address the issue.
   
   I'd be happy if the investigation is useful to someone, even if the 
suggested solution turns out to be completely wrong. ;-)
   
   Thanks to everyone working on ECharts!
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to