Librería de visualización adaptable para HTML, Dashboards y PDFs en Python
Project description
📦 ViewX — Librería de Visualización Adaptativa para Python
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.
Este proyecto ofrece una solución ligera, intuitiva y escalable, ideal para crear interfaces visuales llamativas sin depender de frameworks pesados… aunque una parte se encuentra basada en Streamlit mediante dependencias opcionales.
✨ Características principales
- ⚡ Rápido y minimalista: cero dependencias pesadas por defecto.
- 🧩 API intuitiva: crea páginas y dashboards en segundos.
- 📐 Diseño adaptativo: cada componente se acomoda automáticamente.
- 🌐 Modo HTML: genera páginas
.htmltotalmente autónomas. - 📊 Modo Dashboard: plantillas escalables con soporte opcional para Streamlit/Dash.
- 🛠️ Extensible: añade tus propias plantillas y módulos personalizados.
- 🔮 Visión a futuro: pensado para expandirse a interfaces inteligentes.
Instalacion
pip install viewx
🚀 Ejemplo rápido
Crear una página HTML
from viewx.datasets import load_dataset
from viewx import HTML
# -----------------------------
# DATASET
# -----------------------------
df = load_dataset("iris.csv")
# -----------------------------
# DASHBOARD
# -----------------------------
(
HTML(
data=df,
title="Reporte Iris — ViewX",
template_color=1,
num_divs=8,
num_cols=4,
num_rows=5
)
# ===== VALUE BOXES =====
.add_valuebox(
title="Filas",
value=len(df),
icon="📄",
slot_grid=("div1", 1, 1, 1, 1)
)
# slot_grid = ("div#", fila_inicial, columna_inicial, alto, ancho)
.add_valuebox(
title="Prom Sepal Length",
value=round(df["sepal_length"].mean(), 2),
icon="📏",
slot_grid=("div2", 1, 2, 1, 1)
)
.add_valuebox(
title="Prom Petal Width",
value=round(df["petal_width"].mean(), 2),
icon="🌸",
slot_grid=("div3", 1, 3, 1, 1)
)
.add_text(
"<h2>Iris Dataset Dashboard</h2><p>Este DashBoard fue desarrollado por Emmanuel Ascendra con Viewx</p>",
slot_grid=("div4", 1, 4, 1, 1)
)
# ===== PLOTS =====
.add_plot(
kind="scatter",
x="sepal_length",
y="sepal_width",
title="Sepal Length vs Width",
slot_grid=("div5", 2, 1, 2, 2)
)
.add_plot(
kind="box",
x="species",
y="petal_width",
title="Petal Width por especie",
slot_grid=("div6", 4, 1, 2, 2)
)
.add_plot(
kind="bar",
x="species",
y="sepal_length",
title="Promedio Sepal Length",
slot_grid=("div7", 4, 3, 2, 2)
)
# ===== TABLE =====
.add_table(
columns="all",
slot_grid=("div8", 2, 3, 2, 2)
)
.show("demo_viewx.html", port=8001)
)
Crear un DashBoard
from viewx import DashBoard
from viewx.datasets import load_dataset
df = load_dataset("iris.csv")
db = DashBoard(df, title="StreamOps: Mini Dashboard", title_align="center")
db.set_theme(background="#071021", text="#E9F6F2", primary="#19D3A3", card="#0b1620")
# Sidebar
db.add_sidebar(db.comp_text("Parámetros del reporte"))
db.add_sidebar(db.comp_metric("Longitud del dataset", df.shape[0]))
db.add_sidebar(db.comp_metric("Cantidad de Flores", df["species"].unique().shape[0]))
# Main layout
db.add_blank()
db.add_row(
col_widths=[1, 2, 1],
components=[
db.comp_blank(),
db.comp_plot(x="sepal_length", y="sepal_width", kind="scatter", color="#FFB86B"),
db.comp_metric("sepal_width", df["sepal_width"].sum(), delta="▲ 5%")
]
)
db.add_tabs({
"Overview": [
db.comp_title("Resumen por Región"),
db.comp_table()
],
"Details": [
db.comp_title("Distribución de Flores"),
db.comp_plot(x="species", y=None, kind="hist", color="#7C4DFF")
]
})
db.add_expander("Detalles técnicos", [
db.comp_text("Este panel fue generado automáticamente."),
db.comp_text("Metadata: filas=" + str(len(df)), size="12px")
], expanded=True)
db.run(open_browser=True)
Crear un Reporte
from viewx.datasets import load_dataset
import seaborn as sns
import matplotlib.pyplot as plt
# ===============================
# 1️⃣ CREAR REPORTE
# ===============================
r = Report(
title="Reporte Técnico ViewX",
author="Emmanuel Ascendra"
)
# ===============================
# 2️⃣ TEXTO
# ===============================
r.add_text("Este reporte demuestra todas las capacidades del motor ViewX.\n")
r.add_text("Texto importante en negrita.", bold=True)
# ===============================
# 3️⃣ SECCIONES
# ===============================
with r.doc.create(r.add_section("Introducción")):
r.add_text(
"ViewX es un motor de generación de reportes científicos "
"capaz de producir documentos profesionales usando Python."
)
# ===============================
# 4️⃣ SUBSECCIÓN
# ===============================
with r.doc.create(r.add_subsection("Características principales")):
r.add_itemize([
"Texto estructurado",
"Imágenes",
"Tablas",
"Código",
"Gráficos científicos",
"Multicolumnas",
"Cajas de información"
])
# ===============================
# 5️⃣ TABLA
# ===============================
with r.doc.create(r.add_section("Tabla de resultados")):
r.add_table(
headers=["Modelo", "Accuracy", "F1"],
rows=[
["Regresión", 0.82, 0.79],
["Árbol", 0.91, 0.88],
["Red neuronal", 0.94, 0.92],
],
caption="Comparación de modelos"
)
# ===============================
# 6️⃣ IMAGEN
# ===============================
with r.doc.create(r.add_section("Visualización")):
r.add_image(
path="assets/ejemplo.png",
caption="Imagen de prueba",
width="0.6\\linewidth"
)
# ===============================
# 7️⃣ CÓDIGO
# ===============================
with r.doc.create(r.add_section("Código de ejemplo")):
r.add_code("""
import numpy as np
x = np.linspace(0, 10, 50)
y = np.sin(x)
""")
# ===============================
# 8️⃣ MULTICOLUMNAS
# ===============================
with r.doc.create(r.add_section("Análisis en dos columnas")):
r.begin_multicols(2)
r.add_text(
"Este bloque demuestra cómo dividir el contenido "
"en múltiples columnas dentro del mismo documento."
)
r.add_itemize([
"Ideal para papers",
"Mejora lectura",
"Ahorra espacio"
])
r.end_multicols()
# ===============================
# 9️⃣ CAJA DESTACADA
# ===============================
with r.doc.create(r.add_section("Nota importante")):
r.add_box(
title="Observación clave",
content="Todos los elementos se generan directamente desde Python.",
color="green!20"
)
# ===============================
# 🔟 GRÁFICO SIMPLE
# ===============================
with r.doc.create(r.add_section("Gráfico simple")):
r.add_plot(
x=[0, 1, 2, 3, 4],
y=[0, 1, 4, 9, 16],
caption="Crecimiento cuadrático"
)
# ===============================
# 1️⃣1️⃣ MULTIGRÁFICO
# ===============================
with r.doc.create(r.add_section("Gráficos múltiples")):
r.add_multiplot(
plots=[
([0, 1, 2, 3], [0, 1, 4, 9]),
([0, 1, 2, 3], [0, 1, 8, 27]),
],
caption="Comparación de funciones"
)
# ===============================
# 1️⃣2️⃣ SALTO DE PÁGINA
# ===============================
r.new_page()
r.add_text("Contenido en una nueva página.")
# ===============================
# 1️⃣3️⃣ GENERAR PDF
# ===============================
r.build("reporte_demo")
🤝 Contribuciones
¡Todas las ideas, mejoras y plantillas son bienvenidas! ViewX está diseñado para crecer y evolucionar con la comunidad.
📬 Contacto:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file viewx-0.1.7.tar.gz.
File metadata
- Download URL: viewx-0.1.7.tar.gz
- Upload date:
- Size: 4.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
330c0480370139e3a5d5efb1c29459c47ece8e730fbecd94780536ad73be9c07
|
|
| MD5 |
30bd6fd44d7a23ed8f3db59705a60846
|
|
| BLAKE2b-256 |
c45e47132cb525a350db8447e145ecaaebda0cb24c3e7683eabf1f2ac9faca77
|
File details
Details for the file viewx-0.1.7-py3-none-any.whl.
File metadata
- Download URL: viewx-0.1.7-py3-none-any.whl
- Upload date:
- Size: 4.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72a7bbb7bd34458922b8b55bab0b3ab9520c5a8fae5302a131dfe7852e1bab1c
|
|
| MD5 |
39115551297b40e5da6980e1625a7619
|
|
| BLAKE2b-256 |
af1042b55a56e38d5e25418a294ffaa608d86395edefd45593582f4ec0b3febe
|