Skip to content

fix(heatmap): add eventData handler for proper click event data#7920

Open
ubertidavide wants to merge 1 commit into
plotly:masterfrom
ubertidavide:fix-heatmap-click-data
Open

fix(heatmap): add eventData handler for proper click event data#7920
ubertidavide wants to merge 1 commit into
plotly:masterfrom
ubertidavide:fix-heatmap-click-data

Conversation

@ubertidavide

@ubertidavide ubertidavide commented Jul 24, 2026

Copy link
Copy Markdown

Description

When interacting with heatmaps, the standard plotly_click event previously lacked properly formatted 2D matrix indices and explicit z values. This made it difficult for downstream wrappers (such as Streamlit or Marimo) to identify the exact clicked cell natively.

Architecture Note: plotly_click vs plotly_heatmapclick

While introducing a trace-specific event like plotly_heatmapclick (similar to plotly_treemapclick or plotly_sunburstclick) was originally discussed in #7685, doing so for heatmaps is an anti-pattern. Heatmaps are Cartesian trace types that reside on standard 2D Cartesian subplots. Introducing trace-specific click events on Cartesian subplots breaks consistency across Cartesian traces. The correct architectural approach is to rely on the standard plotly_click event and delegate trace-specific payload formatting to a dedicated eventData handler.

Summary of Changes

This PR introduces the missing eventData handler for the heatmap trace:

  • pointNumber and pointIndex are properly exposed as a 2D array [row, col].
  • z values are explicitly attached to the event payload.

This PR completes and supersedes #7686 (which was stalled). Unlike #7686, this implementation cleanly exposes the 2D pointNumber: [row, col] matrix indices and z values via eventData without modifying hover.js (avoiding category axis regressions), and includes complete Jasmine unit tests.

Closes #7685.

Testing

  • Added regression tests in test/jasmine/tests/heatmap_test.js to verify that standard plotly_click events emit 2D pointNumber and z values.
  • Ran Jasmine test suite (npm run test-jasmine -- test/jasmine/tests/heatmap_test.js) with 51/51 specs passing successfully.

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]: Add plotly_heatmapclick event (similar to plotly_treemapclick / plotly_sunburstclick)

1 participant