reox8631 downloadsRender Graphviz code blocks as diagrams, with a button to flip each one between the diagram and its source.
Draw graphs in your notes with Graphviz and its DOT language. Write a
graphviz code block and the graph appears in its place, in Reading view and Live Preview, on
desktop and mobile. No Graphviz installation needed.
```graphviz
digraph {
rankdir=LR
idea -> draft -> review -> published
review -> draft [label="changes"]
}
```
To install by hand instead, download main.js, manifest.json and styles.css from the
latest release into
<your vault>/.obsidian/plugins/graphviz-diagram-preview/, then enable the plugin.
Put DOT code in a code block tagged graphviz. Blocks tagged dot are left as plain code. The
DOT language guide explains the syntax. To use another
layout engine, set it in the graph, for example layout=neato.
Add options in braces after graphviz:
```graphviz {caption="Figure 1: Publishing" align="center" alt="Four stages from idea to published"}
digraph { rankdir=LR; idea -> draft -> review -> published }
```
| Option | What it does |
|---|---|
caption |
Text shown under the graph. |
align |
left, center or right. |
alt |
A description read aloud by screen readers. |
class |
A CSS class, for styling the graph with a CSS snippet. |
Put each value in quotes. Values are plain text, not Markdown. If an option is misspelled, it's ignored and the graph still appears.
Nodes and edges with a URL or href open in your browser when selected. Links to http:,
https: and mailto: addresses work; other links are removed and the node stays.
Labels fit their shapes best in these fonts: Times, Helvetica or Arial, Courier, DejaVu Sans,
Consolas, Nunito and Trebuchet. Graphviz measures other fonts as Times, so long labels may
overflow. Name a single font, such as fontname="Helvetica", not a list.
Graphs follow your theme. In a dark theme, lines and labels are lightened just enough to read, filled shapes are darkened, colours keep their hue, and the white background disappears. In a light theme, graphs appear on a white card with their exact colours.
A graph that sets its own background with bgcolor always keeps its exact colours. To do the same
for every graph, turn off Follow dark themes in the plugin's settings.
| Setting | What it does |
|---|---|
| Layout time limit | How long a graph's layout may take before it's shown as an error. 3 seconds by default, from 0.5 to 60. |
| Follow dark themes | On by default. Turn off to keep every graph on a white card. |
| Debug logging | Writes ignored options and Graphviz warnings, such as unknown fonts, to the developer console. |
| Command | What it does |
|---|---|
| Show every diagram in this note | Switches every block in the note back from code to graph. |
| Restart renderer | Starts Graphviz afresh and redraws open notes. |
image= and <IMG> in labels aren't supported.Graphs are drawn on your device, inside Obsidian. The plugin doesn't connect to the internet, doesn't collect any data, and doesn't read or write any files. Links in a graph open in your browser only when you select them.
Graphs are drawn by Graphviz, through Viz.js. The licenses of the software built into this plugin are listed in THIRD_PARTY_NOTICES.md.
Released under the MIT License. To build or change the plugin, see DEVELOPMENT.md.