awacke1 commited on
Commit
16f32ec
·
1 Parent(s): a99cc85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -25,6 +25,9 @@ health_conditions = [
25
  # Create a DataFrame from the list dictionary
26
  df_top_conditions = pd.DataFrame(health_conditions)
27
 
 
 
 
28
  # Define the reroll function
29
  def reroll():
30
  # Randomly select a health condition from the top 10
@@ -39,11 +42,17 @@ def reroll():
39
  if reroll:
40
  reroll()
41
 
42
- # Create the map graph using Plotly Express
43
- fig_map = px.choropleth(locations=["CA", "FL", "MN"], locationmode="USA-states", color=[1, 2, 3], scope="usa")
44
- fig_map.update_layout(geo=dict(bgcolor= "rgba(0, 0, 0, 0)", lakecolor="rgb(255, 255, 255)"))
 
 
 
 
 
 
 
45
 
46
- # Create the bar chart using Plotly Graph Objects
47
- fig_bar = go.Figure(go.Bar(x=df_top_conditions["emoji"] + " " + df_top_conditions["condition"], y=df_top_conditions["spending"], marker_color="#1f77b4"))
48
- fig_bar.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)",
49
- yaxis_title="Spending ($B)", plot_bgcolor='rgba(0,0
 
25
  # Create a DataFrame from the list dictionary
26
  df_top_conditions = pd.DataFrame(health_conditions)
27
 
28
+ # Calculate the total spending
29
+ total_spending = round(df_top_conditions["spending"].sum(), 1)
30
+
31
  # Define the reroll function
32
  def reroll():
33
  # Randomly select a health condition from the top 10
 
42
  if reroll:
43
  reroll()
44
 
45
+ # Define the sunburst chart
46
+ fig_sunburst = go.Figure(go.Sunburst(
47
+ labels=df_top_conditions["emoji"] + " " + df_top_conditions["condition"],
48
+ parents=[""] * top_n,
49
+ values=df_top_conditions["spending"],
50
+ maxdepth=2
51
+ ))
52
+
53
+ # Customize the layout of the sunburst chart
54
+ fig_sunburst.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)")
55
 
56
+ # Display the sunburst chart and reroll button in the Streamlit app
57
+ st.plotly_chart(fig_sunburst)
58
+ st.button("Reroll", on_click=reroll)