Skip to content

Commit

Permalink
Merge pull request #102 from Anushka-Pote/main
Browse files Browse the repository at this point in the history
Downloadable Visualizations #99
  • Loading branch information
Devanik21 authored Nov 12, 2024
2 parents d3ffdc5 + e0794aa commit aa06981
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,25 @@ def show_visualize_page():
# Use a color gradient for the 'adjusted_score' column for better visual appeal
st.write(top_sites_display.style.background_gradient(subset=['adjusted_score'], cmap='coolwarm'))

# Downloadable Visualization
if st.button("Download Visualization"):
fig.savefig("visualization.png") # Save the current figure
with open("visualization.png", "rb") as file:
st.download_button(
label="Download Chart",
data=file,
file_name="visualization.png",
mime="image/png"
)

# Downloadable Data
if st.button("Download Data"):
csv = data.to_csv(index=False)
st.download_button(
label="Download CSV",
data=csv,
file_name="space_mining_data.csv",
mime="text/csv"
)

show_visualize_page()

0 comments on commit aa06981

Please sign in to comment.