Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1378,6 +1378,12 @@ def actualizar_graficos(ciudad):
|
|
1378 |
), "Brecha Salarial de Género", "%", ".1f")
|
1379 |
]
|
1380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1381 |
with gr.Blocks(
|
1382 |
title="Análisis Mercado Laboral Peruano",
|
1383 |
css="""
|
@@ -1385,6 +1391,7 @@ with gr.Blocks(
|
|
1385 |
.card {border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; margin: 10px 0; background: white}
|
1386 |
.header {font-size: 28px; font-weight: bold; color: #2c3e50; margin-bottom: 20px}
|
1387 |
.subheader {font-size: 20px; color: #3498db; margin: 15px 0}
|
|
|
1388 |
"""
|
1389 |
) as app:
|
1390 |
|
@@ -1398,31 +1405,34 @@ with gr.Blocks(
|
|
1398 |
interactive=True
|
1399 |
)
|
1400 |
|
1401 |
-
|
|
|
1402 |
with gr.Column(elem_classes="card"):
|
1403 |
gr.Markdown("## 📍 Indicadores Clave", elem_classes="subheader")
|
1404 |
-
radar_plot = Plot(
|
1405 |
|
1406 |
with gr.Column(elem_classes="card"):
|
1407 |
gr.Markdown("## 📈 Tendencias Principales", elem_classes="subheader")
|
1408 |
with gr.Row():
|
1409 |
-
desempleo_plot = Plot(
|
1410 |
-
ingresos_plot = Plot(
|
1411 |
with gr.Row():
|
1412 |
-
informalidad_plot = Plot(
|
1413 |
-
actividad_plot = Plot(
|
1414 |
|
1415 |
with gr.Column(elem_classes="card"):
|
1416 |
gr.Markdown("## 📉 Brecha Salarial", elem_classes="subheader")
|
1417 |
-
brecha_plot = Plot(
|
1418 |
|
1419 |
-
|
|
|
1420 |
with gr.Column(elem_classes="card"):
|
1421 |
gr.Markdown("## 🏙️ Comparativa entre Ciudades", elem_classes="subheader")
|
1422 |
-
global_desempleo = Plot(
|
1423 |
-
global_ingresos = Plot(
|
1424 |
-
global_brecha = Plot(
|
1425 |
-
|
|
|
1426 |
ciudad.change(
|
1427 |
fn=actualizar_graficos,
|
1428 |
inputs=ciudad,
|
@@ -1430,7 +1440,19 @@ with gr.Blocks(
|
|
1430 |
)
|
1431 |
|
1432 |
@app.load()
|
1433 |
-
def
|
1434 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1435 |
|
1436 |
-
app.launch(debug=True)
|
|
|
1378 |
), "Brecha Salarial de Género", "%", ".1f")
|
1379 |
]
|
1380 |
|
1381 |
+
def cargar_datos_iniciales():
|
1382 |
+
# Generar datos iniciales para ambas pestañas
|
1383 |
+
datos_ciudad = actualizar_graficos("Chimbote")
|
1384 |
+
datos_global = generar_analisis_global()
|
1385 |
+
return [*datos_ciudad, *datos_global]
|
1386 |
+
|
1387 |
with gr.Blocks(
|
1388 |
title="Análisis Mercado Laboral Peruano",
|
1389 |
css="""
|
|
|
1391 |
.card {border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; margin: 10px 0; background: white}
|
1392 |
.header {font-size: 28px; font-weight: bold; color: #2c3e50; margin-bottom: 20px}
|
1393 |
.subheader {font-size: 20px; color: #3498db; margin: 15px 0}
|
1394 |
+
.plot-container {min-height: 500px}
|
1395 |
"""
|
1396 |
) as app:
|
1397 |
|
|
|
1405 |
interactive=True
|
1406 |
)
|
1407 |
|
1408 |
+
# Componentes para la pestaña de Ciudad
|
1409 |
+
with gr.Tab("Análisis por Ciudad") as tab_ciudad:
|
1410 |
with gr.Column(elem_classes="card"):
|
1411 |
gr.Markdown("## 📍 Indicadores Clave", elem_classes="subheader")
|
1412 |
+
radar_plot = Plot(elem_classes="plot-container")
|
1413 |
|
1414 |
with gr.Column(elem_classes="card"):
|
1415 |
gr.Markdown("## 📈 Tendencias Principales", elem_classes="subheader")
|
1416 |
with gr.Row():
|
1417 |
+
desempleo_plot = Plot(elem_classes="plot-container")
|
1418 |
+
ingresos_plot = Plot(elem_classes="plot-container")
|
1419 |
with gr.Row():
|
1420 |
+
informalidad_plot = Plot(elem_classes="plot-container")
|
1421 |
+
actividad_plot = Plot(elem_classes="plot-container")
|
1422 |
|
1423 |
with gr.Column(elem_classes="card"):
|
1424 |
gr.Markdown("## 📉 Brecha Salarial", elem_classes="subheader")
|
1425 |
+
brecha_plot = Plot(elem_classes="plot-container")
|
1426 |
|
1427 |
+
# Componentes para la pestaña Comparativa
|
1428 |
+
with gr.Tab("Análisis Comparativo") as tab_comparativo:
|
1429 |
with gr.Column(elem_classes="card"):
|
1430 |
gr.Markdown("## 🏙️ Comparativa entre Ciudades", elem_classes="subheader")
|
1431 |
+
global_desempleo = Plot(elem_classes="plot-container")
|
1432 |
+
global_ingresos = Plot(elem_classes="plot-container")
|
1433 |
+
global_brecha = Plot(elem_classes="plot-container")
|
1434 |
+
|
1435 |
+
# Configurar eventos y carga inicial
|
1436 |
ciudad.change(
|
1437 |
fn=actualizar_graficos,
|
1438 |
inputs=ciudad,
|
|
|
1440 |
)
|
1441 |
|
1442 |
@app.load()
|
1443 |
+
def inicializar_aplicacion():
|
1444 |
+
# Cargar datos para ambas pestañas
|
1445 |
+
datos = cargar_datos_iniciales()
|
1446 |
+
return {
|
1447 |
+
radar_plot: datos[0],
|
1448 |
+
desempleo_plot: datos[1],
|
1449 |
+
ingresos_plot: datos[2],
|
1450 |
+
informalidad_plot: datos[3],
|
1451 |
+
actividad_plot: datos[4],
|
1452 |
+
brecha_plot: datos[5],
|
1453 |
+
global_desempleo: datos[6],
|
1454 |
+
global_ingresos: datos[7],
|
1455 |
+
global_brecha: datos[8]
|
1456 |
+
}
|
1457 |
|
1458 |
+
app.launch(debug=True, show_error=True)
|