Skip to content

Commit 6c8a2c3

Browse files
authored
Merge pull request #539 from materialsproject/fix-phonon
disable interactive button if has_eigendisplacements is false
2 parents 10912c6 + eb68a59 commit 6c8a2c3

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

crystal_toolkit/components/phonon.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ def _sub_layouts(self) -> dict[str, Component]:
181181
id=self.id("animation-button-container"),
182182
)
183183

184+
hints = html.Div(
185+
"💡 Zoom in by selecting an area of interest, and double-click to return to the original view. (The q points' labels that appear to overlap at the current scale are actually distinct.)",
186+
style={"textAlign": "center"},
187+
)
188+
184189
return {
185190
"graph": graph,
186191
"convention": convention,
@@ -189,6 +194,7 @@ def _sub_layouts(self) -> dict[str, Component]:
189194
"zone": zone,
190195
"table": summary_table,
191196
"crystal_animation_button_container": crystal_animation_button_container,
197+
"hints": hints,
192198
}
193199

194200
def _get_animation_panel(self):
@@ -426,6 +432,7 @@ def _get_animation_panel(self):
426432
def layout(self) -> html.Div:
427433
sub_layouts = self._sub_layouts
428434
graph = Columns([Column([sub_layouts["graph"]])])
435+
hints = Columns([Column([sub_layouts["hints"]])])
429436
crystal_animation_container = Columns(
430437
[], id=self.id("crystal-animation-container"), style={"display": "none"}
431438
)
@@ -453,6 +460,7 @@ def layout(self) -> html.Div:
453460
return html.Div(
454461
[
455462
graph,
463+
hints,
456464
crystal_animation_button_container,
457465
crystal_animation_container,
458466
controls,
@@ -896,6 +904,7 @@ def get_figure(
896904
tickvals=bs_data["ticks"]["distance"],
897905
title=dict(text="Wave Vector", font=dict(size=16)),
898906
zeroline=False,
907+
automargin=True,
899908
)
900909

901910
yaxis_style = dict(
@@ -1008,6 +1017,9 @@ def generate_callbacks(self, app, cache) -> None:
10081017
Output(self.id("ph-bsdos-graph"), "figure", allow_duplicate=True),
10091018
Output(self.id("zone"), "data"),
10101019
Output(self.id("table"), "children"),
1020+
Output(
1021+
self.id("animation-button-container"), "style", allow_duplicate=True
1022+
),
10111023
Input(self.id("ph_bs"), "data"),
10121024
Input(self.id("ph_dos"), "data"),
10131025
# prevent_intial_call=True,
@@ -1026,7 +1038,9 @@ def update_graph(bs, dos):
10261038
summary_dict = self._get_data_list_dict(bs, dos)
10271039
summary_table = get_data_list(summary_dict)
10281040

1029-
return figure, zone_scene.to_json(), summary_table
1041+
if bs.has_eigendisplacements:
1042+
return figure, zone_scene.to_json(), summary_table, {"display": "flex"}
1043+
return figure, zone_scene.to_json(), summary_table, {"display": "none"}
10301044

10311045
@app.callback(
10321046
Output(self.id("ph-bsdos-graph"), "figure", allow_duplicate=True),
@@ -1087,7 +1101,9 @@ def update_pointer_graph(figure, nclick, animation_click):
10871101
@app.callback(
10881102
Output(self.id("crystal-animation-container"), "children"),
10891103
Output(self.id("crystal-animation-container"), "style"),
1090-
Output(self.id("animation-button-container"), "style"),
1104+
Output(
1105+
self.id("animation-button-container"), "style", allow_duplicate=True
1106+
),
10911107
Input(self.id("animation-button"), "n_clicks"),
10921108
prevent_intial_call=True,
10931109
)

crystal_toolkit/helpers/pretty_labels.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
"\\Gamma": "Γ",
1010
"\\Sigma": "Σ",
1111
"GAMMA": "Γ",
12+
"SIGMA": "Σ",
13+
"_0": "₀",
1214
"_1": "₁",
1315
"_2": "₂",
1416
"_3": "₃",
1517
"_4": "₄",
18+
"_{0}": "₀",
1619
"_{1}": "₁",
1720
"_{2}": "₂",
1821
"_{3}": "₃",

0 commit comments

Comments
 (0)