Adding Interactivity with Widgets
To make your dashboards interactive and responsive to user input, Streamlit provides a variety of widgets. These widgets allow users to control parameters, filter data, or provide information directly through the app interface. Some of the most commonly used widgets include st.slider, st.selectbox, and st.text_input.
- The
st.sliderwidget lets users select a numeric value or range by moving a slider; - The
st.selectboxallows users to choose a single option from a dropdown list; - The
st.text_inputwidget enables users to enter freeform text.
By incorporating these widgets, you can build dashboards that react instantly to user choices, making the data exploration experience much more engaging and tailored.
In this example, the st.slider widget gives users control over the number of bins in the histogram. When a user moves the slider, the value of num_bins updates instantly. This value is then used to set the bins parameter in the ax.hist function, which redraws the histogram with the new bin count. As a result, the chart displayed in the dashboard updates in real time based on the user's selection, demonstrating how widget values can be directly used to make dashboard content interactive and dynamic.
Tak for dine kommentarer!
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Fantastisk!
Completion rate forbedret til 11.11
Adding Interactivity with Widgets
Stryg for at vise menuen
To make your dashboards interactive and responsive to user input, Streamlit provides a variety of widgets. These widgets allow users to control parameters, filter data, or provide information directly through the app interface. Some of the most commonly used widgets include st.slider, st.selectbox, and st.text_input.
- The
st.sliderwidget lets users select a numeric value or range by moving a slider; - The
st.selectboxallows users to choose a single option from a dropdown list; - The
st.text_inputwidget enables users to enter freeform text.
By incorporating these widgets, you can build dashboards that react instantly to user choices, making the data exploration experience much more engaging and tailored.
In this example, the st.slider widget gives users control over the number of bins in the histogram. When a user moves the slider, the value of num_bins updates instantly. This value is then used to set the bins parameter in the ax.hist function, which redraws the histogram with the new bin count. As a result, the chart displayed in the dashboard updates in real time based on the user's selection, demonstrating how widget values can be directly used to make dashboard content interactive and dynamic.
Tak for dine kommentarer!