Skip to content

Interactivity

Works only with strategy inline.

Searchable text

Search text in the diagram with Cmd + F.

⚠️ Note: text search doesn’t work for Vizdom.

📝 Note: links in diagrams combine nicely with link previews.

Graphviz

linkbcdef

Vizdom

Mermaid

link

link

c

d

e

f

link

link

c

d

e

f

D2

linkbcde

⚠️ Note: dark mode doesn’t work for strategy=inline for D2 due to CSS conflicts

Progressive enhancement with JS

When SVG inlined one can use JS to add interactivity. For example,

[...document.querySelectorAll(".node")].forEach((n) =>
n.addEventListener("click", () => alert("Hello"))
);

Some diagrams may provide as well additional data, for example, Vizdom

import { json } from "@dagrejs/graphlib";
document.querySelectorAll(".vizdom").forEach((container) => {
const data = container.getAttribute("data-beoe")
? JSON.parse(container.getAttribute("data-beoe")!)
: null;
if (!data) return;
const graph = json.read(data);
// ...
})

Which allows to add interesting interactivity. See examples below.

Vizdom Example 1

Try hower nodes.

Vizdom Example 2

Try hower and click one or two nodes.

Notes

  • JS and CSS for those examples are not included in Vizdom Rehype plugin, but feel free to copy (from this website) and modify them
  • Graphviz Rehype plugin also provides option for data (graphFormat=dagre), but ids in SVG are not consistent with ids in JSON. So it doesn’t really work
  • Request to support JSON representation for D2

TODO

  • Search/filter by labels

See for inspiration: