Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust dataZoom behavior based on mouse hover position: differentiate between chart and y-axis hover #578

Open
23andreas opened this issue Nov 2, 2024 · 0 comments

Comments

@23andreas
Copy link

23andreas commented Nov 2, 2024

I want to configure the component's scrolling behavior to adapt based on where the mouse is hovering:

  • When the mouse hovers over the main chart area: Scrolling the mouse wheel should zoom in and out horizontally, adjusting the x-axis range.
  • When the mouse hovers over a y-axis: Scrolling the mouse wheel should zoom in and out on that specific y-axis, adjusting only its range.

My chart includes multiple y-axes, so I need the scrolling to only affect the y-axis that the mouse is directly hovering over, without impacting other y-axes.

Current Approach:

Currently, I’m trying to achieve this by creating two separate dataZoom configurations and activating/deactivating them based on mouse hover events. I’ve also noticed that dataZoom can target individual y-axes using the yAxisIndex property

When hovering a yAxis

    dataZoom: [
      {
        type: 'inside',
        orient: 'vertical',
        filterMode: 'none',
        yAxisIndex: <y axis currenlty being hovered>,
      }
    ]

When hovering the main chart

    dataZoom: [
      {
        type: 'inside',
        orient: 'horizontal',
        filterMode: 'none',
     }
    ]

However, I’m encountering some issues with this approach, using yAxis.triggerEvent, hover events are only triggered when the mouse is over the y-axis value labels, not over the entire axis line or area.

Question:
Is there a more effective way to detect hover on the entire y-axis, not just the value labels? Alternatively, is there a better approach to achieve the desired behavior without relying on these hover events?

Any guidance or suggestions would be appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant