Skip to content

Enable Hover and Click Events Anywhere#7707

Open
alexshoe wants to merge 4 commits intoplotly:masterfrom
alexshoe:hover-click-events-anywhere
Open

Enable Hover and Click Events Anywhere#7707
alexshoe wants to merge 4 commits intoplotly:masterfrom
alexshoe:hover-click-events-anywhere

Conversation

@alexshoe
Copy link
Contributor

@alexshoe alexshoe commented Feb 12, 2026

Description:

Added 2 new boolean attributes to the layour object: hoveranywhere and clickanywhere, which respectively allow plotly_hover and plotly_click events to be received anywhere in the plot area and not just over traces.

When hovering/clicking on empty space and with no nearby trace, the events will fire with an empty points array but includes xvals, yvals, xaxes, and yaxes so you still get cursor coordinates in data space. When hovering/clicking over a trace, the event behaves as before with full point data.

Example:

layout: {
  hoveranywhere: true, // enables hover events anywhere, even on empty plotting area
  clickanywhere: true // same for click events
}

See this codepen for an interactive demo of this feature

Screenshot 2026-02-13 at 1 19 35 PM

New API:

hoveranywhere

  • Type: boolean
  • Default: false
  • When true, plotly_hover events fire for any cursor position within the plot area, not just over traces. Events on empty space include an empty points array plus xvals and yvals with cursor coordinates in data space.

clickanywhere

  • Type: boolean
  • Default: false
  • When true, plotly_click events fire for any click position within the plot area, not just over traces. Events on empty space include an empty points array plus xvals and yvals with click coordinates in data space.

@alexshoe alexshoe requested a review from emilykl February 13, 2026 18:20
@alexshoe alexshoe linked an issue Feb 13, 2026 that may be closed by this pull request
@alexshoe alexshoe marked this pull request as ready for review February 13, 2026 18:20
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

Successfully merging this pull request may close these issues.

[FEATURE]: Enable click and hover events anywhere

1 participant