Manasa1 commited on
Commit
5c75aef
·
verified ·
1 Parent(s): 8e4352d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
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, scatter 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 Plots")
53
 
54
  # LinePlot component for displaying the ESG data
55
- line_plot_output = gr.LinePlot(label="ESG Scores Line Plot", x="ESG Category", y="Score", overlay_point=True)
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=[line_plot_output, scatter_plot_output, csv_output])
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()