XPMaster commited on
Commit
17cbc9f
·
1 Parent(s): d344372

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -11,9 +11,11 @@ df = pd.DataFrame({
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
  # Session state for navigation
19
  if 'current_step' not in st.session_state:
@@ -23,10 +25,17 @@ if 'current_step' not in st.session_state:
23
  def go_to_step(step):
24
  st.session_state['current_step'] = step
25
 
 
 
 
26
  # Layout
27
  st.title('Interactive Dashboard with Steps')
28
 
29
- col1, col2 = st.columns(2)
 
 
 
 
30
  with col1:
31
  # "Previous" button will be disabled on the first step
32
  prev_disabled = st.session_state['current_step'] == 1
@@ -41,4 +50,4 @@ with col2:
41
  if st.session_state['current_step'] == 1:
42
  st.plotly_chart(fig_bar)
43
  elif st.session_state['current_step'] == 2:
44
- st.plotly_chart(fig_line)
 
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
+ fig_bar.update_layout(autosize=True, width=st.session_state.get('chart_width', 700))
15
 
16
  # Create another figure for a line chart
17
  fig_line = px.line(df, x="Fruit", y="Amount", color="City")
18
+ fig_line.update_layout(autosize=True, width=st.session_state.get('chart_width', 700))
19
 
20
  # Session state for navigation
21
  if 'current_step' not in st.session_state:
 
25
  def go_to_step(step):
26
  st.session_state['current_step'] = step
27
 
28
+ # Set the layout to wide
29
+ st.set_page_config(layout="wide")
30
+
31
  # Layout
32
  st.title('Interactive Dashboard with Steps')
33
 
34
+ # Set the width of the chart dynamically based on the page width
35
+ st.session_state['chart_width'] = st.columns()[0].width
36
+
37
+ # Button columns
38
+ col1, col2 = st.columns([1, 5])
39
  with col1:
40
  # "Previous" button will be disabled on the first step
41
  prev_disabled = st.session_state['current_step'] == 1
 
50
  if st.session_state['current_step'] == 1:
51
  st.plotly_chart(fig_bar)
52
  elif st.session_state['current_step'] == 2:
53
+ st.plotly_chart(fig_line)