Skip to content

Commit 9472623

Browse files
fix: Magic number
1 parent 5a9443f commit 9472623

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/ansys/tools/visualization_interface/backends/plotly/plotly_interface.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@
3333

3434

3535
class PlotlyBackend(BaseBackend):
36-
"""Plotly interface for visualization.
37-
38-
Parameters
39-
----------
40-
theme : str, default: "plotly"
41-
Theme for the Plotly figure. See available themes at
42-
`Plotly Templates <https://plotly.com/python/templates/>`_.
43-
"""
36+
"""Plotly interface for visualization."""
4437

4538
def __init__(self) -> None:
4639
"""Initialize the Plotly backend."""

src/ansys/tools/visualization_interface/backends/plotly/widgets/button_manager.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ def add_projection_toggle_button(
387387
self.add_button(
388388
label=label,
389389
method="relayout",
390-
args=[orthographic_projection],
391-
args2=[perspective_projection],
390+
args=[perspective_projection],
391+
args2=[orthographic_projection],
392392
x=x,
393393
y=y
394394
)
@@ -451,8 +451,11 @@ def add_theme_toggle_button(
451451
"scene.zaxis.zerolinecolor": "#C8D4E3"
452452
}
453453

454-
# Add styling updates for all existing updatemenus
455-
for i in range(10): # Support up to 10 button groups
454+
# Add styling updates for all existing updatemenus + the theme button we're about to add
455+
# Get the actual number of updatemenus in the figure
456+
current_updatemenus = self._fig.layout.updatemenus or []
457+
# Add 1 to include the theme button we're about to create
458+
for i in range(len(current_updatemenus) + 1):
456459
light_theme[f"updatemenus[{i}].bgcolor"] = "rgba(255,255,255,0.95)"
457460
light_theme[f"updatemenus[{i}].bordercolor"] = "rgba(0,0,0,0.3)"
458461
light_theme[f"updatemenus[{i}].font.color"] = "black"

0 commit comments

Comments
 (0)