graphviz-anywidget
Interactive Graphviz visualization widget for Jupyter notebooks using anywidget. Graphviz is provided via WASM (hpcc-js-wasm) and the rendering is done using graphvizsvg and d3-graphviz, inspired by the VS Code extension Graphviz Interactive Preview.
https://github.com/user-attachments/assets/74cf39c5-2d64-4c98-b3ee-cf7308753da6
https://github.com/user-attachments/assets/8947dfd1-5d4a-43b9-b0c7-22cb52f72dc3
Features
- 🎨 Interactive SVG visualization of Graphviz DOT graphs
- 🔍 Search functionality with regex support
- 🎯 Node and edge highlighting
- ↔️ Directional graph traversal
- 🔄 Zoom reset functionality
- 📱 Responsive design
- 🎨 Smooth animations and transitions
- 💻 Works in JupyterLab, Jupyter Notebook, and VS Code
Installation
pip install graphviz-anywidget
or with uv:
uv add graphviz-anywidget
Usage
from graphviz_anywidget import graphviz_widget
# Create a widget with a DOT string
dot_source = """
digraph {
a -> b;
b -> c;
c -> a;
}
"""
widget = graphviz_widget(dot_source)
widget
Features
-
Search: Use the search box to find nodes and edges
- Supports exact match, substring, and regex search
- Case-sensitive option available
-
Direction Selection: Choose how to traverse the graph
- Bidirectional: Show connections in both directions
- Downstream: Show only outgoing connections
- Upstream: Show only incoming connections
- Single: Show only the selected node
-
Zoom Reset: Reset the graph to its original position and scale
API
graphviz_widget
def graphviz_widget(dot_source: str = "digraph { a -> b; }") -> widgets.VBox:
"""Create an interactive Graphviz widget.
Parameters
----------
dot_source
The DOT string representing the graph
Returns
-------
widgets.VBox
The widget containing the graph and controls
"""
Dependencies
- anywidget
- ipywidgets
- graphvizsvg (npm package)
- d3-graphviz (npm package)
- hpcc-js-wasm (npm package)
Development
We recommend using uv for development. It will automatically manage virtual environments and dependencies for you.
uv run jupyter lab example.ipynb
Alternatively, create and manage your own virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
jupyter lab example.ipynb
The widget front-end code bundles it's JavaScript dependencies. After setting up Python, make sure to install these dependencies locally:
npm install
While developing, you can run the following in a separate terminal to automatically rebuild JavaScript as you make changes:
npm run dev
Open example.ipynb in JupyterLab, VS Code, or your favorite editor
to start developing. Changes made in js/ will be reflected
in the notebook.
License
MIT
Credits
Built with:
- anywidget
- graphvizsvg
- d3-graphviz
- The WASM binary comes from @hpcc-js/wasm (via
d3-graphviz) - Inspired by the VS Code extension Graphviz Interactive Preview.
Metadata
Release files for graphviz-anywidget 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| graphviz_anywidget-0.8.0.tar.gz | 694.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| graphviz_anywidget-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.4 MB
Release files / graphviz_anywidget-0.8.0.tar.gz
| Download URL | graphviz_anywidget-0.8.0.tar.gz |
|---|---|
| Size | 694.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a5216b01df37154cc45d1e8491c88e32539ee8def3eceb0d6f4add83184c3de
|
|
BLAKE2b-256 checksum How to use checksums |
e46dc1eed27b68ab52542a76dc7a4201e3765d99236e2ef0c69cb6f6f7a6fb4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 6, 2025.
Transparency logRelease files / graphviz_anywidget-0.8.0-py3-none-any.whl
| Download URL | graphviz_anywidget-0.8.0-py3-none-any.whl |
|---|---|
| Size | 695.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
725bd6f1242964da98ec0af89ad0ed0e3e58f95a1d3d2ebee140258db940630b
|
|
BLAKE2b-256 checksum How to use checksums |
5481eb71357448aca5f512237fcf3724fca356fe0bcbded56457d934a5192855
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 6, 2025.
Transparency log