Graphs Plus

approvedunreviewed

by jsmorabito

A graph view that looks and behaves like the core graph, but can be opened several times, saved to .graph files, and extended.

↓ 254 downloadsUpdated 21d agoMIT

Graphs Plus

A graph view for Obsidian that looks and behaves like the core graph view, with a few things core can't do:

  • Open as many as you like. Each graph view keeps its own search, filters, groups, display and forces.
  • Save graphs to files. A .graph file holds a view's settings, camera and layout, so it reopens looking the same. It works like .canvas and .base files: open it from the file explorer, rename it, link to it.
  • Sandbox graphs. Start from an empty graph and add notes by hand, or add a note together with the notes it links to.
  • Extend it. Other plugins can recolor, fade and enlarge nodes and links through a small API.

Everything core offers is here too: the local graph, color groups, tag and attachment nodes, orphans, the timelapse animation, hover previews and the query search syntax (path:, file:, tag:, content:, line:, section:, [property:value], regex), with the same suggester.

Usage

Open a graph from the command palette, or turn on Show ribbon icon in the plugin's settings to get a ribbon button. Commands:

CommandWhat it does
Open graph viewA graph of the whole vault
Open sandboxAn empty graph you add notes to
Open local graphA graph around the active note, following it as you switch notes
Create new graph fileA new .graph file of the whole vault
Create new empty graphA new .graph file that starts empty, like a sandbox
Save the active graph as a graph fileSaves the open graph view to a .graph file
Export the active graph as a canvasWrites the graph's current layout to a .canvas file
Copy settings from the core graph into the active graphBrings over your core graph's filters, groups, display and forces
Start timelapse animationCore's animation, building the graph up in file-creation order
Search in the active graphFocuses the graph's search box

Right-click a folder for New graph, or a note for Open local graph in Graphs Plus.

By default, clicking a node opens the note, as in core. In the plugin's settings you can switch this to show a card with the note's links and a preview.

The .graph format

A .graph file is JSON. Its options use the same keys as core's .obsidian/graph.json:

{
  "format": "graphs-plus",
  "version": 1,
  "mode": "vault",
  "options": { "search": "tag:#project", "showTags": true, "colorGroups": [] },
  "camera": { "scale": 1, "x": 0, "y": 0 },
  "positions": { "Notes/Idea.md": [120.5, -40] }
}

mode can be vault, sandbox (with a members list of paths) or local (with a localFile). Nodes come from the vault every time the file opens, so positions only records where they were. Graphs Plus won't open or overwrite a .graph file that doesn't have "format": "graphs-plus".

API

const api = app.plugins.getPlugin("graphs-plus")?.api;
for (const graph of api.graphs()) {
  graph.setOverlay("my-plugin", {
    nodes: new Map([["Notes/Idea.md", { rgb: 0xe0a030, alpha: 1, sizeBoost: 4 }]]),
    edges: new Map(),
    dimAlpha: 0.3, // fade everything the overlay doesn't mention
  });
  graph.focus("Notes/Idea.md");
}

Each plugin paints its own named layer, and setOverlay(key, null) removes it. Edges are keyed by their two paths, sorted and joined with "\u0000" (edgeKey in src/overlay.ts). See src/api.ts and src/overlay.ts for the types.

Installing

Graphs Plus isn't in the community plugin list yet. To install it:

  • With BRAT: add jsmorabito/obsidian-graphs-plus as a beta plugin.
  • By hand: download main.js, manifest.json and styles.css from the latest release into .obsidian/plugins/graphs-plus/ in your vault, then turn the plugin on in Settings → Community plugins.

Development

npm install --legacy-peer-deps
npm run dev     # watch build
npm run build   # type-check and production build
npm test        # Vitest
npm run lint

The graph logic (building the graph, search, filters, forces, the .graph format) lives in modules that don't import obsidian, so it runs under Vitest in Node.

License

MIT

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.