Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/reflex-components-plotly/news/6722.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed `rx.plotly` `on_hover`/`on_click`/`on_unhover` event data reporting the wrong z bounding box for 3D traces: `bbox.z0`/`bbox.z1` had been duplicating the y-extent instead of surfacing the real z-extent.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def add_custom_code(self) -> list[str]:
x1: point.bbox.x1,
y0: point.bbox.y0,
y1: point.bbox.y1,
z0: point.bbox.y0,
z1: point.bbox.y1,
z0: point.bbox.z0,
Comment on lines 216 to +217

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.

P1 Z Bounds Remain Missing

Plotly gl3d events provide bbox as a screen-space box with x0, x1, y0, and y1, not z0 or z1. For scatter3d, mesh3d, and surface events, these reads therefore return undefined, and removeUndefined deletes both keys instead of exposing the claimed z extent.

z1: point.bbox.z1,
}) : undefined;
return removeUndefined({
x: point.x,
Expand Down
19 changes: 19 additions & 0 deletions tests/units/components/graphing/test_plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,22 @@ def test_plotly_basic_locale_option_merges_into_config(plotly_fig: go.Figure):
assert "locale" not in rendered.props
assert "_rxGetPlotlyLocaleConfig" in str(config_var)
assert "fr" in str(config_var)


def test_plotly_extract_points_bbox_z_source(plotly_fig: go.Figure):
"""Test that the point extractor reads the z-bbox from the z fields.

The generated ``extractPoints`` helper must source the ``z0``/``z1`` bounding
box members from ``point.bbox.z0``/``point.bbox.z1`` so 3D-plot event data
reports the real z-extent instead of duplicating the y-extent.

Args:
plotly_fig: The figure to display.
"""
component = rx.plotly(data=plotly_fig)
custom_code = "\n".join(component.add_custom_code())

assert "z0: point.bbox.z0" in custom_code
assert "z1: point.bbox.z1" in custom_code
assert "z0: point.bbox.y0" not in custom_code
assert "z1: point.bbox.y1" not in custom_code
Loading