Armeddinosaur commited on
Commit
8b5f55f
·
1 Parent(s): a325fdc

Updating Metric to checkbox

Browse files
Files changed (1) hide show
  1. src/components/filters.py +26 -12
src/components/filters.py CHANGED
@@ -34,13 +34,24 @@ def initialize_session_state(df):
34
 
35
  def render_metric_selection():
36
  """
37
- Render the metric selection component
38
 
39
  Returns:
40
  list: Selected metrics
41
  """
42
  st.markdown("### Select Metrics")
43
 
 
 
 
 
 
 
 
 
 
 
 
44
  # Get metric names
45
  all_metrics = list(metrics_config.keys())
46
  primary_metric = all_metrics[0] # First metric is primary
@@ -56,22 +67,19 @@ def render_metric_selection():
56
 
57
  # Primary metric first (always selected and can't be deselected)
58
  with cols[0]:
59
- button_label = f"{primary_metric}"
60
- st.button(button_label, key=f"metric_{primary_metric}", type="primary", disabled=True)
61
 
62
  # Secondary metrics that can be toggled
63
  for i, metric in enumerate(secondary_metrics):
64
  with cols[i+1]:
65
  is_selected = metric in st.session_state.selected_metrics
66
- button_label = f"✓ {metric}" if is_selected else metric
67
- button_type = "primary" if is_selected else "secondary"
68
 
69
- if st.button(button_label, key=f"metric_{metric}", type=button_type):
70
- if is_selected:
71
- st.session_state.selected_metrics.remove(metric)
72
- else:
73
  st.session_state.selected_metrics.append(metric)
74
- st.rerun() # Force UI update
 
 
75
 
76
  return st.session_state.selected_metrics
77
 
@@ -91,7 +99,7 @@ def render_task_selection(df):
91
  all_tasks = [col for col in df.columns if col not in ['Model Type']]
92
 
93
  # Increase number of columns to reduce spacing
94
- num_cols = 4 # More columns for tighter spacing
95
 
96
  # Create task groups in a fixed number of columns with balanced width
97
  task_groups = [all_tasks[i:i+num_cols] for i in range(0, len(all_tasks), num_cols)]
@@ -100,7 +108,7 @@ def render_task_selection(df):
100
  if 'selected_tasks' not in st.session_state or not st.session_state.selected_tasks:
101
  st.session_state.selected_tasks = []
102
 
103
- # Add custom CSS to reduce spacing between checkboxes
104
  st.markdown("""
105
  <style>
106
  /* Reduce spacing in checkbox containers */
@@ -108,6 +116,12 @@ def render_task_selection(df):
108
  padding: 0px !important;
109
  margin-bottom: 5px !important;
110
  }
 
 
 
 
 
 
111
  </style>
112
  """, unsafe_allow_html=True)
113
 
 
34
 
35
  def render_metric_selection():
36
  """
37
+ Render the metric selection component with checkboxes
38
 
39
  Returns:
40
  list: Selected metrics
41
  """
42
  st.markdown("### Select Metrics")
43
 
44
+ # Add custom CSS to increase font size for checkbox labels
45
+ st.markdown("""
46
+ <style>
47
+ /* Increase font size for metric checkboxes */
48
+ [data-testid="stCheckbox"] label p {
49
+ font-size: 16px !important;
50
+ font-weight: 500 !important;
51
+ }
52
+ </style>
53
+ """, unsafe_allow_html=True)
54
+
55
  # Get metric names
56
  all_metrics = list(metrics_config.keys())
57
  primary_metric = all_metrics[0] # First metric is primary
 
67
 
68
  # Primary metric first (always selected and can't be deselected)
69
  with cols[0]:
70
+ st.checkbox(primary_metric, value=True, key=f"metric_checkbox_{primary_metric}", disabled=True)
 
71
 
72
  # Secondary metrics that can be toggled
73
  for i, metric in enumerate(secondary_metrics):
74
  with cols[i+1]:
75
  is_selected = metric in st.session_state.selected_metrics
 
 
76
 
77
+ if st.checkbox(metric, value=is_selected, key=f"metric_checkbox_{metric}"):
78
+ if metric not in st.session_state.selected_metrics:
 
 
79
  st.session_state.selected_metrics.append(metric)
80
+ else:
81
+ if metric in st.session_state.selected_metrics:
82
+ st.session_state.selected_metrics.remove(metric)
83
 
84
  return st.session_state.selected_metrics
85
 
 
99
  all_tasks = [col for col in df.columns if col not in ['Model Type']]
100
 
101
  # Increase number of columns to reduce spacing
102
+ num_cols = 5 # More columns for tighter spacing
103
 
104
  # Create task groups in a fixed number of columns with balanced width
105
  task_groups = [all_tasks[i:i+num_cols] for i in range(0, len(all_tasks), num_cols)]
 
108
  if 'selected_tasks' not in st.session_state or not st.session_state.selected_tasks:
109
  st.session_state.selected_tasks = []
110
 
111
+ # Add custom CSS to reduce spacing and increase font size for checkbox labels
112
  st.markdown("""
113
  <style>
114
  /* Reduce spacing in checkbox containers */
 
116
  padding: 0px !important;
117
  margin-bottom: 5px !important;
118
  }
119
+
120
+ /* Increase font size for task checkboxes */
121
+ [data-testid="stCheckbox"] label p {
122
+ font-size: 16px !important;
123
+ font-weight: 500 !important;
124
+ }
125
  </style>
126
  """, unsafe_allow_html=True)
127