dagre graph rendering for spaday
Overview
spaday-dagre renders directed graphs in spaday from a
serializable node/edge config, laid out by @dagrejs/dagre and
drawn as light-DOM SVG. Colors ride the spaday shell's --spa-* tokens, so
bind_root_class("wa-dark", ...) re-themes the graph with the rest of the page, and application CSS
reaches every shape. dagre-node-click bubbles the node id (scalar detail, so
SetField("selected", event_value()) just works); dagre-edge-click bubbles {source, target}.
Right-clicking a node or edge bubbles dagre-node-contextmenu / dagre-edge-contextmenu with the
graph context plus the pointer position, pairing with spaday's open_popup for context menus.
Navigation is dagre-d3-class: cursor-anchored wheel zoom, drag pan (clamped so the graph can never
be dragged out of view), double-click reset, and an optional GitHub-mermaid-style D-pad
(controls) with pan arrows around a center reset circle.
Quick example
from spaday import element
from spaday.backends.starlette import serve
from spaday_dagre import Dagre, package
graph = Dagre(
graph={
"nodes": [{"id": "a", "label": "Alpha"}, {"id": "b", "shape": "diamond"}],
"edges": [{"source": "a", "target": "b", "label": "flow"}],
},
layout={"rankdir": "LR"},
controls=True,
)
app = serve(element("main").child(graph), packages=[package])
Node sizes default from label measurement; per-node width/height/class/shape (rect,
diamond, ellipse) and per-edge label/class override. layout passes through to dagre (rankdir, align, nodesep,
ranksep, edgesep, marginx/marginy, ranker). Installing the package registers the dagre
entry point, so packages=["dagre"] also works.
Run the local example
python -m spaday_dagre.example
Open http://127.0.0.1:8016: a pipeline DAG live over a transports wire — the server sweeps an active-stage highlight through the graph while node/edge selection rides back as model edits — with direction switching, mixed node shapes, a right-click menu for nodes and edges, view controls, and the dark-mode toggle.
[!NOTE] This library was generated using copier from the Base Python Project Template repository.
Metadata
Release files for spaday-dagre 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| spaday_dagre-0.1.2.tar.gz | 176.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spaday_dagre-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 304.0 kB
Release files / spaday_dagre-0.1.2.tar.gz
| Download URL | spaday_dagre-0.1.2.tar.gz |
|---|---|
| Size | 176.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e2af21a3da8eaf5d4166697793d83b6cd2891bf6c62d25b12516b0263fa7c2b
|
|
BLAKE2b-256 checksum How to use checksums |
871588088ff75a65efd5229e0c65520eb32d18666d28eb31a146f1d41afd8806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / spaday_dagre-0.1.2-py3-none-any.whl
| Download URL | spaday_dagre-0.1.2-py3-none-any.whl |
|---|---|
| Size | 127.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2bb9a5936e603a967cdf91ceb03f43c555990b10b3a3fe6c29012c13c64fd6b
|
|
BLAKE2b-256 checksum How to use checksums |
868bd5e0e2100031f0712f222795bdad6aaefa5dcc1c958eaf803bbba2383410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|