mabuseif commited on
Commit
8bd30dd
·
verified ·
1 Parent(s): 6112ee7

Update app/internal_loads.py

Browse files
Files changed (1) hide show
  1. app/internal_loads.py +49 -32
app/internal_loads.py CHANGED
@@ -20,6 +20,7 @@ import uuid
20
  import plotly.graph_objects as go
21
  import plotly.express as px
22
  from typing import Dict, List, Any, Optional, Tuple, Union
 
23
 
24
  # Configure logging
25
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@@ -922,40 +923,47 @@ def display_ventilation_infiltration_tab():
922
  st.session_state.module_rerun_flags["internal_loads"] = True
923
  st.rerun()
924
 
925
- # Custom CSS for vertical sliders resembling a column chart
926
  st.markdown("""
927
  <style>
928
  .slider-container {
929
  display: flex;
930
  flex-direction: row;
931
- justify-content: space-evenly;
932
  align-items: flex-end;
933
- gap: 4px;
934
- padding: 20px 0;
 
935
  }
936
  .slider-item {
937
  display: flex;
938
  flex-direction: column;
939
  align-items: center;
940
- width: 40px;
941
- }
942
- .vertical-slider {
943
- writing-mode: bt-lr;
944
- transform: rotate(-90deg);
945
- height: 200px;
946
- width: 30px;
947
  }
948
  .hour-label {
949
  text-align: center;
950
- font-size: 12px;
951
- margin-top: 5px;
952
  font-weight: bold;
 
 
 
 
 
 
 
 
 
 
 
953
  }
954
- .stSlider > div > div > div > div {
955
- background-color: #4CAF50 !important;
956
  }
957
- .stSlider > div > div > div > div > div {
958
- background-color: #2196F3 !important;
 
959
  }
960
  </style>
961
  """, unsafe_allow_html=True)
@@ -1010,19 +1018,23 @@ def display_schedules_tab():
1010
  for hour in range(24):
1011
  with st.container():
1012
  st.markdown('<div class="slider-item">', unsafe_allow_html=True)
1013
- val = st.slider(
1014
  label="",
 
 
 
 
 
1015
  min_value=0.0,
1016
  max_value=1.0,
1017
- step=0.01,
1018
- value=float(weekday_values[hour]),
1019
- key=f"weekday_{hour}",
1020
- help=f"Hour {hour}:00 weekday value",
1021
- format="%.2f"
1022
  )
1023
  st.markdown(f'<div class="hour-label">{hour:02d}:00</div>', unsafe_allow_html=True)
1024
  st.markdown('</div>', unsafe_allow_html=True)
1025
- weekday_schedule.append(val)
1026
  st.markdown('</div>', unsafe_allow_html=True)
1027
 
1028
  # Weekend schedule with vertical sliders
@@ -1032,19 +1044,24 @@ def display_schedules_tab():
1032
  for hour in range(24):
1033
  with st.container():
1034
  st.markdown('<div class="slider-item">', unsafe_allow_html=True)
1035
- val = st.slider(
1036
  label="",
 
 
 
 
 
1037
  min_value=0.0,
1038
  max_value=1.0,
1039
- step=0.01,
1040
- value=float(weekend_values[hour]),
1041
- key=f"weekend_{hour}",
1042
- help=f"Hour {hour}:00 weekend value",
1043
- format="%.2f"
1044
  )
1045
  st.markdown(f'<div class="hour-label">{hour:02d}:00</div>', unsafe_allow_html=True)
1046
  st.markdown('</div>', unsafe_allow_html=True)
1047
- weekend_schedule.append(val)
1048
  st.markdown('</div>', unsafe_allow_html=True)
1049
 
1050
  # Display saved schedules table
@@ -1089,7 +1106,7 @@ def display_schedules_tab():
1089
  st.session_state.module_rerun_flags["internal_loads"] = True
1090
  st.rerun()
1091
 
1092
- with col2:
1093
  if st.button("Cancel"):
1094
  st.session_state.schedule_editor = {}
1095
  st.session_state.module_rerun_flags["internal_loads"] = True
 
20
  import plotly.graph_objects as go
21
  import plotly.express as px
22
  from typing import Dict, List, Any, Optional, Tuple, Union
23
+ from streamlit_vertical_slider import vertical_slider # Add import for vertical slider
24
 
25
  # Configure logging
26
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
923
  st.session_state.module_rerun_flags["internal_loads"] = True
924
  st.rerun()
925
 
926
+ # Updated CSS for vertical sliders with tighter spacing
927
  st.markdown("""
928
  <style>
929
  .slider-container {
930
  display: flex;
931
  flex-direction: row;
932
+ justify-content: space-between;
933
  align-items: flex-end;
934
+ gap: 2px; /* Reduced gap for tighter spacing */
935
+ padding: 10px 0;
936
+ flex-wrap: nowrap;
937
  }
938
  .slider-item {
939
  display: flex;
940
  flex-direction: column;
941
  align-items: center;
942
+ width: 35px; /* Narrower width for compact layout */
 
 
 
 
 
 
943
  }
944
  .hour-label {
945
  text-align: center;
946
+ font-size: 11px; /* Slightly smaller font */
947
+ margin-top: 3px;
948
  font-weight: bold;
949
+ white-space: nowrap;
950
+ }
951
+ /* Style the vertical slider track and thumb */
952
+ .stVerticalSlider {
953
+ height: 180px !important; /* Shorter height for better fit */
954
+ }
955
+ .stVerticalSlider .slider-track {
956
+ background: #e0e0e0 !important;
957
+ }
958
+ .stVerticalSlider .slider-filled {
959
+ background: #4CAF50 !important; /* Weekday color */
960
  }
961
+ .stVerticalSlider.weekend .slider-filled {
962
+ background: #2196F3 !important; /* Weekend color */
963
  }
964
+ .stVerticalSlider .slider-thumb {
965
+ background: #333 !important;
966
+ border: 2px solid #fff !important;
967
  }
968
  </style>
969
  """, unsafe_allow_html=True)
 
1018
  for hour in range(24):
1019
  with st.container():
1020
  st.markdown('<div class="slider-item">', unsafe_allow_html=True)
1021
+ val = vertical_slider(
1022
  label="",
1023
+ key=f"weekday_{hour}",
1024
+ height=180, # Matches CSS height
1025
+ thumb_shape="circle",
1026
+ step=0.01,
1027
+ default_value=float(weekday_values[hour]),
1028
  min_value=0.0,
1029
  max_value=1.0,
1030
+ track_color="#e0e0e0",
1031
+ slider_color="#4CAF50", # Green for weekday
1032
+ thumb_color="#333",
1033
+ value_always_visible=False
 
1034
  )
1035
  st.markdown(f'<div class="hour-label">{hour:02d}:00</div>', unsafe_allow_html=True)
1036
  st.markdown('</div>', unsafe_allow_html=True)
1037
+ weekday_schedule.append(val if val is not None else float(weekday_values[hour]))
1038
  st.markdown('</div>', unsafe_allow_html=True)
1039
 
1040
  # Weekend schedule with vertical sliders
 
1044
  for hour in range(24):
1045
  with st.container():
1046
  st.markdown('<div class="slider-item">', unsafe_allow_html=True)
1047
+ val = vertical_slider(
1048
  label="",
1049
+ key=f"weekend_{hour}",
1050
+ height=180, # Matches CSS height
1051
+ thumb_shape="circle",
1052
+ step=0.01,
1053
+ default_value=float(weekend_values[hour]),
1054
  min_value=0.0,
1055
  max_value=1.0,
1056
+ track_color="#e0e0e0",
1057
+ slider_color="#2196F3", # Blue for weekend
1058
+ thumb_color="#333",
1059
+ value_always_visible=False,
1060
+ class_name="weekend" # Custom class for weekend styling
1061
  )
1062
  st.markdown(f'<div class="hour-label">{hour:02d}:00</div>', unsafe_allow_html=True)
1063
  st.markdown('</div>', unsafe_allow_html=True)
1064
+ weekend_schedule.append(val if val is not None else float(weekend_values[hour]))
1065
  st.markdown('</div>', unsafe_allow_html=True)
1066
 
1067
  # Display saved schedules table
 
1106
  st.session_state.module_rerun_flags["internal_loads"] = True
1107
  st.rerun()
1108
 
1109
+ with col2]:
1110
  if st.button("Cancel"):
1111
  st.session_state.schedule_editor = {}
1112
  st.session_state.module_rerun_flags["internal_loads"] = True