Skip to content

Fix numeric customdata in Graph events - #4076

Open
monsterlag wants to merge 2 commits into
plotly:devfrom
monsterlag:fix/issue-3196-efb8
Open

monsterlag wants to merge 2 commits into
plotly:devfrom
monsterlag:fix/issue-3196-efb8

Conversation

@monsterlag

Copy link
Copy Markdown

Note

AI-generated, not reviewed by a human. This pull request was written by an AI coding agent and then checked by a separate AI review agent, which re-ran the tests described below. No human has reviewed the code. It is submitted by @monsterlag, who runs these agents. If that does not fit how you want to receive contributions, please feel free to close it.

Fixes #3196.

Numeric NumPy and pandas customdata can be sent by Plotly.py as binary array objects. Graph indexed those objects instead of their decoded values, dropping customdata from callback event data.

Use Plotly.js's cached decoded array and convert typed-array values to plain arrays before serialization. This preserves scalar and row-valued data in click, hover and selection events without changing plain-list handling.

Add browser coverage for Scatter and Scattergl, including a nonzero trace index, and restore the pie customdata regression test.

Testing

  • python -m pytest components/dash-core-components/tests/integration/graph/test_graph_basics.py --headless -xvs: 22 passed with Plotly.py 7.1.0. Before rebuilding with the fix, the focused customdata tests had 5 failures and 4 passing list controls.
  • python -m pytest components/dash-core-components/tests/integration/graph/test_graph_basics.py -k 'grbs005 or grbs007 or grbs013' --headless -xvs: 10 passed with Plotly.py 6.0.1.
  • python -m pytest tests/unit: 729 passed, 6 skipped.
  • python -m pytest tests/compliance/: 54 passed, 1 skipped.
  • In components/dash-core-components: npm run test:jest -- --runInBand (85 passed) and npm run lint (passed, with existing warnings in unrelated files).
  • Changed-file pylint, flake8, Black, ESLint and Prettier checks passed, including the pre-commit hook.

Contributor Checklist

  • I have run the tests locally and they passed. (refer to testing section in contributing) (done by the AI agents, not by a human)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR (done by the AI agents, not by a human)

@KoolADE85

Copy link
Copy Markdown
Contributor

Thanks for the PR! We'll take a closer look and follow up.

@T4rk1n T4rk1n left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reading the decoded array from _inputArray and converting typed arrays before serialization covers scalar, row and 3D customdata, and plain lists still go through the same code as before. Re-enabling grbs005 and checking against all of pointNumbers is a good tightening. Two small asks, neither blocking: can you add a CHANGELOG entry under Fixed for #3196, and swap the hand-rolled wait in grbs005 for the helper (inline)?

assert data != "", "graph clickData must contain data"

data = json.loads(data)
wait.until(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you use dash_dcc.wait_for_contains_text("#text-area", '"points"') here instead of wait.until on find_element? contains_text already checks the textarea value. The raw find_element inside until can throw a stale element error if the Textarea re-renders between the lookup and the read, and we've seen that flake elsewhere in the suite.

@camdecoster

Copy link
Copy Markdown
Contributor

I'd rather not rely on private variables if possible. fullPoint.fullData.customdata would be one option to access this data.

Use fullPoint.fullData.customdata, where plotly.js has decoded binary
arrays, instead of the private _inputArray cache, and always convert
typed arrays to plain arrays. Use wait_for_contains_text in grbs005 and
add the CHANGELOG entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wm7kczaxb2ShcgbbmUx6fa
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@monsterlag

Copy link
Copy Markdown
Author

Thanks @T4rk1n and @camdecoster. I pushed e16f1d3:

  • It now reads fullPoint.fullData.customdata (falling back to the input trace) instead of the private _inputArray. It still converts typed arrays to plain arrays, so they serialize as lists.
  • grbs005 now uses wait_for_contains_text("#text-area", ...).
  • Added a CHANGELOG entry under Fixed.

All of test_graph_basics.py passes locally (22 tests), including the list/numpy × scalar/row × scatter/scattergl cases.

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.

customdata is missing in clickData for Scattergl objects

4 participants