tx3bas commited on
Commit
144a23b
·
verified ·
1 Parent(s): 47710b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -42,6 +42,9 @@ st.sidebar.header("Configuración del Gráfico")
42
  # Título del gráfico
43
  chart_title = st.sidebar.text_input("Título del Gráfico", "Generador de Gráfico")
44
 
 
 
 
45
  # Ingresar valores para los ejes
46
  x_values = st.sidebar.text_area("Valores para X (separados por comas)", "2013,2014,2015,2016,2017,2018")
47
  x = x_values.split(",")
@@ -65,7 +68,6 @@ y_label = st.sidebar.text_input("Etiqueta para el eje Y", "Y")
65
 
66
  # Desplegable de opciones adicionales
67
  with st.sidebar.expander("Opciones Adicionales"):
68
- chart_type = st.selectbox("Tipo de Gráfico", ["Línea", "Área", "Dispersión", "Barras", "Donut"])
69
  graph_width = st.slider("Ancho del Gráfico", min_value=400, max_value=1000, value=800, step=50)
70
  graph_height = st.slider("Alto del Gráfico", min_value=300, max_value=800, value=600, step=50)
71
  font_family = st.selectbox("Fuente", font_options, index=font_options.index("Times New Roman"))
@@ -85,6 +87,10 @@ if chart_type == "Donut":
85
  else:
86
  hole_size = 0
87
 
 
 
 
 
88
  # Definir colores
89
  if use_multiple_colors:
90
  num_colors = max(len(y_values_list), len(x))
@@ -131,10 +137,6 @@ else:
131
  # Personalizar el hovertemplate
132
  hovertemplate = '<b>%{y}</b>'
133
 
134
- # Opciones específicas para gráficos de barras
135
- if chart_type == "Barras" and num_y_vars > 1:
136
- bar_mode = st.sidebar.radio("Modo de Barras", ["Normal", "Superpuestas"])
137
-
138
  # Generar el gráfico basado en el tipo seleccionado
139
  if chart_type == "Línea":
140
  fig = px.line(data, x="X", y=y_names_list, line_shape="spline")
@@ -179,7 +181,7 @@ else:
179
  for y_name in y_names_list:
180
  fig = px.pie(data, values=y_name, names="X", hole=hole_size)
181
  fig.update_traces(hovertemplate='<b>%{label}</b>: %{value} (%{percent})', textinfo='percent+label')
182
- fig.update_layout(title=f"{chart_title} - {y_name}")
183
  fig.update_layout(**common_layout)
184
  figs.append(fig)
185
  for fig in figs:
 
42
  # Título del gráfico
43
  chart_title = st.sidebar.text_input("Título del Gráfico", "Generador de Gráfico")
44
 
45
+ # Tipo de gráfico
46
+ chart_type = st.sidebar.selectbox("Tipo de Gráfico", ["Línea", "Área", "Dispersión", "Barras", "Donut"])
47
+
48
  # Ingresar valores para los ejes
49
  x_values = st.sidebar.text_area("Valores para X (separados por comas)", "2013,2014,2015,2016,2017,2018")
50
  x = x_values.split(",")
 
68
 
69
  # Desplegable de opciones adicionales
70
  with st.sidebar.expander("Opciones Adicionales"):
 
71
  graph_width = st.slider("Ancho del Gráfico", min_value=400, max_value=1000, value=800, step=50)
72
  graph_height = st.slider("Alto del Gráfico", min_value=300, max_value=800, value=600, step=50)
73
  font_family = st.selectbox("Fuente", font_options, index=font_options.index("Times New Roman"))
 
87
  else:
88
  hole_size = 0
89
 
90
+ # Opciones específicas para gráficos de barras
91
+ if chart_type == "Barras" and num_y_vars > 1:
92
+ bar_mode = st.sidebar.radio("Modo de Barras", ["Normal", "Superpuestas"])
93
+
94
  # Definir colores
95
  if use_multiple_colors:
96
  num_colors = max(len(y_values_list), len(x))
 
137
  # Personalizar el hovertemplate
138
  hovertemplate = '<b>%{y}</b>'
139
 
 
 
 
 
140
  # Generar el gráfico basado en el tipo seleccionado
141
  if chart_type == "Línea":
142
  fig = px.line(data, x="X", y=y_names_list, line_shape="spline")
 
181
  for y_name in y_names_list:
182
  fig = px.pie(data, values=y_name, names="X", hole=hole_size)
183
  fig.update_traces(hovertemplate='<b>%{label}</b>: %{value} (%{percent})', textinfo='percent+label')
184
+ fig.update_layout(title=chart_title)
185
  fig.update_layout(**common_layout)
186
  figs.append(fig)
187
  for fig in figs: