refactor: extract _render_axis_motions helper, use literal emoji in expander
This commit is contained in:
+15
-20
@@ -1036,11 +1036,23 @@ def build_compass_tab(db_path: str, window_size: str) -> None:
|
||||
evr = axis_def.get("explained_variance_ratio", [None, None])
|
||||
evr0 = evr[0] if evr else None
|
||||
|
||||
def _render_axis_motions(label: str, conf_pct: str, top: dict) -> None:
|
||||
st.markdown(f"**{label}**{conf_pct}")
|
||||
for sign, icon in (("+", "➕"), ("-", "➖")):
|
||||
titles = top.get(sign, [])
|
||||
if titles:
|
||||
st.markdown(
|
||||
" "
|
||||
+ icon
|
||||
+ " "
|
||||
+ " · ".join(f"{t} ({d})" for t, d in titles[:3])
|
||||
)
|
||||
|
||||
_has_motion_data = bool(
|
||||
x_top.get("+") or x_top.get("-") or y_top.get("+") or y_top.get("-")
|
||||
)
|
||||
if _has_motion_data:
|
||||
with st.expander("\U0001f50d Wat bepaalt deze assen?"):
|
||||
with st.expander("🔍 Wat bepaalt deze assen?"):
|
||||
x_conf_pct = (
|
||||
f" (vertrouwen: {x_conf:.0%})" if x_conf is not None else ""
|
||||
)
|
||||
@@ -1048,25 +1060,8 @@ def build_compass_tab(db_path: str, window_size: str) -> None:
|
||||
f" (vertrouwen: {y_conf:.0%})" if y_conf is not None else ""
|
||||
)
|
||||
|
||||
st.markdown(f"**Horizontale as: {_x_label}**{x_conf_pct}")
|
||||
x_pos_titles = x_top.get("+", [])
|
||||
x_neg_titles = x_top.get("-", [])
|
||||
if x_pos_titles:
|
||||
labels_pos = " · ".join(f"{t} ({d})" for t, d in x_pos_titles[:3])
|
||||
st.markdown(f" ➕ {labels_pos}")
|
||||
if x_neg_titles:
|
||||
labels_neg = " · ".join(f"{t} ({d})" for t, d in x_neg_titles[:3])
|
||||
st.markdown(f" ➖ {labels_neg}")
|
||||
|
||||
st.markdown(f"**Verticale as: {_y_label}**{y_conf_pct}")
|
||||
y_pos_titles = y_top.get("+", [])
|
||||
y_neg_titles = y_top.get("-", [])
|
||||
if y_pos_titles:
|
||||
labels_pos = " · ".join(f"{t} ({d})" for t, d in y_pos_titles[:3])
|
||||
st.markdown(f" ➕ {labels_pos}")
|
||||
if y_neg_titles:
|
||||
labels_neg = " · ".join(f"{t} ({d})" for t, d in y_neg_titles[:3])
|
||||
st.markdown(f" ➖ {labels_neg}")
|
||||
_render_axis_motions(f"Horizontale as: {_x_label}", x_conf_pct, x_top)
|
||||
_render_axis_motions(f"Verticale as: {_y_label}", y_conf_pct, y_top)
|
||||
|
||||
if evr0 is not None:
|
||||
st.caption(
|
||||
|
||||
Reference in New Issue
Block a user