Rimjhim Mittal commited on
Commit ·
52f6e73
1
Parent(s): fe7d37c
Horizontal Checkboxes
Browse files
app.py
CHANGED
|
@@ -71,21 +71,36 @@ def show_simulation_results(all_node_results, stateful_nodes):
|
|
| 71 |
st.session_state.selected_columns = {node_id: {col: True for col in chart_data.columns}}
|
| 72 |
elif node_id not in st.session_state.selected_columns:
|
| 73 |
st.session_state.selected_columns[node_id] = {col: True for col in chart_data.columns}
|
| 74 |
-
|
| 75 |
-
for column in columns:
|
| 76 |
-
st.checkbox(
|
| 77 |
-
f"{column}",
|
| 78 |
-
value=st.session_state.selected_columns[node_id][column],
|
| 79 |
-
key=f"checkbox_{node_id}_{column}",
|
| 80 |
-
on_change=update_selected_columns,
|
| 81 |
-
args=(node_id, column,)
|
| 82 |
-
)
|
| 83 |
-
|
| 84 |
# Filter the data based on selected checkboxes
|
| 85 |
filtered_data = chart_data[[col for col, selected in st.session_state.selected_columns[node_id].items() if selected]]
|
| 86 |
-
|
| 87 |
# Display the line chart with filtered data
|
| 88 |
st.line_chart(filtered_data, use_container_width=True, height=400)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
else:
|
| 90 |
st.write(all_node_results[node_id])
|
| 91 |
|
|
@@ -250,7 +265,7 @@ def upload_file_and_load_to_model():
|
|
| 250 |
github_url = st.sidebar.text_input("Enter GitHub raw file URL:", placeholder="Enter GitHub raw file URL")
|
| 251 |
example_models = {
|
| 252 |
"Newton Cooling Model": "./examples/NewtonCoolingModel.json",
|
| 253 |
-
|
| 254 |
"FN": "./examples/FN.mdf.json",
|
| 255 |
"States": "./examples/States.json",
|
| 256 |
"Swicthed RLC Circuit": "./examples/switched_rlc_circuit.json",
|
|
|
|
| 71 |
st.session_state.selected_columns = {node_id: {col: True for col in chart_data.columns}}
|
| 72 |
elif node_id not in st.session_state.selected_columns:
|
| 73 |
st.session_state.selected_columns[node_id] = {col: True for col in chart_data.columns}
|
| 74 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
# Filter the data based on selected checkboxes
|
| 76 |
filtered_data = chart_data[[col for col, selected in st.session_state.selected_columns[node_id].items() if selected]]
|
|
|
|
| 77 |
# Display the line chart with filtered data
|
| 78 |
st.line_chart(filtered_data, use_container_width=True, height=400)
|
| 79 |
+
columns = chart_data.columns
|
| 80 |
+
checks = st.columns(8)
|
| 81 |
+
if len(columns) > 0 and len(st.session_state.selected_columns[node_id])>1:
|
| 82 |
+
for l, column in enumerate(columns):
|
| 83 |
+
with checks[l]:
|
| 84 |
+
st.checkbox(
|
| 85 |
+
f"{column}",
|
| 86 |
+
value=st.session_state.selected_columns[node_id][column],
|
| 87 |
+
key=f"checkbox_{node_id}_{column}",
|
| 88 |
+
on_change=update_selected_columns,
|
| 89 |
+
args=(node_id, column,)
|
| 90 |
+
)
|
| 91 |
+
#show checkboxes horizontally
|
| 92 |
+
# in case we late go back to vertical
|
| 93 |
+
# for column in columns:
|
| 94 |
+
# st.checkbox(
|
| 95 |
+
# f"{column}",
|
| 96 |
+
# value=st.session_state.selected_columns[node_id][column],
|
| 97 |
+
# key=f"checkbox_{node_id}_{column}",
|
| 98 |
+
# on_change=update_selected_columns,
|
| 99 |
+
# args=(node_id, column,)
|
| 100 |
+
# )
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
else:
|
| 105 |
st.write(all_node_results[node_id])
|
| 106 |
|
|
|
|
| 265 |
github_url = st.sidebar.text_input("Enter GitHub raw file URL:", placeholder="Enter GitHub raw file URL")
|
| 266 |
example_models = {
|
| 267 |
"Newton Cooling Model": "./examples/NewtonCoolingModel.json",
|
| 268 |
+
"ABCD": "./examples/ABCD.json",
|
| 269 |
"FN": "./examples/FN.mdf.json",
|
| 270 |
"States": "./examples/States.json",
|
| 271 |
"Swicthed RLC Circuit": "./examples/switched_rlc_circuit.json",
|