viewx 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {viewx-0.2.0 → viewx-0.2.2}/PKG-INFO +66 -106
- {viewx-0.2.0 → viewx-0.2.2}/README.md +65 -104
- {viewx-0.2.0 → viewx-0.2.2}/setup.py +2 -3
- viewx-0.2.2/tests/test1.py +150 -0
- viewx-0.2.2/tests/test4.py +74 -0
- viewx-0.2.2/tests/test7.py +1514 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/DataMatrix/datamatrix_engine.py +3 -0
- viewx-0.2.2/viewx/HTML/html_engine.py +1355 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/__init__.py +3 -5
- {viewx-0.2.0 → viewx-0.2.2}/viewx.egg-info/PKG-INFO +66 -106
- {viewx-0.2.0 → viewx-0.2.2}/viewx.egg-info/SOURCES.txt +1 -3
- {viewx-0.2.0 → viewx-0.2.2}/viewx.egg-info/requires.txt +0 -1
- viewx-0.2.0/tests/test1.py +0 -65
- viewx-0.2.0/tests/test4.py +0 -150
- viewx-0.2.0/viewx/DashBoard/__init__.py +0 -5
- viewx-0.2.0/viewx/DashBoard/dashboard_engine.py +0 -409
- viewx-0.2.0/viewx/HTML/html_engine.py +0 -448
- viewx-0.2.0/viewx/app_engine.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/setup.cfg +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/tests/test2.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/tests/test3.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/tests/test5.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/tests/test6.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/DataMatrix/__init__.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/DataMatrix/bibliometrics.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/DataMatrix/visualizer.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/HTML/__init__.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/Report/__init__.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/Report/report_engine.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/Slides/__init__.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/Slides/charts.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/Slides/components.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/Slides/slides_engine.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/datasets/__init__.py +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/datasets/course_completion.csv +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/datasets/iris.csv +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/datasets/penguins.csv +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/datasets/sp500_companies.csv +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx/datasets/titanic.csv +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx.egg-info/dependency_links.txt +0 -0
- {viewx-0.2.0 → viewx-0.2.2}/viewx.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: viewx
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Librería de visualización adaptable para HTML, Dashboards y PDFs en Python
|
|
5
5
|
Home-page: https://github.com/GhostAnalyst30/ViewX
|
|
6
6
|
Author: Emmanuel Ascendra Perez
|
|
@@ -26,7 +26,6 @@ Requires-Dist: pylatex>=1.4.2
|
|
|
26
26
|
Requires-Dist: seaborn>=0.12.2
|
|
27
27
|
Requires-Dist: plotly>=6.0.0
|
|
28
28
|
Requires-Dist: streamlit>=1.32.0
|
|
29
|
-
Requires-Dist: statslibx>=0.2.2
|
|
30
29
|
Provides-Extra: streamlit
|
|
31
30
|
Requires-Dist: streamlit>=1.32.0; extra == "streamlit"
|
|
32
31
|
Provides-Extra: dash
|
|
@@ -53,7 +52,7 @@ Dynamic: requires-dist
|
|
|
53
52
|
Dynamic: requires-python
|
|
54
53
|
Dynamic: summary
|
|
55
54
|
|
|
56
|
-
#
|
|
55
|
+
# ViewX — v2.2
|
|
57
56
|
|
|
58
57
|
**ViewX** es un paquete moderno de Python diseñado para generar **páginas HTML interactivas**, **dashboards dinámicos** y **visualizaciones inteligentes** que se adaptan automáticamente a los objetos agregados por el usuario.
|
|
59
58
|
|
|
@@ -61,15 +60,14 @@ Este proyecto ofrece una solución **ligera, intuitiva y escalable**, ideal para
|
|
|
61
60
|
|
|
62
61
|
---
|
|
63
62
|
|
|
64
|
-
##
|
|
63
|
+
## Características principales
|
|
65
64
|
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
- 🔮 **Visión a futuro**: pensado para expandirse a interfaces inteligentes.
|
|
65
|
+
- **Rápido y minimalista**: cero dependencias pesadas por defecto.
|
|
66
|
+
- **API intuitiva**: crea páginas y dashboards en segundos.
|
|
67
|
+
- **Diseño adaptativo**: cada componente se acomoda automáticamente.
|
|
68
|
+
- **Modo HTML**: genera páginas `.html` totalmente autónomas.
|
|
69
|
+
- **Extensible**: añade tus propias plantillas y módulos personalizados.
|
|
70
|
+
- **Visión a futuro**: pensado para expandirse a interfaces inteligentes.
|
|
73
71
|
|
|
74
72
|
---
|
|
75
73
|
|
|
@@ -78,125 +76,87 @@ Este proyecto ofrece una solución **ligera, intuitiva y escalable**, ideal para
|
|
|
78
76
|
pip install viewx
|
|
79
77
|
```
|
|
80
78
|
|
|
81
|
-
##
|
|
79
|
+
## Ejemplo rápido
|
|
82
80
|
|
|
83
81
|
### Crear una página HTML
|
|
84
82
|
```python
|
|
85
83
|
import pandas as pd
|
|
86
|
-
import numpy as np
|
|
87
|
-
import plotly.express as px
|
|
88
84
|
from viewx.HTML import HTML
|
|
89
85
|
|
|
90
|
-
# 1.
|
|
86
|
+
# 1. Crear datos de ejemplo
|
|
91
87
|
df_ventas = pd.DataFrame({
|
|
92
|
-
'
|
|
93
|
-
'Ventas': [
|
|
94
|
-
'
|
|
88
|
+
'Mes': ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
|
|
89
|
+
'Ventas': [120, 135, 148, 170, 195, 210, 245, 268, 290, 310, 335, 400],
|
|
90
|
+
'Beneficio': [30, 35, 42, 51, 58, 63, 73, 80, 87, 93, 100, 120],
|
|
91
|
+
'Clientes': [45, 48, 52, 58, 65, 72, 80, 88, 95, 102, 110, 125]
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
# Datos para gráfico de barras
|
|
95
|
+
df_productos = pd.DataFrame({
|
|
96
|
+
'Producto': ['Producto A', 'Producto B', 'Producto C', 'Producto D', 'Producto E'],
|
|
97
|
+
'Ventas': [450, 320, 280, 190, 150]
|
|
95
98
|
})
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
'
|
|
100
|
+
# Datos para scatter
|
|
101
|
+
df_clientes = pd.DataFrame({
|
|
102
|
+
'Edad': [25, 32, 28, 45, 38, 29, 51, 42, 35, 30],
|
|
103
|
+
'Gasto': [120, 200, 150, 300, 250, 180, 400, 320, 220, 160],
|
|
104
|
+
'Segmento': ['Joven', 'Adulto', 'Joven', 'Senior', 'Adulto', 'Joven', 'Senior', 'Adulto', 'Adulto', 'Joven']
|
|
100
105
|
})
|
|
101
106
|
|
|
102
|
-
# 2.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
# 3. Inicializar Dashboard con Estética Power BI
|
|
111
|
-
# Temas: corporate_blue, dark_enterprise, modern_green, void_indigo, glass_ocean, cyberpunk_neon
|
|
112
|
-
dash = HTML(
|
|
113
|
-
title="Dashboard de Rendimiento Corporativo",
|
|
114
|
-
theme="corporate_blue",
|
|
107
|
+
# 2. Configurar el dashboard
|
|
108
|
+
dashboard = HTML(
|
|
109
|
+
title="📊 Dashboard Ejecutivo - Demo",
|
|
110
|
+
theme="corporate_blue", # Temas: corporate_blue, dark_enterprise, modern_green, void_indigo, glass_ocean, cyberpunk_neon
|
|
111
|
+
cols=12, # Grid de 12 columnas
|
|
112
|
+
rows=12, # 12 filas de altura
|
|
113
|
+
gap=16,
|
|
114
|
+
padding=20,
|
|
115
115
|
navbar={
|
|
116
|
-
"title": "
|
|
116
|
+
"title": "📈 ViewX PRO",
|
|
117
117
|
"items": [
|
|
118
|
-
{"label": "
|
|
118
|
+
{"label": "Inicio", "link": "#"},
|
|
119
119
|
{"label": "Ventas", "link": "#"},
|
|
120
|
+
{"label": "Clientes", "link": "#"},
|
|
120
121
|
{"label": "Reportes", "link": "#"}
|
|
121
122
|
]
|
|
122
123
|
}
|
|
123
124
|
)
|
|
124
125
|
|
|
125
|
-
#
|
|
126
|
-
#
|
|
127
|
-
|
|
128
|
-
#
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
dash.add_text("""
|
|
141
|
-
<h3>Resumen de Insights</h3>
|
|
142
|
-
<p>El segmento de <b>Moda</b> lidera las ventas con un margen saludable del 18%.</p>
|
|
143
|
-
<p>Se observa un crecimiento sostenido en los ingresos mensuales, alcanzando un pico en <b>Junio</b>.</p>
|
|
144
|
-
<p><i>Recomendación:</i> Aumentar stock en la categoría 'Hogar' debido al incremento de demanda previsto.</p>
|
|
145
|
-
""", slot_grid=(8, 8, 5, 5))
|
|
146
|
-
|
|
147
|
-
# 5. Generar Dashboard
|
|
148
|
-
output = dash.generate("powerbi_dashboard_pro.html")
|
|
149
|
-
print(f"Dashboard profesional generado: {output}")
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-

|
|
127
|
+
# Fila 1: KPIs
|
|
128
|
+
dashboard.add_valuebox("Ventas Totales", "$2.8M", "💰", row=1, col=1, height=2, width=3)
|
|
129
|
+
dashboard.add_valuebox("Beneficio Neto", "$942K", "📈", "#00A86B", row=1, col=4, height=2, width=3)
|
|
130
|
+
dashboard.add_valuebox("Clientes Activos", "1,247", "👥", "#FF6B35", row=1, col=7, height=2, width=3)
|
|
131
|
+
dashboard.add_valuebox("Tasa Conversión", "24.5%", "🎯", "#9B59B6", row=1, col=10, height=2, width=3)
|
|
132
|
+
|
|
133
|
+
# Fila 2-5: Gráfico de líneas (ventas mensuales) - Método sencillo con datos
|
|
134
|
+
dashboard.add_chart(
|
|
135
|
+
data=df_ventas,
|
|
136
|
+
chart_type="line",
|
|
137
|
+
x="Mes",
|
|
138
|
+
y="Ventas",
|
|
139
|
+
title="📈 Evolución de Ventas 2024",
|
|
140
|
+
row=3, col=1, height=10, width=6
|
|
154
141
|
)
|
|
155
142
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
db.set_theme(background="#071021", text="#E9F6F2", primary="#19D3A3", card="#0b1620")
|
|
165
|
-
# Sidebar
|
|
166
|
-
db.add_sidebar(db.comp_text("Parámetros del reporte"))
|
|
167
|
-
db.add_sidebar(db.comp_metric("Longitud del dataset", df.shape[0]))
|
|
168
|
-
db.add_sidebar(db.comp_metric("Cantidad de Flores", df["species"].unique().shape[0]))
|
|
169
|
-
# Main layout
|
|
170
|
-
db.add_blank()
|
|
171
|
-
db.add_row(
|
|
172
|
-
col_widths=[1, 2, 1],
|
|
173
|
-
components=[
|
|
174
|
-
db.comp_blank(),
|
|
175
|
-
db.comp_plot(x="sepal_length", y="sepal_width", kind="scatter", color="#FFB86B"),
|
|
176
|
-
db.comp_metric("sepal_width", df["sepal_width"].sum(), delta="▲ 5%")
|
|
177
|
-
]
|
|
143
|
+
# Fila 2-5: Gráfico de barras (productos) - Otro ejemplo sencillo
|
|
144
|
+
dashboard.add_chart(
|
|
145
|
+
data=df_productos,
|
|
146
|
+
chart_type="bar",
|
|
147
|
+
x="Producto",
|
|
148
|
+
y="Ventas",
|
|
149
|
+
title="🏷️ Ventas por Producto",
|
|
150
|
+
row=3, col=7, height=10, width=6
|
|
178
151
|
)
|
|
179
152
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
db.comp_title("Resumen por Región"),
|
|
183
|
-
db.comp_table()
|
|
184
|
-
],
|
|
185
|
-
"Details": [
|
|
186
|
-
db.comp_title("Distribución de Flores"),
|
|
187
|
-
db.comp_plot(x="species", y=None, kind="hist", color="#7C4DFF")
|
|
188
|
-
]
|
|
189
|
-
})
|
|
153
|
+
# 4. Generar el archivo
|
|
154
|
+
dashboard.generate("mi_dashboard.html")
|
|
190
155
|
|
|
191
|
-
db.add_expander("Detalles técnicos", [
|
|
192
|
-
db.comp_text("Este panel fue generado automáticamente."),
|
|
193
|
-
db.comp_text("Metadata: filas=" + str(len(df)), size="12px")
|
|
194
|
-
], expanded=True)
|
|
195
|
-
|
|
196
|
-
db.run(open_browser=True)
|
|
197
156
|
```
|
|
198
157
|
|
|
199
|
-

|
|
200
160
|
|
|
201
161
|
### Crear una Presentacion
|
|
202
162
|
|
|
@@ -441,10 +401,10 @@ report_path = dm.generate_report("demo_datamatrix_report.html", title="Análisis
|
|
|
441
401
|
print(f"Reporte generado exitosamente en: {report_path}")
|
|
442
402
|
```
|
|
443
403
|
|
|
444
|
-
##
|
|
404
|
+
## Contribuciones
|
|
445
405
|
|
|
446
406
|
¡Todas las ideas, mejoras y plantillas son bienvenidas!
|
|
447
407
|
ViewX está diseñado para crecer y evolucionar con la comunidad.
|
|
448
408
|
|
|
449
|
-
##
|
|
409
|
+
## Contacto:
|
|
450
410
|
ascendraemmanuel@gmail.com
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ViewX — v2.2
|
|
2
2
|
|
|
3
3
|
**ViewX** es un paquete moderno de Python diseñado para generar **páginas HTML interactivas**, **dashboards dinámicos** y **visualizaciones inteligentes** que se adaptan automáticamente a los objetos agregados por el usuario.
|
|
4
4
|
|
|
@@ -6,15 +6,14 @@ Este proyecto ofrece una solución **ligera, intuitiva y escalable**, ideal para
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Características principales
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- 🔮 **Visión a futuro**: pensado para expandirse a interfaces inteligentes.
|
|
11
|
+
- **Rápido y minimalista**: cero dependencias pesadas por defecto.
|
|
12
|
+
- **API intuitiva**: crea páginas y dashboards en segundos.
|
|
13
|
+
- **Diseño adaptativo**: cada componente se acomoda automáticamente.
|
|
14
|
+
- **Modo HTML**: genera páginas `.html` totalmente autónomas.
|
|
15
|
+
- **Extensible**: añade tus propias plantillas y módulos personalizados.
|
|
16
|
+
- **Visión a futuro**: pensado para expandirse a interfaces inteligentes.
|
|
18
17
|
|
|
19
18
|
---
|
|
20
19
|
|
|
@@ -23,125 +22,87 @@ Este proyecto ofrece una solución **ligera, intuitiva y escalable**, ideal para
|
|
|
23
22
|
pip install viewx
|
|
24
23
|
```
|
|
25
24
|
|
|
26
|
-
##
|
|
25
|
+
## Ejemplo rápido
|
|
27
26
|
|
|
28
27
|
### Crear una página HTML
|
|
29
28
|
```python
|
|
30
29
|
import pandas as pd
|
|
31
|
-
import numpy as np
|
|
32
|
-
import plotly.express as px
|
|
33
30
|
from viewx.HTML import HTML
|
|
34
31
|
|
|
35
|
-
# 1.
|
|
32
|
+
# 1. Crear datos de ejemplo
|
|
36
33
|
df_ventas = pd.DataFrame({
|
|
37
|
-
'
|
|
38
|
-
'Ventas': [
|
|
39
|
-
'
|
|
34
|
+
'Mes': ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
|
|
35
|
+
'Ventas': [120, 135, 148, 170, 195, 210, 245, 268, 290, 310, 335, 400],
|
|
36
|
+
'Beneficio': [30, 35, 42, 51, 58, 63, 73, 80, 87, 93, 100, 120],
|
|
37
|
+
'Clientes': [45, 48, 52, 58, 65, 72, 80, 88, 95, 102, 110, 125]
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
# Datos para gráfico de barras
|
|
41
|
+
df_productos = pd.DataFrame({
|
|
42
|
+
'Producto': ['Producto A', 'Producto B', 'Producto C', 'Producto D', 'Producto E'],
|
|
43
|
+
'Ventas': [450, 320, 280, 190, 150]
|
|
40
44
|
})
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
'
|
|
46
|
+
# Datos para scatter
|
|
47
|
+
df_clientes = pd.DataFrame({
|
|
48
|
+
'Edad': [25, 32, 28, 45, 38, 29, 51, 42, 35, 30],
|
|
49
|
+
'Gasto': [120, 200, 150, 300, 250, 180, 400, 320, 220, 160],
|
|
50
|
+
'Segmento': ['Joven', 'Adulto', 'Joven', 'Senior', 'Adulto', 'Joven', 'Senior', 'Adulto', 'Adulto', 'Joven']
|
|
45
51
|
})
|
|
46
52
|
|
|
47
|
-
# 2.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
# 3. Inicializar Dashboard con Estética Power BI
|
|
56
|
-
# Temas: corporate_blue, dark_enterprise, modern_green, void_indigo, glass_ocean, cyberpunk_neon
|
|
57
|
-
dash = HTML(
|
|
58
|
-
title="Dashboard de Rendimiento Corporativo",
|
|
59
|
-
theme="corporate_blue",
|
|
53
|
+
# 2. Configurar el dashboard
|
|
54
|
+
dashboard = HTML(
|
|
55
|
+
title="📊 Dashboard Ejecutivo - Demo",
|
|
56
|
+
theme="corporate_blue", # Temas: corporate_blue, dark_enterprise, modern_green, void_indigo, glass_ocean, cyberpunk_neon
|
|
57
|
+
cols=12, # Grid de 12 columnas
|
|
58
|
+
rows=12, # 12 filas de altura
|
|
59
|
+
gap=16,
|
|
60
|
+
padding=20,
|
|
60
61
|
navbar={
|
|
61
|
-
"title": "
|
|
62
|
+
"title": "📈 ViewX PRO",
|
|
62
63
|
"items": [
|
|
63
|
-
{"label": "
|
|
64
|
+
{"label": "Inicio", "link": "#"},
|
|
64
65
|
{"label": "Ventas", "link": "#"},
|
|
66
|
+
{"label": "Clientes", "link": "#"},
|
|
65
67
|
{"label": "Reportes", "link": "#"}
|
|
66
68
|
]
|
|
67
69
|
}
|
|
68
70
|
)
|
|
69
71
|
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
dash.add_text("""
|
|
86
|
-
<h3>Resumen de Insights</h3>
|
|
87
|
-
<p>El segmento de <b>Moda</b> lidera las ventas con un margen saludable del 18%.</p>
|
|
88
|
-
<p>Se observa un crecimiento sostenido en los ingresos mensuales, alcanzando un pico en <b>Junio</b>.</p>
|
|
89
|
-
<p><i>Recomendación:</i> Aumentar stock en la categoría 'Hogar' debido al incremento de demanda previsto.</p>
|
|
90
|
-
""", slot_grid=(8, 8, 5, 5))
|
|
91
|
-
|
|
92
|
-
# 5. Generar Dashboard
|
|
93
|
-
output = dash.generate("powerbi_dashboard_pro.html")
|
|
94
|
-
print(f"Dashboard profesional generado: {output}")
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-

|
|
73
|
+
# Fila 1: KPIs
|
|
74
|
+
dashboard.add_valuebox("Ventas Totales", "$2.8M", "💰", row=1, col=1, height=2, width=3)
|
|
75
|
+
dashboard.add_valuebox("Beneficio Neto", "$942K", "📈", "#00A86B", row=1, col=4, height=2, width=3)
|
|
76
|
+
dashboard.add_valuebox("Clientes Activos", "1,247", "👥", "#FF6B35", row=1, col=7, height=2, width=3)
|
|
77
|
+
dashboard.add_valuebox("Tasa Conversión", "24.5%", "🎯", "#9B59B6", row=1, col=10, height=2, width=3)
|
|
78
|
+
|
|
79
|
+
# Fila 2-5: Gráfico de líneas (ventas mensuales) - Método sencillo con datos
|
|
80
|
+
dashboard.add_chart(
|
|
81
|
+
data=df_ventas,
|
|
82
|
+
chart_type="line",
|
|
83
|
+
x="Mes",
|
|
84
|
+
y="Ventas",
|
|
85
|
+
title="📈 Evolución de Ventas 2024",
|
|
86
|
+
row=3, col=1, height=10, width=6
|
|
99
87
|
)
|
|
100
88
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
db.set_theme(background="#071021", text="#E9F6F2", primary="#19D3A3", card="#0b1620")
|
|
110
|
-
# Sidebar
|
|
111
|
-
db.add_sidebar(db.comp_text("Parámetros del reporte"))
|
|
112
|
-
db.add_sidebar(db.comp_metric("Longitud del dataset", df.shape[0]))
|
|
113
|
-
db.add_sidebar(db.comp_metric("Cantidad de Flores", df["species"].unique().shape[0]))
|
|
114
|
-
# Main layout
|
|
115
|
-
db.add_blank()
|
|
116
|
-
db.add_row(
|
|
117
|
-
col_widths=[1, 2, 1],
|
|
118
|
-
components=[
|
|
119
|
-
db.comp_blank(),
|
|
120
|
-
db.comp_plot(x="sepal_length", y="sepal_width", kind="scatter", color="#FFB86B"),
|
|
121
|
-
db.comp_metric("sepal_width", df["sepal_width"].sum(), delta="▲ 5%")
|
|
122
|
-
]
|
|
89
|
+
# Fila 2-5: Gráfico de barras (productos) - Otro ejemplo sencillo
|
|
90
|
+
dashboard.add_chart(
|
|
91
|
+
data=df_productos,
|
|
92
|
+
chart_type="bar",
|
|
93
|
+
x="Producto",
|
|
94
|
+
y="Ventas",
|
|
95
|
+
title="🏷️ Ventas por Producto",
|
|
96
|
+
row=3, col=7, height=10, width=6
|
|
123
97
|
)
|
|
124
98
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
db.comp_title("Resumen por Región"),
|
|
128
|
-
db.comp_table()
|
|
129
|
-
],
|
|
130
|
-
"Details": [
|
|
131
|
-
db.comp_title("Distribución de Flores"),
|
|
132
|
-
db.comp_plot(x="species", y=None, kind="hist", color="#7C4DFF")
|
|
133
|
-
]
|
|
134
|
-
})
|
|
99
|
+
# 4. Generar el archivo
|
|
100
|
+
dashboard.generate("mi_dashboard.html")
|
|
135
101
|
|
|
136
|
-
db.add_expander("Detalles técnicos", [
|
|
137
|
-
db.comp_text("Este panel fue generado automáticamente."),
|
|
138
|
-
db.comp_text("Metadata: filas=" + str(len(df)), size="12px")
|
|
139
|
-
], expanded=True)
|
|
140
|
-
|
|
141
|
-
db.run(open_browser=True)
|
|
142
102
|
```
|
|
143
103
|
|
|
144
|
-

|
|
145
106
|
|
|
146
107
|
### Crear una Presentacion
|
|
147
108
|
|
|
@@ -386,10 +347,10 @@ report_path = dm.generate_report("demo_datamatrix_report.html", title="Análisis
|
|
|
386
347
|
print(f"Reporte generado exitosamente en: {report_path}")
|
|
387
348
|
```
|
|
388
349
|
|
|
389
|
-
##
|
|
350
|
+
## Contribuciones
|
|
390
351
|
|
|
391
352
|
¡Todas las ideas, mejoras y plantillas son bienvenidas!
|
|
392
353
|
ViewX está diseñado para crecer y evolucionar con la comunidad.
|
|
393
354
|
|
|
394
|
-
##
|
|
355
|
+
## Contacto:
|
|
395
356
|
ascendraemmanuel@gmail.com
|
|
@@ -9,7 +9,7 @@ except FileNotFoundError:
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name="viewx",
|
|
12
|
-
version="0.2.
|
|
12
|
+
version="0.2.2",
|
|
13
13
|
author="Emmanuel Ascendra Perez",
|
|
14
14
|
author_email="ascendraemmanuel@gmail.com",
|
|
15
15
|
description="Librería de visualización adaptable para HTML, Dashboards y PDFs en Python",
|
|
@@ -48,8 +48,7 @@ setup(
|
|
|
48
48
|
"pylatex>=1.4.2", # Para PDFs
|
|
49
49
|
"seaborn>=0.12.2",
|
|
50
50
|
"plotly>=6.0.0",
|
|
51
|
-
"streamlit>=1.32.0"
|
|
52
|
-
"statslibx >= 0.2.2"
|
|
51
|
+
"streamlit>=1.32.0"
|
|
53
52
|
],
|
|
54
53
|
|
|
55
54
|
# Dependencias opcionales
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import numpy as np
|
|
3
|
+
from datetime import datetime, timedelta
|
|
4
|
+
from viewx.HTML.html_engine import HTML
|
|
5
|
+
|
|
6
|
+
# ── Generar datos de demo ────────────────────────────────────────────────────
|
|
7
|
+
np.random.seed(42)
|
|
8
|
+
n = 200
|
|
9
|
+
|
|
10
|
+
fechas = [datetime(2024, 1, 1) + timedelta(days=i) for i in range(n)]
|
|
11
|
+
regiones = np.random.choice(["Norte", "Sur", "Este", "Oeste", "Centro"], n)
|
|
12
|
+
productos = np.random.choice(["Laptop", "Tablet", "Phone", "Monitor", "Teclado"], n)
|
|
13
|
+
ventas = np.random.randint(500, 10000, n)
|
|
14
|
+
utilidad = ventas * np.random.uniform(0.1, 0.4, n)
|
|
15
|
+
unidades = np.random.randint(1, 50, n)
|
|
16
|
+
activo = np.random.choice([True, False], n)
|
|
17
|
+
|
|
18
|
+
df = pd.DataFrame({
|
|
19
|
+
"fecha" : fechas,
|
|
20
|
+
"region" : regiones,
|
|
21
|
+
"producto" : productos,
|
|
22
|
+
"ventas" : ventas,
|
|
23
|
+
"utilidad" : utilidad.astype(int),
|
|
24
|
+
"unidades" : unidades,
|
|
25
|
+
"activo" : activo,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
print("Columnas disponibles:", df.columns.tolist())
|
|
29
|
+
print(df.head(3))
|
|
30
|
+
|
|
31
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
32
|
+
# DEMO 1 — Layout automático, tema por defecto
|
|
33
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
34
|
+
HTML.auto_generate(
|
|
35
|
+
df,
|
|
36
|
+
title = "Demo 1 · Auto Layout",
|
|
37
|
+
filename = "demo1_auto.html",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
41
|
+
# DEMO 2 — Solo algunas columnas + tema oscuro
|
|
42
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
43
|
+
HTML.auto_generate(
|
|
44
|
+
df,
|
|
45
|
+
columns = ["fecha", "ventas", "utilidad", "region"],
|
|
46
|
+
template = "dark_enterprise",
|
|
47
|
+
title = "Demo 2 · Columnas seleccionadas",
|
|
48
|
+
filename = "demo2_cols.html",
|
|
49
|
+
authors = [
|
|
50
|
+
{"name": "Ana García", "email": "ana@empresa.com"},
|
|
51
|
+
{"name": "Luis Torres", "email": "luis@empresa.com"},
|
|
52
|
+
]
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
56
|
+
# DEMO 3 — Preset kpi_focus + tema void_indigo
|
|
57
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
58
|
+
HTML.auto_generate(
|
|
59
|
+
df,
|
|
60
|
+
columns = ["ventas", "utilidad", "unidades", "region", "producto"],
|
|
61
|
+
template = "void_indigo",
|
|
62
|
+
title = "Demo 3 · KPI Focus",
|
|
63
|
+
filename = "demo3_kpi_focus.html",
|
|
64
|
+
layout = "kpi_focus",
|
|
65
|
+
authors = "Carlos Méndez",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
69
|
+
# DEMO 4 — Preset chart_focus + tema glass_ocean
|
|
70
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
71
|
+
HTML.auto_generate(
|
|
72
|
+
df,
|
|
73
|
+
columns = ["fecha", "ventas", "utilidad", "region"],
|
|
74
|
+
template = "glass_ocean",
|
|
75
|
+
title = "Demo 4 · Chart Focus",
|
|
76
|
+
filename = "demo4_chart_focus.html",
|
|
77
|
+
layout = "chart_focus",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
81
|
+
# DEMO 5 — Preset table_first + tema cyberpunk_neon
|
|
82
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
83
|
+
HTML.auto_generate(
|
|
84
|
+
df,
|
|
85
|
+
columns = ["fecha", "region", "producto", "ventas", "unidades"],
|
|
86
|
+
template = "cyberpunk_neon",
|
|
87
|
+
title = "Demo 5 · Table First",
|
|
88
|
+
filename = "demo5_table_first.html",
|
|
89
|
+
layout = "table_first",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
93
|
+
# DEMO 6 — Layout 100% personalizado
|
|
94
|
+
# Diseño:
|
|
95
|
+
# [KPI ventas] [KPI utilidad] [KPI unidades] | [Chart barras región]
|
|
96
|
+
# [Chart línea temporal (ventas) ] | [Chart scatter ]
|
|
97
|
+
# [Tabla completa ]
|
|
98
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
99
|
+
HTML.auto_generate(
|
|
100
|
+
df,
|
|
101
|
+
columns = ["fecha", "region", "ventas", "utilidad", "unidades"],
|
|
102
|
+
template = "modern_green",
|
|
103
|
+
title = "Demo 6 · Layout Personalizado",
|
|
104
|
+
filename = "demo6_custom.html",
|
|
105
|
+
authors = [{"name": "Equipo BI", "email": "bi@empresa.com"}],
|
|
106
|
+
layout = [
|
|
107
|
+
# Fila 1: 3 KPIs a la izquierda + 1 chart a la derecha
|
|
108
|
+
{"type": "kpi", "index": 0, "row": 1, "col": 1, "height": 2, "width": 3},
|
|
109
|
+
{"type": "kpi", "index": 1, "row": 1, "col": 4, "height": 2, "width": 3},
|
|
110
|
+
{"type": "kpi", "index": 2, "row": 1, "col": 7, "height": 2, "width": 3},
|
|
111
|
+
{"type": "chart", "index": 1, "row": 1, "col": 10, "height": 7, "width": 3}, # barras región
|
|
112
|
+
|
|
113
|
+
# Fila 2: línea temporal grande + scatter
|
|
114
|
+
{"type": "chart", "index": 0, "row": 3, "col": 1, "height": 5, "width": 6}, # línea tiempo
|
|
115
|
+
{"type": "chart", "index": 2, "row": 3, "col": 7, "height": 5, "width": 3}, # scatter
|
|
116
|
+
|
|
117
|
+
# Fila 3: tabla completa
|
|
118
|
+
{"type": "table", "row": 8, "col": 1, "height": 4, "width": 12},
|
|
119
|
+
]
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
123
|
+
# DEMO 7 — DataFrame con strings numéricos (prueba parseo automático)
|
|
124
|
+
# ════════════════════════════════════════════════════════════════════════════
|
|
125
|
+
df_strings = pd.DataFrame({
|
|
126
|
+
"mes" : ["Ene", "Feb", "Mar", "Abr", "May", "Jun"],
|
|
127
|
+
"ingresos" : ["$12,500", "$9,800", "$15,200", "$11,000", "$18,400", "$14,700"],
|
|
128
|
+
"costos" : ["8500", "7200", "9800", "8100", "12000", "10500"],
|
|
129
|
+
"margen%" : ["32%", "27%", "36%", "26%", "35%", "29%"],
|
|
130
|
+
"ciudad" : ["Bogotá", "Medellín","Cali", "Bogotá", "Cali", "Medellín"],
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
HTML.auto_generate(
|
|
134
|
+
df_strings,
|
|
135
|
+
template = "corporate_blue",
|
|
136
|
+
title = "Demo 7 · Parseo Automático de Strings",
|
|
137
|
+
filename = "demo7_parseo.html",
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
print("\n✅ Todos los dashboards generados:")
|
|
141
|
+
for i, name in enumerate([
|
|
142
|
+
"demo1_auto.html",
|
|
143
|
+
"demo2_cols.html",
|
|
144
|
+
"demo3_kpi_focus.html",
|
|
145
|
+
"demo4_chart_focus.html",
|
|
146
|
+
"demo5_table_first.html",
|
|
147
|
+
"demo6_custom.html",
|
|
148
|
+
"demo7_parseo.html",
|
|
149
|
+
], 1):
|
|
150
|
+
print(f" {i}. {name}")
|