Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -205,7 +205,6 @@ 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 |
-
# Use gr.update() to create an update dictionary for the CheckboxGroup
|
209 |
return gr.update(
|
210 |
choices=investor_list,
|
211 |
value=investor_list,
|
@@ -217,7 +216,6 @@ def main():
|
|
217 |
country_list = ["All"] + sorted(data["Country"].dropna().unique())
|
218 |
industry_list = ["All"] + sorted(data["Industry"].dropna().unique())
|
219 |
|
220 |
-
# Ensure the default values for dropdowns exist
|
221 |
default_country = "United States" if "United States" in country_list else "All"
|
222 |
default_industry = "Enterprise Tech" if "Enterprise Tech" in industry_list else "All"
|
223 |
|
@@ -226,7 +224,6 @@ def main():
|
|
226 |
|
227 |
with gr.Blocks() as demo:
|
228 |
with gr.Row():
|
229 |
-
# Set default value for country and industry dropdowns
|
230 |
country_filter = gr.Dropdown(choices=country_list, label="Filter by Country", value=default_country)
|
231 |
industry_filter = gr.Dropdown(choices=industry_list, label="Filter by Industry", value=default_industry)
|
232 |
|
@@ -236,7 +233,6 @@ def main():
|
|
236 |
|
237 |
filtered_data_holder = gr.State()
|
238 |
|
239 |
-
# Event handlers for filters
|
240 |
country_filter.change(
|
241 |
app,
|
242 |
inputs=[country_filter, industry_filter],
|
@@ -248,25 +244,24 @@ def main():
|
|
248 |
outputs=[filtered_investor_list, filtered_data_holder]
|
249 |
)
|
250 |
|
251 |
-
# Generate graph when investors are selected
|
252 |
filtered_investor_list.change(
|
253 |
generate_graph,
|
254 |
inputs=[filtered_investor_list, filtered_data_holder],
|
255 |
outputs=graph_output
|
256 |
)
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
if not plotly_event or "points" not in plotly_event or not plotly_event["points"]:
|
261 |
return "Click on a company node to see its valuation."
|
262 |
-
|
263 |
-
|
264 |
-
|
|
|
265 |
return "Click on a company node to see its valuation."
|
266 |
|
267 |
-
graph_output.
|
268 |
fn=display_valuation,
|
269 |
-
inputs=
|
270 |
outputs=valuation_display
|
271 |
)
|
272 |
|
|
|
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,
|
|
|
216 |
country_list = ["All"] + sorted(data["Country"].dropna().unique())
|
217 |
industry_list = ["All"] + sorted(data["Industry"].dropna().unique())
|
218 |
|
|
|
219 |
default_country = "United States" if "United States" in country_list else "All"
|
220 |
default_industry = "Enterprise Tech" if "Enterprise Tech" in industry_list else "All"
|
221 |
|
|
|
224 |
|
225 |
with gr.Blocks() as demo:
|
226 |
with gr.Row():
|
|
|
227 |
country_filter = gr.Dropdown(choices=country_list, label="Filter by Country", value=default_country)
|
228 |
industry_filter = gr.Dropdown(choices=industry_list, label="Filter by Industry", value=default_industry)
|
229 |
|
|
|
233 |
|
234 |
filtered_data_holder = gr.State()
|
235 |
|
|
|
236 |
country_filter.change(
|
237 |
app,
|
238 |
inputs=[country_filter, industry_filter],
|
|
|
244 |
outputs=[filtered_investor_list, filtered_data_holder]
|
245 |
)
|
246 |
|
|
|
247 |
filtered_investor_list.change(
|
248 |
generate_graph,
|
249 |
inputs=[filtered_investor_list, filtered_data_holder],
|
250 |
outputs=graph_output
|
251 |
)
|
252 |
|
253 |
+
def display_valuation(click_data):
|
254 |
+
if not click_data or not click_data.get("points"):
|
|
|
255 |
return "Click on a company node to see its valuation."
|
256 |
+
|
257 |
+
point = click_data["points"][0]
|
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.select(
|
263 |
fn=display_valuation,
|
264 |
+
inputs=graph_output,
|
265 |
outputs=valuation_display
|
266 |
)
|
267 |
|