Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,29 +30,41 @@ def fetch_esg_data(company_name):
|
|
30 |
else:
|
31 |
return pd.DataFrame(), None
|
32 |
|
33 |
-
# Gradio interface with
|
34 |
def app_interface():
|
35 |
with gr.Blocks() as app:
|
36 |
gr.Markdown("# ESG Data Explorer")
|
|
|
37 |
with gr.Tab("ESG Data"):
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
plot_button = gr.Button("Generate ESG Plot")
|
|
|
|
|
46 |
line_plot = gr.LinePlot(label="ESG Scores Line Plot", x="ESG Category", y="Score", overlay_point=True)
|
47 |
scatter_plot = gr.ScatterPlot(label="ESG Scores Scatter Plot", x="ESG Category", y="Score", overlay_point=True)
|
|
|
|
|
48 |
csv_output = gr.File(label="Download CSV")
|
|
|
|
|
49 |
plot_button.click(fn=fetch_esg_data, inputs=company, outputs=[line_plot, csv_output, scatter_plot])
|
|
|
|
|
50 |
with gr.Tab("Tab 2"):
|
51 |
gr.Markdown("Content for Tab 2 goes here.")
|
|
|
52 |
with gr.Tab("Tab 3"):
|
53 |
gr.Markdown("Content for Tab 3 goes here.")
|
|
|
54 |
with gr.Tab("Tab 4"):
|
55 |
gr.Markdown("Content for Tab 4 goes here.")
|
|
|
56 |
return app
|
57 |
|
58 |
# Launch the Gradio app
|
|
|
30 |
else:
|
31 |
return pd.DataFrame(), None
|
32 |
|
33 |
+
# Gradio interface with a dropdown and file download option
|
34 |
def app_interface():
|
35 |
with gr.Blocks() as app:
|
36 |
gr.Markdown("# ESG Data Explorer")
|
37 |
+
|
38 |
with gr.Tab("ESG Data"):
|
39 |
+
company = gr.Dropdown(
|
40 |
+
label="Select Company",
|
41 |
+
choices=list(company_dict.keys()), # Show company names
|
42 |
+
value="Apple", # Default value
|
43 |
+
interactive=True # Make it interactive
|
44 |
+
)
|
45 |
+
|
46 |
plot_button = gr.Button("Generate ESG Plot")
|
47 |
+
|
48 |
+
# Graphs for ESG scores
|
49 |
line_plot = gr.LinePlot(label="ESG Scores Line Plot", x="ESG Category", y="Score", overlay_point=True)
|
50 |
scatter_plot = gr.ScatterPlot(label="ESG Scores Scatter Plot", x="ESG Category", y="Score", overlay_point=True)
|
51 |
+
|
52 |
+
# File output for CSV download
|
53 |
csv_output = gr.File(label="Download CSV")
|
54 |
+
|
55 |
+
# Define the action when the "Generate ESG Plot" button is clicked
|
56 |
plot_button.click(fn=fetch_esg_data, inputs=company, outputs=[line_plot, csv_output, scatter_plot])
|
57 |
+
|
58 |
+
# Additional tabs for other content
|
59 |
with gr.Tab("Tab 2"):
|
60 |
gr.Markdown("Content for Tab 2 goes here.")
|
61 |
+
|
62 |
with gr.Tab("Tab 3"):
|
63 |
gr.Markdown("Content for Tab 3 goes here.")
|
64 |
+
|
65 |
with gr.Tab("Tab 4"):
|
66 |
gr.Markdown("Content for Tab 4 goes here.")
|
67 |
+
|
68 |
return app
|
69 |
|
70 |
# Launch the Gradio app
|