Skip to content

Commit

Permalink
Added graph type toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansurf committed Jun 8, 2024
1 parent 146c8b1 commit 4b260d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/dev_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
# User input location
location = st.text_input("Surf Spot", placeholder="Enter surf spot!")

graph_type = st.radio(
"Choose graph type",
["Height/Period :ocean:", "Direction :world_map:"],
index=None,
)

# Checks if location has been entered.
# If True, gathers surf report and displays map
if location:
Expand All @@ -72,8 +78,8 @@
# Writes the GPT response
if gpt_response is not None:
st.write(gpt_response)

# Displays the line graph
st.write("# Surf Conditions")
df = sl_help.graph_data(report_dict)
df = sl_help.graph_data(report_dict, graph_type)
st.line_chart(df.rename(columns={"date": "index"}).set_index("index"))
24 changes: 18 additions & 6 deletions src/streamlit_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def map_data(lat, long):
return m


def graph_data(report_dict):
def graph_data(report_dict, graph_type="Height/Period :ocean:"):
"""
Gathers the forecasted dates, heights, period and stores them in a pandas
dataframe. Will be used to display the line chart
Expand All @@ -71,11 +71,23 @@ def graph_data(report_dict):
forecasted_periods = [
forecast["period"] for forecast in report_dict["Forecast"]
]
forecasted_directions = [
forecast["direction"] for forecast in report_dict["Forecast"]
]
# table
df = pd.DataFrame({
"date": forecasted_dates,
"heights": forecasted_heights,
"periods": forecasted_periods,
})
if graph_type == "Height/Period :ocean:" or graph_type == None:
df = pd.DataFrame({
"date": forecasted_dates,
"heights": forecasted_heights,
"periods": forecasted_periods,
})
else:
df = pd.DataFrame({
"date": forecasted_dates,
"directions": forecasted_directions
})

return df



1 comment on commit 4b260d1

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src
   __init__.py00100% 
   api.py86693%30, 48, 70–71, 103–104
   art.py9367%24–25, 37
   cli.py25580%26, 37, 55–56, 60
   dev_streamlit.py37370%1–85
   gpt.py10640%16–21, 32–45
   helper.py1455264%50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 81, 92–96, 129–137, 149, 162–163, 181–183, 193, 195–196, 219–220, 258–268, 275–283
   send_email.py24240%5–48
   server.py41410%5–82
   settings.py220100% 
   streamlit_helper.py33330%5–90
TOTAL43220752% 

Tests Skipped Failures Errors Time
9 0 💤 0 ❌ 0 🔥 14.929s ⏱️

Please sign in to comment.