From e0794aabd5316ea5a6d324280d83a76b1ebe6c27 Mon Sep 17 00:00:00 2001 From: Anushka Pote <101658241+Anushka-Pote@users.noreply.github.com> Date: Fri, 1 Nov 2024 23:01:40 +0530 Subject: [PATCH] Update visualize.py --- visualize.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/visualize.py b/visualize.py index d727505..b52c544 100644 --- a/visualize.py +++ b/visualize.py @@ -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()