Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,10 +63,10 @@ selected_color = st.sidebar.color_picker("Color", "#24CBA0", key="single_color")
|
|
| 63 |
|
| 64 |
# Definir colores
|
| 65 |
if use_multiple_colors:
|
| 66 |
-
colors = [
|
| 67 |
for i in range(num_y_vars)]
|
| 68 |
else:
|
| 69 |
-
color =
|
| 70 |
colors = [color] * num_y_vars # Definir colors para casos donde no se usa múltiple colores
|
| 71 |
|
| 72 |
# Opciones adicionales
|
|
@@ -79,15 +79,16 @@ with st.sidebar.expander("Opciones Adicionales"):
|
|
| 79 |
data_list = []
|
| 80 |
for idx, (y_name, (start_date, end_date)) in enumerate(y_values.items()):
|
| 81 |
if start_date and end_date and y_name:
|
|
|
|
|
|
|
| 82 |
data_list.append({
|
| 83 |
'Variable': y_name,
|
| 84 |
'Start': datetime.strptime(start_date, '%Y-%m-%d'),
|
| 85 |
'End': datetime.strptime(end_date, '%Y-%m-%d'),
|
| 86 |
'Category': '' if stacked else y_name, # Eliminar "Apilado" cuando se apilen las franjas
|
| 87 |
-
'Color':
|
| 88 |
-
'Opacity': opacity,
|
| 89 |
'Border Width': border_width,
|
| 90 |
-
'Border Color':
|
| 91 |
})
|
| 92 |
|
| 93 |
data = pd.DataFrame(data_list)
|
|
@@ -104,7 +105,7 @@ fig = px.timeline(data, x_start="Start", x_end="End", y="Category", color="Varia
|
|
| 104 |
|
| 105 |
# Actualizar los colores y estilos de las franjas
|
| 106 |
for idx, row in data.iterrows():
|
| 107 |
-
fig.data[idx].update(marker_color=row['Color']
|
| 108 |
fig.data[idx].update(marker_line=dict(width=row['Border Width'], color=row['Border Color']))
|
| 109 |
|
| 110 |
# Actualizar el diseño del gráfico
|
|
|
|
| 63 |
|
| 64 |
# Definir colores
|
| 65 |
if use_multiple_colors:
|
| 66 |
+
colors = [st.sidebar.color_picker(f"Color {i+1}", predefined_colors[i % len(predefined_colors)], key=f"color_{i}")
|
| 67 |
for i in range(num_y_vars)]
|
| 68 |
else:
|
| 69 |
+
color = selected_color
|
| 70 |
colors = [color] * num_y_vars # Definir colors para casos donde no se usa múltiple colores
|
| 71 |
|
| 72 |
# Opciones adicionales
|
|
|
|
| 79 |
data_list = []
|
| 80 |
for idx, (y_name, (start_date, end_date)) in enumerate(y_values.items()):
|
| 81 |
if start_date and end_date and y_name:
|
| 82 |
+
color_with_opacity = hex_to_rgba(colors[idx], opacity)
|
| 83 |
+
border_color_with_opacity = hex_to_rgba(colors[idx], border_opacity)
|
| 84 |
data_list.append({
|
| 85 |
'Variable': y_name,
|
| 86 |
'Start': datetime.strptime(start_date, '%Y-%m-%d'),
|
| 87 |
'End': datetime.strptime(end_date, '%Y-%m-%d'),
|
| 88 |
'Category': '' if stacked else y_name, # Eliminar "Apilado" cuando se apilen las franjas
|
| 89 |
+
'Color': color_with_opacity, # Asignar color a cada variable con opacidad
|
|
|
|
| 90 |
'Border Width': border_width,
|
| 91 |
+
'Border Color': border_color_with_opacity # Asignar color del borde con opacidad
|
| 92 |
})
|
| 93 |
|
| 94 |
data = pd.DataFrame(data_list)
|
|
|
|
| 105 |
|
| 106 |
# Actualizar los colores y estilos de las franjas
|
| 107 |
for idx, row in data.iterrows():
|
| 108 |
+
fig.data[idx].update(marker_color=row['Color'])
|
| 109 |
fig.data[idx].update(marker_line=dict(width=row['Border Width'], color=row['Border Color']))
|
| 110 |
|
| 111 |
# Actualizar el diseño del gráfico
|