Declarative Vega and Vega-Lite visualizations for spaday.
Usage
VegaChart accepts either grammar through the same typed Python component. Vega-Embed selects the correct runtime from the specification's $schema.
from spaday.backends.starlette import serve
from spaday_vega import VegaChart, package
spec = {
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"data": {"name": "values"},
"datasets": {"values": []},
"mark": "bar",
"encoding": {
"x": {"field": "category", "type": "nominal"},
"y": {"field": "value", "type": "quantitative"},
},
}
data = {"values": [{"category": "A", "value": 12}, {"category": "B", "value": 21}]}
page = VegaChart(spec=spec, data=data, renderer="svg", actions=False)
app = serve(page, packages=[package], title="Vega-Lite chart")
data maps Vega dataset names to rows and signals maps signal names to values. Updating either property applies the change to the current view, preserving scroll position and chart interaction state. Set signal_listeners to the signal names that should produce vega-signal events; each event contains the signal's name and value in detail.
The bundled <vega-chart> custom element dispatches vega-ready after rendering, vega-update after applying data or signals, and vega-error when either operation fails. It also accepts serializable Vega-Embed options. Updating spec, options, renderer, or actions redraws the visualization and finalizes the previous view.
The element exposes its Vega view property for JavaScript code that needs the rest of the View API.
Theming
Chart defaults follow spaday's shell palette. Set a component token on the chart or any ancestor to theme Vega without changing its specification:
| Token | Controls | Shell fallback |
|---|---|---|
--spa-vega-background |
Chart background | --spa-surface |
--spa-vega-text |
Titles, guides, and text marks | --spa-muted |
--spa-vega-axis |
Axis domains and ticks | --spa-muted |
--spa-vega-grid |
Grid lines and legend gradient outline | --spa-border |
--spa-vega-mark |
Default mark color | --spa-accent |
--spa-vega-danger |
Rendering errors | --spa-danger |
These are Vega configuration defaults. Colors declared by the specification or options.config
still win. Python authors can discover the same mapping as spaday_vega.TOKENS and set a token with
VegaChart(...).css(spa_vega_mark="#4c78a8").
Browser examples
The browser example runs Python through Pyodide, so it needs no install or server. Each timer event travels from the browser to a Python model through Spaday and transports. Python returns three named datasets and a Vega signal, and each chart applies them to its existing view. Hovering a point sends a watched Vega signal back through Spaday and transports. The example includes native Vega and Vega-Lite specifications.
Run the examples locally
python -m pip install -e ".[examples]"
python -m spaday_vega.example
Open http://127.0.0.1:8028 for the example.
Metadata
Release files for spaday-vega 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spaday_vega-0.2.1.tar.gz | 1.5 MB | Without provenance | Details for spaday_vega-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spaday_vega-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for spaday_vega-0.2.1-py3-none-any.whl |
Total release size: 2.9 MB
Release files / spaday_vega-0.2.1.tar.gz
| Download URL | spaday_vega-0.2.1.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27520e79f63ddcfc10d57a8b21e96e3c7920a1dafc32d2211a51b948371e72cb
|
|
BLAKE2b-256 checksum How to use checksums |
7942c4c5a8ea63dd4fb52ba8eca25caf2ca1ed9e86e4d42561833137bacd83d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / spaday_vega-0.2.1-py3-none-any.whl
| Download URL | spaday_vega-0.2.1-py3-none-any.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d73335d5c0f8cb825eca55318f1144f32c0ce0fd8a1abf7ec6fc56084e3e823
|
|
BLAKE2b-256 checksum How to use checksums |
a0af4c3eb398054dfb5a65b529be9e03a9bcea60ab62bef6f47ce24bf8ef7ad8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Security for spaday-vega 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.