Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
-
import pandas as pd
|
| 4 |
-
import streamlit_option_menu as option_menu
|
| 5 |
|
| 6 |
# Configuración de la página
|
| 7 |
st.set_page_config(page_title="Generador de Gráficos", layout="wide")
|
|
@@ -16,30 +14,42 @@ st.markdown(
|
|
| 16 |
.css-1aumxhk {
|
| 17 |
display: none;
|
| 18 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</style>
|
| 20 |
""",
|
| 21 |
unsafe_allow_html=True,
|
| 22 |
)
|
| 23 |
|
| 24 |
# Sidebar para la configuración del gráfico
|
| 25 |
-
|
| 26 |
-
selected = option_menu.option_menu(
|
| 27 |
-
menu_title="Configuración del Gráfico",
|
| 28 |
-
options=["Línea", "Barras"],
|
| 29 |
-
icons=["graph-up", "bar-chart"],
|
| 30 |
-
menu_icon="cast",
|
| 31 |
-
default_index=0,
|
| 32 |
-
)
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
st.
|
| 36 |
|
| 37 |
# Ingresar valores para el eje X
|
| 38 |
-
x_values = st.text_area("Valores para X (separados por comas)", "2013,2014,2015,2016,2017")
|
| 39 |
x = [int(i) for i in x_values.split(",")]
|
| 40 |
|
| 41 |
# Ingresar valores para el eje Y
|
| 42 |
-
y_values = st.text_area("Valores para Y (separados por comas)", "10,18,5,9,12")
|
| 43 |
y = [int(i) for i in y_values.split(",")]
|
| 44 |
|
| 45 |
# Verificar si las listas tienen el mismo tamaño
|
|
@@ -47,14 +57,14 @@ if len(x) != len(y):
|
|
| 47 |
st.error("Los valores de X y Y deben tener la misma cantidad de elementos.")
|
| 48 |
else:
|
| 49 |
# Generar el gráfico basado en el tipo seleccionado
|
| 50 |
-
if
|
| 51 |
fig, ax = plt.subplots()
|
| 52 |
ax.plot(x, y, color='#FF5C5C', linewidth=2)
|
| 53 |
ax.set_title("Line Chart", fontsize=20, fontweight='bold')
|
| 54 |
ax.grid(True, linestyle='--', alpha=0.5)
|
| 55 |
st.pyplot(fig)
|
| 56 |
|
| 57 |
-
elif
|
| 58 |
fig, ax = plt.subplots()
|
| 59 |
ax.bar(x, y, color='#5CCFFF', edgecolor='blue', linewidth=2)
|
| 60 |
ax.set_title("Bar Chart", fontsize=20, fontweight='bold')
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# Configuración de la página
|
| 5 |
st.set_page_config(page_title="Generador de Gráficos", layout="wide")
|
|
|
|
| 14 |
.css-1aumxhk {
|
| 15 |
display: none;
|
| 16 |
}
|
| 17 |
+
.css-1d391kg {
|
| 18 |
+
padding: 2rem 1rem 1rem 1rem;
|
| 19 |
+
}
|
| 20 |
+
.stButton>button {
|
| 21 |
+
background-color: #4CAF50;
|
| 22 |
+
color: white;
|
| 23 |
+
border: none;
|
| 24 |
+
padding: 10px 24px;
|
| 25 |
+
text-align: center;
|
| 26 |
+
text-decoration: none;
|
| 27 |
+
display: inline-block;
|
| 28 |
+
font-size: 16px;
|
| 29 |
+
margin: 4px 2px;
|
| 30 |
+
cursor: pointer;
|
| 31 |
+
border-radius: 12px;
|
| 32 |
+
}
|
| 33 |
+
.stButton>button:hover {
|
| 34 |
+
background-color: #45a049;
|
| 35 |
+
}
|
| 36 |
</style>
|
| 37 |
""",
|
| 38 |
unsafe_allow_html=True,
|
| 39 |
)
|
| 40 |
|
| 41 |
# Sidebar para la configuración del gráfico
|
| 42 |
+
st.sidebar.header("Configuración del Gráfico")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
# Tipo de gráfico
|
| 45 |
+
chart_type = st.sidebar.selectbox("Tipo de Gráfico", ["Línea", "Barras"])
|
| 46 |
|
| 47 |
# Ingresar valores para el eje X
|
| 48 |
+
x_values = st.sidebar.text_area("Valores para X (separados por comas)", "2013,2014,2015,2016,2017")
|
| 49 |
x = [int(i) for i in x_values.split(",")]
|
| 50 |
|
| 51 |
# Ingresar valores para el eje Y
|
| 52 |
+
y_values = st.sidebar.text_area("Valores para Y (separados por comas)", "10,18,5,9,12")
|
| 53 |
y = [int(i) for i in y_values.split(",")]
|
| 54 |
|
| 55 |
# Verificar si las listas tienen el mismo tamaño
|
|
|
|
| 57 |
st.error("Los valores de X y Y deben tener la misma cantidad de elementos.")
|
| 58 |
else:
|
| 59 |
# Generar el gráfico basado en el tipo seleccionado
|
| 60 |
+
if chart_type == "Línea":
|
| 61 |
fig, ax = plt.subplots()
|
| 62 |
ax.plot(x, y, color='#FF5C5C', linewidth=2)
|
| 63 |
ax.set_title("Line Chart", fontsize=20, fontweight='bold')
|
| 64 |
ax.grid(True, linestyle='--', alpha=0.5)
|
| 65 |
st.pyplot(fig)
|
| 66 |
|
| 67 |
+
elif chart_type == "Barras":
|
| 68 |
fig, ax = plt.subplots()
|
| 69 |
ax.bar(x, y, color='#5CCFFF', edgecolor='blue', linewidth=2)
|
| 70 |
ax.set_title("Bar Chart", fontsize=20, fontweight='bold')
|