Skip to content

Conversation

@emilykl
Copy link
Contributor

@emilykl emilykl commented Oct 27, 2025

Closes #7607

Some logic in a helper function was not updated to handle typed arrays, causing a regression in customdata behavior in Plotly.js and Plotly.py.

As described in the linked issue, this bug made it impossible to reference a 2D customdata array passed from Plotly.py in the heatmap hover template, when previously that was possible.

On the Plotly.js level, the 2D customdata array passed from Plotly.py was translated into a JavaScript Array containing two JavaScript typed arrays, like this: [new Float64Array([101,103]), new Float64Array([102,104])]

That specific data structure was not handled properly by the getPointData() function which retrieves values to insert into the hovertemplate.

Note: most of the diff in this PR is due to the Biome formatter. Check the second commit for the meaningful change.

How to test

  1. Create a plot using the following code:
var data = [{
            z: [[1,3],[2,4]],
            customdata: [new Float64Array([101,103]), new Float64Array([102,104])], 
            hovertemplate: '<b>z: %{z:.3f}</b><br>custom: %{customdata:.3f}',
            type: 'heatmap',
        }];
        var layout = {
            title: {text: 'Heatmap customdata'},
        };
        Plotly.newPlot('plot', data, layout);
  1. On this branch, it works as expected: customdata is shown in hover tooltip
Screenshot 2025-10-27 at 10 21 53 AM
  1. On master (and Plotly.js >=3.0), it's broken: customdata is not found by hover tooltip and template is shown instead
Screenshot 2025-10-27 at 10 23 26 AM

Copy link
Contributor

@camdecoster camdecoster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. Could you please add a test for getPointData with a typed array? Also, could you please add a draftlog?

@emilykl
Copy link
Contributor Author

emilykl commented Oct 27, 2025

@camdecoster Done -- draftlog and tests added. I've added 2 tests; the first passes already on master, but the second fails on master and passes on this branch.

@emilykl emilykl merged commit 3767140 into master Oct 27, 2025
6 checks passed
@emilykl emilykl deleted the fix-typed-array-hoverdata branch October 27, 2025 19:57
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.

Heatmap customdata needs to be 3D in Plotly>=6.0.0

2 participants