I have a webapp that displays 11 checkboxes. When checked, the application returns a graph of the data that corresponds to the selected box.
Because the end user can select any variation of these boxes and should expect to see only the graph of those selected, every possible combination must be declared.
Currently, my implementation is as follows. It is quite unsophisticated and will likely take hours, so you can see why I'm looking for something a bit more.. supple?
Discretionary = st.sidebar.checkbox(label = 'Consumer Discretionary', value = False)
Consumer_Staples = st.sidebar.checkbox(label = 'Consumer Staples', value = False)
Energy = st.sidebar.checkbox(label = 'Energy', value = False)
Financials = st.sidebar.checkbox(label = 'Financials', value = False)
Healthcare = st.sidebar.checkbox(label = 'Healthcare', value = False)
Industrials = st.sidebar.checkbox(label = 'Industrials', value = False)
Materials = st.sidebar.checkbox(label = 'Materials', value = False)
Real_Estate = st.sidebar.checkbox(label = 'Real Estate', value = False)
Technology = st.sidebar.checkbox(label = 'Technology', value = False)
Utilities = st.sidebar.checkbox(label = 'Utilities', value = False)
Placeholder = st.empty()
for a in range(0, 500):
try:
Data = pd.read_csv('Mydata')
Data = Data.set_index('Time')
except:
pass
if Communications == True and Discretionary == True:
with Placeholder.container():
st.line_chart(data = Data[['Communications','CD Consumer Discretionary']] * 100)
elif Communications == True and Discretionary == False:
with Placeholder.container():
st.line_chart(data = Data['Communications'] * 100)
elif Discretionary == True and Communications == False:
with Placeholder.container():
st.line_chart(data = Data['CD Consumer Discretionary'] * 100)```
Aucun commentaire:
Enregistrer un commentaire