Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
|
| 5 |
+
# Sample DataFrame
|
| 6 |
+
df = pd.DataFrame({
|
| 7 |
+
"Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
|
| 8 |
+
"Amount": [4, 1, 2, 2, 4, 5],
|
| 9 |
+
"City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
|
| 10 |
+
})
|
| 11 |
+
|
| 12 |
+
# Create a Plotly Express figure for the bar chart
|
| 13 |
+
fig_bar = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")
|
| 14 |
+
|
| 15 |
+
# Create another figure for a line chart
|
| 16 |
+
fig_line = px.line(df, x="Fruit", y="Amount", color="City")
|
| 17 |
+
|
| 18 |
+
# Create a session state for navigation
|
| 19 |
+
if 'current_step' not in st.session_state:
|
| 20 |
+
st.session_state['current_step'] = 1
|
| 21 |
+
|
| 22 |
+
# Define navigation functions
|
| 23 |
+
def go_to_step_1():
|
| 24 |
+
st.session_state['current_step'] = 1
|
| 25 |
+
|
| 26 |
+
def go_to_step_2():
|
| 27 |
+
st.session_state['current_step'] = 2
|
| 28 |
+
|
| 29 |
+
# Layout
|
| 30 |
+
st.title('Interactive Dashboard with Steps')
|
| 31 |
+
|
| 32 |
+
# Step navigation
|
| 33 |
+
if st.session_state['current_step'] == 1:
|
| 34 |
+
st.plotly_chart(fig_bar)
|
| 35 |
+
st.button('Next Step', on_click=go_to_step_2)
|
| 36 |
+
elif st.session_state['current_step'] == 2:
|
| 37 |
+
st.plotly_chart(fig_line)
|
| 38 |
+
st.button('Previous Step', on_click=go_to_step_1)
|