Skip to main content

AI-native declarative visual analytics — YAML DSL to Vega-Lite translator

Project description

Shelves

Declarative visual analytics for semantic models. Write charts and dashboards in YAML, render to Vega-Lite.

Shelves connects to your Cube.dev semantic layer, so your charts inherit consistent definitions for measures, dimensions, formats, and aggregations — no copy-pasting field logic across dashboards.

More connectors are planned. For now, Shelves requires a Cube.dev instance as its data backend.

Install

pip install shelves-bi

Requires Python 3.11+.

Project structure

A typical Shelves project looks like this:

my-project/
  models/
    orders.yaml          # semantic model definitions
  charts/
    revenue_by_country.yaml
    sales_over_time.yaml
  dashboards/
    overview.yaml
  .env                   # CUBE_API_URL and CUBE_API_TOKEN

Connect to Cube

Set your Cube.dev credentials in a .env file or as environment variables:

CUBE_API_URL=http://localhost:4000
CUBE_API_TOKEN=your-cube-api-token

Define a model

Models map your Cube cubes to the measures and dimensions your charts can use:

# models/orders.yaml
model: orders
label: Orders

source:
  type: cube
  cube: orders

measures:
  net_sales:
    label: Net Sales
    format: "$,.0f"
    aggregation: sum

dimensions:
  category:
    label: Category
  order_date:
    type: temporal
    label: Order Date
    defaultGrain: month
    format:
      month: "%b %Y"

Write a chart

Charts reference a model by name. Measures, dimensions, formats, and sort orders are resolved from the model:

# charts/sales_by_category.yaml
sheet: "Net Sales by Category"
data: orders

cols: category
rows: net_sales
marks: bar
color: category
sort:
  field: net_sales
  order: descending

Render

# Single chart
shelves-render charts/sales_by_category.yaml --models-dir models/

# Dashboard (charts and models resolved from directories)
shelves-render dashboards/overview.yaml --chart-dir charts/ --models-dir models/

# Dev server with live reload
shelves-dev charts/sales_by_category.yaml --models-dir models/

Output goes to output/<sheet-name-slug>.html by default. Use --out to override.

Dashboards

Dashboards compose multiple charts into a single HTML page with layout, text, and styling:

# dashboards/overview.yaml
dashboard: "Sales Overview"
canvas: { width: 1440, height: 900 }

root:
  orientation: vertical
  contains:
    - text: "Sales Overview"
      preset: title
    - horizontal:
        contains:
          - sheet: "charts/sales_by_category.yaml"
            width: "60%"
          - sheet: "charts/sales_over_time.yaml"
            width: "40%"

Python API

from shelves import parse_chart, translate_chart, merge_theme, render_html
from shelves.data.bind import resolve_data

spec   = parse_chart(yaml_string)          # YAML -> ChartSpec
vl     = translate_chart(spec)             # ChartSpec -> Vega-Lite dict
themed = merge_theme(vl)                   # apply default theme
final  = resolve_data(themed, spec)        # fetch from Cube and bind
html   = render_html(final)                # standalone HTML with vegaEmbed

Each step is independent and composable.

Documentation

Development

git clone https://github.com/shelveshq/shelves.git
cd shelves
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest

License

MIT

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

shelves_bi-0.1.0.tar.gz (88.0 kB view details)

Uploaded Source

Built Distribution

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

shelves_bi-0.1.0-py3-none-any.whl (61.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shelves_bi-0.1.0.tar.gz
  • Upload date:
  • Size: 88.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for shelves_bi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0eeb7c7d46c08ea2ad207fb85c8e943e9b7cb2612d863350b196ccd3b4678b10
MD5 22bc60faf8da5f700816b025ecd454fa
BLAKE2b-256 6067ffcb0d77ed34dbe7f63d15b13dfef00d7b6d900861df17f62081a705d35c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: shelves_bi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 61.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for shelves_bi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76a8082b84f7c94472ec27526aba0d4fb67454b9a7d5e4f7e8242f08b5163a85
MD5 bd2fa8176f1ff504359ee03839dbe9bc
BLAKE2b-256 195ece01d99b18c91865fd56baa8cc4fb28ab2dd45d779f2a76b5d734333f351

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