Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -42,20 +42,17 @@ def fetch_esg_data(company_name):
|
|
42 |
# Return an empty DataFrame and None if no data is available
|
43 |
return pd.DataFrame(), None
|
44 |
|
45 |
-
# Gradio interface with a dropdown for company selection, line plot
|
46 |
def app_interface():
|
47 |
with gr.Blocks() as app:
|
48 |
# Dropdown to select company name
|
49 |
company = gr.Dropdown(label="Select Company", choices=list(company_dict.keys()), value="Apple")
|
50 |
|
51 |
# Button to fetch and plot ESG data
|
52 |
-
plot_button = gr.Button("Generate ESG
|
53 |
|
54 |
# LinePlot component for displaying the ESG data
|
55 |
-
|
56 |
-
|
57 |
-
# ScatterPlot component for displaying the ESG data
|
58 |
-
scatter_plot_output = gr.ScatterPlot(label="ESG Scores Scatter Plot", x="ESG Category", y="Score", overlay_point=True)
|
59 |
|
60 |
# Textbox to display messages
|
61 |
message = gr.Textbox(label="Message", interactive=False)
|
@@ -66,11 +63,10 @@ def app_interface():
|
|
66 |
# Define the action when the "Generate ESG Plot" button is clicked
|
67 |
plot_button.click(fn=fetch_esg_data,
|
68 |
inputs=company,
|
69 |
-
outputs=[
|
70 |
|
71 |
return app
|
72 |
|
73 |
# Launch the Gradio app
|
74 |
app = app_interface()
|
75 |
app.launch()
|
76 |
-
|
|
|
42 |
# Return an empty DataFrame and None if no data is available
|
43 |
return pd.DataFrame(), None
|
44 |
|
45 |
+
# Gradio interface with a dropdown for company selection, line plot visualization, and CSV download
|
46 |
def app_interface():
|
47 |
with gr.Blocks() as app:
|
48 |
# Dropdown to select company name
|
49 |
company = gr.Dropdown(label="Select Company", choices=list(company_dict.keys()), value="Apple")
|
50 |
|
51 |
# Button to fetch and plot ESG data
|
52 |
+
plot_button = gr.Button("Generate ESG Plot")
|
53 |
|
54 |
# LinePlot component for displaying the ESG data
|
55 |
+
plot_output = gr.LinePlot(label="ESG Scores Plot", x="ESG Category", y="Score", overlay_point=True)
|
|
|
|
|
|
|
56 |
|
57 |
# Textbox to display messages
|
58 |
message = gr.Textbox(label="Message", interactive=False)
|
|
|
63 |
# Define the action when the "Generate ESG Plot" button is clicked
|
64 |
plot_button.click(fn=fetch_esg_data,
|
65 |
inputs=company,
|
66 |
+
outputs=[plot_output, csv_output])
|
67 |
|
68 |
return app
|
69 |
|
70 |
# Launch the Gradio app
|
71 |
app = app_interface()
|
72 |
app.launch()
|
|