Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -51,12 +51,16 @@ for y_name, (start_date, end_date) in y_values.items():
|
|
| 51 |
|
| 52 |
data = pd.DataFrame(data_list)
|
| 53 |
|
| 54 |
-
# Crear gráfico
|
| 55 |
-
fig = px.timeline(data, x_start="Start", x_end="End", y="Variable", color="Variable", title=chart_title
|
|
|
|
|
|
|
| 56 |
fig.update_yaxes(categoryorder="total ascending")
|
| 57 |
|
| 58 |
# Personalizar el formato de tiempo en el eje X
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
fig.update_layout(
|
| 61 |
xaxis_title="Tiempo",
|
| 62 |
yaxis_title="Variables",
|
|
@@ -75,6 +79,10 @@ fig.update_layout(
|
|
| 75 |
font=dict(family="Times New Roman", size=18, color="black")
|
| 76 |
)
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# Mostrar el gráfico
|
| 79 |
st.plotly_chart(fig)
|
| 80 |
|
|
|
|
| 51 |
|
| 52 |
data = pd.DataFrame(data_list)
|
| 53 |
|
| 54 |
+
# Crear gráfico de franjas de tiempo
|
| 55 |
+
fig = px.timeline(data, x_start="Start", x_end="End", y="Variable", color="Variable", title=chart_title)
|
| 56 |
+
|
| 57 |
+
# Actualizar el diseño del gráfico
|
| 58 |
fig.update_yaxes(categoryorder="total ascending")
|
| 59 |
|
| 60 |
# Personalizar el formato de tiempo en el eje X
|
| 61 |
+
if time_format == "Año":
|
| 62 |
+
tickformat = "%Y"
|
| 63 |
+
|
| 64 |
fig.update_layout(
|
| 65 |
xaxis_title="Tiempo",
|
| 66 |
yaxis_title="Variables",
|
|
|
|
| 79 |
font=dict(family="Times New Roman", size=18, color="black")
|
| 80 |
)
|
| 81 |
|
| 82 |
+
# Aplicar apilamiento manualmente si está habilitado
|
| 83 |
+
if stacked:
|
| 84 |
+
fig.update_layout(barmode='stack')
|
| 85 |
+
|
| 86 |
# Mostrar el gráfico
|
| 87 |
st.plotly_chart(fig)
|
| 88 |
|