No project description provided
Project description
jupyter_anywidget_graphviz
Jupyter anywidget
for rendering diagrams from .dot
language to SVG using Graphviz Wasm (hpcc-systems/hpcc-js-wasm
).
Install as:
pip install jupyter_anywidget_graphviz
Usage
This runs in a browser based Jupyter environment and uses the browser machinery to run the wasm application.
# Import package
from jupyter_anywidget_graphviz import graphviz_headless, graphviz_panel, graphviz_inline
# Create a headless widget
# - works in: Jupyter Lab, Jupyter Notebook, VS Code
g = graphviz_headless()
# Inline mode
# Preview output as cell output from initialising cell
# - works in: Jupyter Lab, Jupyter Notebook, VS Code
# g = graphviz_inline()
# Create a widget panel with a handle
# - uses jupyter sidecar (Jupyter Lab only)
#g = graphviz_panel()
# Load magic
%load_ext jupyter_anywidget_graphviz
We can now write dot
code in a magicked code cell (%%graphviz_magic WIDGET_HANDLE
):
%%graphviz_magic -w g
strict graph {
a -- b
a -- b
b -- a [color=blue]
}
The -w / --widget-name
setting can be used to set the widget within the magic and it does not need to be passed again.
The widget can also be set via line magic: %setwidget g
The output is previewed in the UI panel, if rendered.
Retrieve the SVG diagram as WIDGET_HANDLE.svg
.
We can display the diagram in the notebook e.g. as:
from IPython.display import SVG
SVG(g.svg)
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
Hashes for jupyter_anywidget_graphviz-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9604f9fc17101fb000bd960077e3c3df483b619f40307b63d3d4f81a112d2e6a |
|
MD5 | 629097b3bd671bf66748c28c75b308db |
|
BLAKE2b-256 | 505446307886af5566f625d5a19539603a0691d2a1f9aa05a266df4abe458a11 |
Hashes for jupyter_anywidget_graphviz-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eca0ebf8c1cebd0c7533c7bc216b815b2e1d0afc056974dfa4ae3d9b56e1e10 |
|
MD5 | 149abb4428e922d447dee9f882e8adee |
|
BLAKE2b-256 | fb2856ca8f67e6110e01934939999ee180e95f200050152882fab473a538c0ff |