AI-native declarative visual analytics — YAML DSL to Vega-Lite translator
Project description
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
- Getting Started — setup, first chart, first dashboard
- DSL Reference — complete field and property reference
- Dashboards — layout DSL, components, and styling
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
Apache 2.0
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
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 shelves_bi-0.2.1.tar.gz.
File metadata
- Download URL: shelves_bi-0.2.1.tar.gz
- Upload date:
- Size: 126.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
933f4bc5bccea40a7865d186f99b51a4132d49a18bc0f3d53ffca9e89bc18219
|
|
| MD5 |
3687a112136d06e4b41784a82fb8ba78
|
|
| BLAKE2b-256 |
764dd689869584380884925dd398891c0a709918a45be108c1241f514639a6ba
|
File details
Details for the file shelves_bi-0.2.1-py3-none-any.whl.
File metadata
- Download URL: shelves_bi-0.2.1-py3-none-any.whl
- Upload date:
- Size: 96.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4107265c8465c6e25c13b3bee5a32c4ad89faab98dd7f070431e5c8ec2c73faf
|
|
| MD5 |
6c09d0d902dcc5fbf27969c7f268c603
|
|
| BLAKE2b-256 |
40a321a3eeb1a778e3d8e85a58c4efcd96cdc93cf184c19df26e41afc0389674
|