Skip to main content

Gere dashboards visuais como imagens usando HTML/CSS e Playwright.

Project description

Dashgen

📊 Gere dashboards visuais como imagens (PNG) diretamente do Python com HTML, CSS e Chart.js.


✨ O que é?

dashgen é um micro-framework que permite montar dashboards com:

  • Cards com indicadores e progresso
  • Tabelas com dados estruturados
  • Gráficos de barra e linha com Chart.js
  • Sistema de layout com Row() e Column()
  • Temas personalizados com variáveis CSS
  • Exportação como imagem via Playwright

🚀 Instalação

pip install dashgen
playwright install

🧪 Exemplo Rápido

from dashgen import Dashboard
from dashgen.core.layout import Row, Column

db = Dashboard(
    title="Relatório de Vendas",
    logo_path="logo.png",
    size=(1080, 1080),
    theme={
        "primary": "#005f73",
        "accent": "#94d2bd",
        "bg": "#fefae0",
        "text": "#001219"
    }
)

# Cards
db.add(Row(
    Column(6).add_card("Receita Acumulada", 8200000, 10000000),
    Column(6).add_card("Unidades Vendidas", 320, 400)
))

# Tabela + Gráfico
empreendimentos = [
    {"Nome": "Projeto A", "Meta": "R$ 2M", "Realizado": "R$ 1.6M", "Variação": "-20%"},
    {"Nome": "Projeto B", "Meta": "R$ 3M", "Realizado": "R$ 3.1M", "Variação": "+3%"},
]
grafico_barras = [
    {"label": "Jan", "value": 120},
    {"label": "Fev", "value": 135},
    {"label": "Mar", "value": 160},
]
db.add(Row(
    Column(6).add_table("Receita por Empreendimento", empreendimentos, ["Nome", "Meta", "Realizado", "Variação"]),
    Column(6).add_chart("bar", "Vendas Mensais", grafico_barras)
))

# Gráfico de linha
grafico_linha = [
    {"label": "Jan", "value": 1200000},
    {"label": "Fev", "value": 1450000},
    {"label": "Mar", "value": 1600000},
]
db.add(Row(
    Column(12).add_chart("line", "Receita Total (R$)", grafico_linha)
))

# Exportar imagem
db.generate("output_dashboard.png")

🧱 Componentes disponíveis

Dashboard

Classe principal que coordena a montagem e renderização da imagem.

Row() e Column(width)

Sistema de layout baseado em grid de 12 colunas.

Row(Column(6), Column(6))  # duas colunas lado a lado
Row(Column(12))            # elemento ocupando 100%

add_card(title, value, target)

Componente com barra de progresso e KPI.

add_table(title, data, headers)

Tabela com cabeçalho fixo e linhas formatadas.

add_chart(chart_type, title, data)

Suporta:

  • "bar": gráfico de barras
  • "line": gráfico de linhas

🎨 Temas Personalizados

Via argumento theme={...} no Dashboard():

Chave Variável CSS Exemplo
primary --primary #005f73
accent --accent #94d2bd
bg --bg #fefae0
text --text #001219

📦 Build e Publicação

Para empacotar o projeto:

pip install build
python -m build

Para publicar:

pip install twine
twine upload dist/*

🛠 Requisitos

  • Python 3.7+
  • playwright (com playwright install)
  • jinja2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dashgen-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dashgen-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file dashgen-0.1.0.tar.gz.

File metadata

  • Download URL: dashgen-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for dashgen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e52f07203bd257c01712eb356651615eef474f0e342c960893dde6f50e034e42
MD5 78b88f0fba990261d0bebae6a0591a6e
BLAKE2b-256 f48b54509cc4b21166c75ed8df3ae2c572e93430d3114932cceb24392e7aff09

See more details on using hashes here.

File details

Details for the file dashgen-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dashgen-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for dashgen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 638405ab93e0dafeaee4c76ebd6295d0fdf07073a362eb44b040513092a88634
MD5 168b830de67fbe7109dd8f955b924da4
BLAKE2b-256 b9d369b738eeeeb2aae3d96eb1ce8001865de0129bee432bb0ddec8184857a57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page