Skip to content

Commit ce1e048

Browse files
committed
Add dark mode support to 3D scatter view
Introduced a 'dark_mode' parameter to the 3D scatter view animation, passing it from the callback and applying the appropriate Plotly template based on the mode. This enhances visualization by supporting both dark and light themes.
1 parent 3d4c08c commit ce1e048

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

view_callbacks/scatter_3d_view.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def export_3d_scatter_animation(
753753
"""
754754
if btn == 0:
755755
raise PreventUpdate
756-
756+
757757
set_progress(["show"])
758758

759759
if not os.path.exists("data/" + case + "/images"):
@@ -822,6 +822,7 @@ def export_3d_scatter_animation(
822822
frame_key=config["slider"],
823823
img_list=img_list,
824824
colormap=colormap,
825+
dark_mode=darkmode,
825826
**fig_kwargs
826827
)
827828
)

viz/viz.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import numpy as np
5353
import pandas as pd
5454

55+
import plotly.io as pio
56+
5557
from .graph_data import get_scatter3d_data, get_ref_scatter3d_data
5658
from .graph_layout import get_scatter3d_layout
5759

@@ -323,6 +325,7 @@ def get_animation_data(
323325
img_list: Optional[List[str]] = None,
324326
colormap: Optional[str] = None,
325327
decay: int = 0,
328+
dark_mode: bool = True,
326329
**kwargs: Any,
327330
) -> Dict[str, Any]:
328331
"""
@@ -478,6 +481,12 @@ def create_frame_data(frame_idx: int, current_idx: int) -> Dict[str, Any]:
478481
layout_kwargs["image"] = process_image(img_list[0])
479482

480483
figure_layout = get_scatter3d_layout(**layout_kwargs)
484+
485+
if dark_mode:
486+
figure_layout["template"] = pio.templates["plotly_dark"]
487+
else:
488+
figure_layout["template"] = pio.templates["plotly"]
489+
481490
figure_layout.update(
482491
{
483492
"updatemenus": [

0 commit comments

Comments
 (0)