【发布时间】:2022-08-19 01:20:55
【问题描述】:
所以我有一个侧边栏。 When \"Go\" in the sidebar is selected, the main dashboard should update.这行得通。
What doesn\'t work is when the radio button (marketing consent) within the main dashboard is selected, the entire dashboard resets.它将恢复到原始视图,而不是选择“开始”后的样子。当单击单选按钮时,就好像“开始”按钮重置并被取消选中......
\"\"\"
# My first app
Here\'s our first attempt at using data to create a table:
\"\"\"
##Packages
from unicodedata import numeric
import streamlit as st
import numpy as np
import pandas as pd
from PIL import Image
import pandasql as ps
import altair as alt
import plotly.express as px
st.set_page_config(page_title = \"Dashboard\")
st.title(\"Dashboard ????\")
##Dataframe
df = pd.DataFrame({
\'first\': [1, 2, 3, 4],
\'second\': [10, 20, 30, 40],
\'third\': [\'apple\', \'banana\', \'grape\', \'grape\'],
\'fourth\': [\'walter\', \'skyler\', \'hank\', \'marie\']
})
####
###Sidebar things
####
###Logo
with st.sidebar.container():
st.sidebar.title(\"Sidebar\")
with st.sidebar.container():
add_selectbox = st.sidebar.multiselect(
\'Choose some properties\',
(df.third.unique())
)
fourth_box = st.sidebar.selectbox(
\'Choose your country\',
(df.fourth.unique()),
index = 1
)
####Page 1
if st.sidebar.button(\'Go!\'):
with st.container():
status = st.radio(
\"Marketing Consent Status\",
(\'Yes\', \'All\'))
df_iris = px.data.iris()
if marketing_status == \'Yes\':
fig_1 = px.bar(df_iris, x=\"sepal_width\", y=\"sepal_length\", color=\"species\",
hover_data=[\'petal_width\'], barmode = \'stack\')
st.plotly_chart(fig_1, use_container_width=True)
elif marketing_status == \'All\':
st.write(\'Hello, *World!\')
else:
with st.container():
df_map = px.data.gapminder().query(\"year==2007\")
fig_map = px.choropleth(df_map, locations=\"iso_alpha\",
color=\"lifeExp\", # lifeExp is a column of gapminder
hover_name=\"country\", # column to add to hover information
color_continuous_scale=px.colors.sequential.Plasma)
st.plotly_chart(fig_map, use_container_width=True)
如您所见,当您使用单选按钮(Marketing Consent Button)出现后,它将恢复到主地图视图。
-
这能回答你的问题吗?user input is not capturing the text
-
这回答了你的问题了吗? user input is not capturing the text