Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,9 @@ predefined_colors = [
|
|
| 33 |
# Sidebar para la configuración del gráfico
|
| 34 |
st.sidebar.header("Configuración del Gráfico")
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
# Tipo de gráfico
|
| 37 |
chart_type = st.sidebar.selectbox("Tipo de Gráfico", ["Línea", "Barras", "Dispersión", "Área", "Pastel"])
|
| 38 |
|
|
@@ -95,24 +98,24 @@ else:
|
|
| 95 |
|
| 96 |
# Generar el gráfico basado en el tipo seleccionado
|
| 97 |
if chart_type == "Línea":
|
| 98 |
-
fig = px.line(data, x="X", y="Y", title=
|
| 99 |
if not use_multiple_colors:
|
| 100 |
fig.update_traces(line_color=color)
|
| 101 |
elif chart_type == "Barras":
|
| 102 |
-
fig = px.bar(data, x="X", y="Y", title=
|
| 103 |
if not use_multiple_colors:
|
| 104 |
fig.update_traces(marker_color=color, marker_line_color=border_color, marker_line_width=1.5)
|
| 105 |
fig.update_layout(bargap=0.2) # Ajustar el espacio entre las barras
|
| 106 |
elif chart_type == "Dispersión":
|
| 107 |
-
fig = px.scatter(data, x="X", y="Y", title=
|
| 108 |
if not use_multiple_colors:
|
| 109 |
fig.update_traces(marker_color=color)
|
| 110 |
elif chart_type == "Área":
|
| 111 |
-
fig = px.area(data, x="X", y="Y", title=
|
| 112 |
if not use_multiple_colors:
|
| 113 |
fig.update_traces(fillcolor=color, line_color=border_color)
|
| 114 |
elif chart_type == "Pastel":
|
| 115 |
-
fig = px.pie(data, values="Y", names="X", title=
|
| 116 |
if not use_multiple_colors:
|
| 117 |
fig.update_traces(marker=dict(colors=[color]*len(x)))
|
| 118 |
|
|
|
|
| 33 |
# Sidebar para la configuración del gráfico
|
| 34 |
st.sidebar.header("Configuración del Gráfico")
|
| 35 |
|
| 36 |
+
# Título del gráfico
|
| 37 |
+
chart_title = st.sidebar.text_input("Título del Gráfico", "Generador de Gráfico")
|
| 38 |
+
|
| 39 |
# Tipo de gráfico
|
| 40 |
chart_type = st.sidebar.selectbox("Tipo de Gráfico", ["Línea", "Barras", "Dispersión", "Área", "Pastel"])
|
| 41 |
|
|
|
|
| 98 |
|
| 99 |
# Generar el gráfico basado en el tipo seleccionado
|
| 100 |
if chart_type == "Línea":
|
| 101 |
+
fig = px.line(data, x="X", y="Y", title=chart_title, line_shape="spline", hover_name="Nombre" if names else None)
|
| 102 |
if not use_multiple_colors:
|
| 103 |
fig.update_traces(line_color=color)
|
| 104 |
elif chart_type == "Barras":
|
| 105 |
+
fig = px.bar(data, x="X", y="Y", title=chart_title, hover_name="Nombre" if names else None)
|
| 106 |
if not use_multiple_colors:
|
| 107 |
fig.update_traces(marker_color=color, marker_line_color=border_color, marker_line_width=1.5)
|
| 108 |
fig.update_layout(bargap=0.2) # Ajustar el espacio entre las barras
|
| 109 |
elif chart_type == "Dispersión":
|
| 110 |
+
fig = px.scatter(data, x="X", y="Y", title=chart_title, hover_name="Nombre" if names else None)
|
| 111 |
if not use_multiple_colors:
|
| 112 |
fig.update_traces(marker_color=color)
|
| 113 |
elif chart_type == "Área":
|
| 114 |
+
fig = px.area(data, x="X", y="Y", title=chart_title, line_shape="spline", hover_name="Nombre" if names else None)
|
| 115 |
if not use_multiple_colors:
|
| 116 |
fig.update_traces(fillcolor=color, line_color=border_color)
|
| 117 |
elif chart_type == "Pastel":
|
| 118 |
+
fig = px.pie(data, values="Y", names="X", title=chart_title, hover_name="Nombre" if names else None)
|
| 119 |
if not use_multiple_colors:
|
| 120 |
fig.update_traces(marker=dict(colors=[color]*len(x)))
|
| 121 |
|