fix(heatmap): add eventData handler for proper click event data#7920
Open
ubertidavide wants to merge 1 commit into
Open
fix(heatmap): add eventData handler for proper click event data#7920ubertidavide wants to merge 1 commit into
ubertidavide wants to merge 1 commit into
Conversation
Open
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When interacting with heatmaps, the standard
plotly_clickevent previously lacked properly formatted 2D matrix indices and explicitzvalues. This made it difficult for downstream wrappers (such as Streamlit or Marimo) to identify the exact clicked cell natively.Architecture Note:
plotly_clickvsplotly_heatmapclickWhile introducing a trace-specific event like
plotly_heatmapclick(similar toplotly_treemapclickorplotly_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 standardplotly_clickevent and delegate trace-specific payload formatting to a dedicatedeventDatahandler.Summary of Changes
This PR introduces the missing
eventDatahandler for the heatmap trace:pointNumberandpointIndexare properly exposed as a 2D array[row, col].zvalues 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 andzvalues viaeventDatawithout modifyinghover.js(avoiding category axis regressions), and includes complete Jasmine unit tests.Closes #7685.
Testing
test/jasmine/tests/heatmap_test.jsto verify that standardplotly_clickevents emit 2DpointNumberandzvalues.npm run test-jasmine -- test/jasmine/tests/heatmap_test.js) with 51/51 specs passing successfully.