feat: add motion expander to compass tab — shows top motions per axis
This commit is contained in:
+45
@@ -1028,6 +1028,51 @@ def build_compass_tab(db_path: str, window_size: str) -> None:
|
||||
):
|
||||
st.caption(_y_interp)
|
||||
|
||||
# Motion expander — show which motions define each axis for this window
|
||||
x_top = axis_def.get("x_top_motions", {}).get(window_idx, {})
|
||||
y_top = axis_def.get("y_top_motions", {}).get(window_idx, {})
|
||||
x_conf = axis_def.get("x_label_confidence", {}).get(window_idx)
|
||||
y_conf = axis_def.get("y_label_confidence", {}).get(window_idx)
|
||||
evr = axis_def.get("explained_variance_ratio", [None, None])
|
||||
evr0 = evr[0] if evr else None
|
||||
|
||||
_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?"):
|
||||
x_conf_pct = (
|
||||
f" (vertrouwen: {x_conf:.0%})" if x_conf is not None else ""
|
||||
)
|
||||
y_conf_pct = (
|
||||
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}")
|
||||
|
||||
if evr0 is not None:
|
||||
st.caption(
|
||||
f"As 1 verklaart {evr0:.1%} van de variantie in stemgedrag."
|
||||
)
|
||||
|
||||
# --- Voting discipline section ---
|
||||
_MIN_MOTIONS_FOR_DISCIPLINE = 5
|
||||
start_date, end_date = _window_to_dates(window_idx)
|
||||
|
||||
Reference in New Issue
Block a user