Skip to content

Commit e693679

Browse files
fix: Avoid using template due to serialization issues
1 parent 01f7611 commit e693679

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

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

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from typing import Any, List
2424

2525
import plotly.graph_objects as go
26-
import plotly.io as pio
2726

2827

2928
class ButtonManager:
@@ -411,14 +410,45 @@ def add_theme_toggle_button(
411410
y : float, optional
412411
Y position of the button (0-1), by default 1.02.
413412
"""
414-
# Light theme with light button styling for all updatemenus
413+
# Define light theme properties manually to avoid JSON serialization issues
414+
# Use dot notation to target specific properties without overriding the entire scene
415+
# Colors extracted from official plotly template
415416
light_theme = {
416-
"template": pio.templates["plotly"]
417+
"paper_bgcolor": "white",
418+
"plot_bgcolor": "#E5ECF6",
419+
"font.color": "#2a3f5f",
420+
"scene.xaxis.backgroundcolor": "#E5ECF6",
421+
"scene.xaxis.gridcolor": "white",
422+
"scene.xaxis.linecolor": "white",
423+
"scene.xaxis.zerolinecolor": "white",
424+
"scene.yaxis.backgroundcolor": "#E5ECF6",
425+
"scene.yaxis.gridcolor": "white",
426+
"scene.yaxis.linecolor": "white",
427+
"scene.yaxis.zerolinecolor": "white",
428+
"scene.zaxis.backgroundcolor": "#E5ECF6",
429+
"scene.zaxis.gridcolor": "white",
430+
"scene.zaxis.linecolor": "white",
431+
"scene.zaxis.zerolinecolor": "white"
417432
}
418433

419-
# Dark theme with dark button styling for all updatemenus
434+
# Define dark theme properties manually
435+
# Colors extracted from official plotly_dark template
420436
dark_theme = {
421-
"template": pio.templates["plotly_dark"]
437+
"paper_bgcolor": "rgb(17,17,17)",
438+
"plot_bgcolor": "rgb(17,17,17)",
439+
"font.color": "#f2f5fa",
440+
"scene.xaxis.backgroundcolor": "rgb(17,17,17)",
441+
"scene.xaxis.gridcolor": "#506784",
442+
"scene.xaxis.linecolor": "#506784",
443+
"scene.xaxis.zerolinecolor": "#C8D4E3",
444+
"scene.yaxis.backgroundcolor": "rgb(17,17,17)",
445+
"scene.yaxis.gridcolor": "#506784",
446+
"scene.yaxis.linecolor": "#506784",
447+
"scene.yaxis.zerolinecolor": "#C8D4E3",
448+
"scene.zaxis.backgroundcolor": "rgb(17,17,17)",
449+
"scene.zaxis.gridcolor": "#506784",
450+
"scene.zaxis.linecolor": "#506784",
451+
"scene.zaxis.zerolinecolor": "#C8D4E3"
422452
}
423453

424454
# Add styling updates for all existing updatemenus

0 commit comments

Comments
 (0)