LeonceNsh commited on
Commit
dd373ed
·
verified ·
1 Parent(s): ed81008

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -204,6 +204,7 @@ def generate_graph(selected_investors, filtered_data):
204
  def app(selected_country, selected_industry):
205
  investor_list, filtered_data = filter_investors_by_country_and_industry(selected_country, selected_industry)
206
  logger.info("Updating CheckboxGroup and filtered data holder.")
 
207
  return gr.update(
208
  choices=investor_list,
209
  value=investor_list,
@@ -227,7 +228,7 @@ def main():
227
  industry_filter = gr.Dropdown(choices=industry_list, label="Filter by Industry", value=default_industry)
228
 
229
  filtered_investor_list = gr.CheckboxGroup(choices=[], label="Select Investors", visible=False)
230
- graph_output = gr.Plotly(type="plotly", label="Venture Network Graph") # Use Plotly for interactive graph
231
  valuation_display = gr.Markdown(value="Click on a company node to see its valuation.", label="Company Valuation")
232
 
233
  filtered_data_holder = gr.State()
@@ -250,17 +251,17 @@ def main():
250
  )
251
 
252
  def display_valuation(click_data):
253
- if not click_data or not click_data.get("points"):
254
  return "Click on a company node to see its valuation."
255
-
256
- point = click_data["points"][0]
257
  if "customdata" in point and point["customdata"]:
258
  return f"**Valuation:** {point['customdata']}"
259
  return "Click on a company node to see its valuation."
260
 
261
- graph_output.interactive(
262
  fn=display_valuation,
263
- inputs=graph_output,
264
  outputs=valuation_display
265
  )
266
 
@@ -268,4 +269,3 @@ def main():
268
 
269
  if __name__ == "__main__":
270
  main()
271
-
 
204
  def app(selected_country, selected_industry):
205
  investor_list, filtered_data = filter_investors_by_country_and_industry(selected_country, selected_industry)
206
  logger.info("Updating CheckboxGroup and filtered data holder.")
207
+
208
  return gr.update(
209
  choices=investor_list,
210
  value=investor_list,
 
228
  industry_filter = gr.Dropdown(choices=industry_list, label="Filter by Industry", value=default_industry)
229
 
230
  filtered_investor_list = gr.CheckboxGroup(choices=[], label="Select Investors", visible=False)
231
+ graph_output = gr.Plot(label="Venture Network Graph")
232
  valuation_display = gr.Markdown(value="Click on a company node to see its valuation.", label="Company Valuation")
233
 
234
  filtered_data_holder = gr.State()
 
251
  )
252
 
253
  def display_valuation(click_data):
254
+ if not click_data:
255
  return "Click on a company node to see its valuation."
256
+ # click_data is a list of dictionaries
257
+ point = click_data[0] # Get the first point clicked
258
  if "customdata" in point and point["customdata"]:
259
  return f"**Valuation:** {point['customdata']}"
260
  return "Click on a company node to see its valuation."
261
 
262
+ graph_output.plotly_events(
263
  fn=display_valuation,
264
+ inputs=None,
265
  outputs=valuation_display
266
  )
267
 
 
269
 
270
  if __name__ == "__main__":
271
  main()