Title: [FEATURE]: Enable click and hover events anywhere · Issue #7699 · plotly/plotly.js · GitHub
Open Graph Title: [FEATURE]: Enable click and hover events anywhere · Issue #7699 · plotly/plotly.js
X Title: [FEATURE]: Enable click and hover events anywhere · Issue #7699 · plotly/plotly.js
Description: Summary As part of an ongoing Plotly Professional Services contract, Kobold Metals has requested multiple feature requests/bug fixes for Plotly.js. One of these feature requests is the ability to enable hover and click events anywhere on...
Open Graph Description: Summary As part of an ongoing Plotly Professional Services contract, Kobold Metals has requested multiple feature requests/bug fixes for Plotly.js. One of these feature requests is the ability to e...
X Description: Summary As part of an ongoing Plotly Professional Services contract, Kobold Metals has requested multiple feature requests/bug fixes for Plotly.js. One of these feature requests is the ability to e...
Opengraph URL: https://github.com/plotly/plotly.js/issues/7699
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[FEATURE]: Enable click and hover events anywhere","articleBody":"# Summary\n\nAs part of an ongoing Plotly Professional Services contract, Kobold Metals has requested multiple feature requests/bug fixes for Plotly.js. One of these feature requests is the ability to enable hover and click events anywhere on the plot area, not just directly over trace data points.\n\nThis feature enhancement would be useful for:\n- Creating custom spikelines or crosshairs that track cursor position across the entire plot\n- Clicking on layout images (e.g., drill hole images) to determine coordinates/depth at the click location\n- Distance measurement between two arbitrary points\n\n# Problem Statement\n\nCurrently, Plotly.js hover and click events (`plotly_hover`, `plotly_click`) only fire when the cursor is directly over a trace data point. The events do not fire when the cursor is in empty plot space between data points.\n\n**Key Decision:** How should we expose this functionality, and what should the event data contain when no trace is under the cursor?\n\n# Proposed Solution\n\n### API\n\nAdd two new opt-in boolean layout attributes. Both would default to `false`.\n\n```js\nlayout: {\n hoveranywhere: true,\n clickanywhere: true\n}\n```\n\n### Details\n- Use existing `plotly_hover` and `plotly_click` events\n- Need some sort of throttling/limiting number of events to prevent performance overload\n\n# Implementation Plan (with rough timeline)\n\n1. Add attributes and defaults (Week 1)\n - Add `hoveranywhere` and `clickanywhere` attributes to `src/components/fx/layout_attributes.js`\n - Add default value coercion in `src/components/fx/layout_defaults.js`\n\n2. Modify hover logic (Week 1-2)\n - In `src/components/fx/hover.js`, modify the `_hover()` function\n - When `hoverData` is empty but `hoveronanywhere` is true, emit event with cursor coordinates\n\n3. Modify click logic (Week 2-3)\n - In `src/components/fx/click.js`, add handling for `clickonanywhere`\n - Calculate click coordinates in data space even when no trace is hit\n\n4. Testing (Week 3)\n - Write mock and Jasmine tests for this feature\n\n# Questions + Things to consider\n\n1. Should we use new event names (`plotly_hover_anywhere`) or reuse existing events?\n2. Should `clickonanywhere` also affect double-click events?\n3. Multiple subplots: I believe events should not fire when over the gaps between subplots, right? Same with being outside the plot area of a single-plot figure'\n4. Multiple overlaid axes: do we show the values of both/all axes at the same position?","author":{"url":"https://github.com/alexshoe","@type":"Person","name":"alexshoe"},"datePublished":"2026-01-28T22:04:53Z","url":"https://github.com/plotly/plotly.js/issues/7699"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bf7c8020-6466-64ab-748a-cbe288224cdb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 988A:36A3E:DB290D:1257AAA:6B01053F |
| html-safe-nonce | 9ba650455ba48dbd6df315c5df637b1cd397743613cd53b139bf509cf4b66f84 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODhBOjM2QTNFOkRCMjkwRDoxMjU3QUFBOjZCMDEwNTNGIiwidmlzaXRvcl9pZCI6IjI0NzM1NDM5ODYyMjA5NTkwMzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1813b9d28abc04773f4ec5a1a93e3fc7dfb01c3fcbfab70e1d017e298e9c0e5d |
| hovercard-subject-tag | issue:3867643709 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.js/7699/issue_layout |
| twitter:image | https://opengraph.githubassets.com/be2ad7b447217c22d1e6797aa549b508f73f1f36971eb1c9d2f3024b34d3f392/plotly/plotly.js/issues/7699 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/be2ad7b447217c22d1e6797aa549b508f73f1f36971eb1c9d2f3024b34d3f392/plotly/plotly.js/issues/7699 |
| og:image:alt | Summary As part of an ongoing Plotly Professional Services contract, Kobold Metals has requested multiple feature requests/bug fixes for Plotly.js. One of these feature requests is the ability to e... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexshoe |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.js git https://github.com/plotly/plotly.js.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 45646037 |
| octolytics-dimension-repository_nwo | plotly/plotly.js |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 45646037 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.js |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width