fix(plotly): extract z-bbox from point.bbox.z, not point.bbox.y#6759
Open
anxkhn wants to merge 2 commits into
Open
fix(plotly): extract z-bbox from point.bbox.z, not point.bbox.y#6759anxkhn wants to merge 2 commits into
anxkhn wants to merge 2 commits into
Conversation
The injected extractPoints helper built the bbox z-extent from point.bbox.y0/y1 instead of point.bbox.z0/z1, a copy-paste of the two lines above it. As a result, on_hover/on_click/on_unhover event data for 3D traces reported a z0/z1 that always duplicated the y-extent, and the real z bounding box was unreachable. The BBox TypedDict already declares z0/z1 as fields distinct from y0/y1, so this only corrects the generated JavaScript. 2D traces are unaffected: their point.bbox carries no z fields, so the keys are still dropped by removeUndefined. Add a regression test asserting the generated helper sources z0/z1 from point.bbox.z0/point.bbox.z1. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Contributor
Greptile SummaryThis PR changes how Plotly event bounding boxes obtain their z fields. The main changes are:
Confidence Score: 4/5The gl3d event extraction path still cannot return z bounding-box values.
packages/reflex-components-plotly/src/reflex_components_plotly/plotly.py and tests/units/components/graphing/test_plotly.py Important Files Changed
Reviews (1): Last reviewed commit: "chore(plotly): add changelog fragment fo..." | Re-trigger Greptile |
Merging this PR will not alter performance
Comparing Footnotes
|
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.
All Submissions:
Type of change
Changes To Core Features:
The client-side
extractPointshelper injected byrx.plotly(
packages/reflex-components-plotly/src/reflex_components_plotly/plotly.py, inadd_custom_code()) reshapes each plotly.js hover/click point into reflex'sPoint/BBoxshape before it is sent to the Pythonon_hover/on_click/on_unhoverevent handlers. When it builds the bounding box, the
z0/z1members were copied fromthe y fields:
so for 3D traces (
scatter3d/mesh3d/surface) the reportedbbox.z0/bbox.z1always duplicated the y-extent, and the real z bounding box was never surfaced. This is a
copy-paste typo: the two lines are identical to the
y0/y1lines above them except forthe destination key. reflex's own contract confirms the intent, the
BBoxTypedDictdeclares
z0/z1as fields distinct fromy0/y1, andPointhas azfield.The fix sources them from the matching z fields:
2D traces are unaffected: their
point.bboxhas no z fields, soremoveUndefineddropsthe extra keys either way.
Testing
Added
test_plotly_extract_points_bbox_z_sourceintests/units/components/graphing/test_plotly.py, which renders the component, joins thegenerated
add_custom_code(), and asserts the snippet readsz0: point.bbox.z0/z1: point.bbox.z1(and no longerz0: point.bbox.y0/z1: point.bbox.y1). It failsbefore the fix and passes after.
A towncrier changelog fragment is included under
packages/reflex-components-plotly/news/.