Graph View presets to save and load filters & display settings

Looks like the latest version of Release v0.2.0 - Workspaces support (thanks zjhcn!) · Sanqui/obsidian-persistent-graph · GitHub also saves the filters etc as well as just the node positions.

1 Like

A work around for this would be to go to folder “.obsidian” in your vault and find the “graph.json” file. This file contains all the info regarding the filters you;ve created.
Then, you can save it with another name and whenever you want to use it just rename it as “graph.json” so that it replaces the existing one.

You can of course automate this with a Python/other script

:warning::warning:: You have to reload Obsidian in order for those changes to take effect. Otherwise the .json file is going to be overwritten by whatever you do in Obsidian.

+1 After two years… Is there any possibility this is implemented? Thanks

Please, please, please. +1!!!

Well, I think it’s easier to just re-write or paste the filter.

+1 on this feature, it’s a must have! Has any developer started looking into this already? If there is a WIP pull request, I’d be happy to help.

1 Like

Another +1 on this, I’d love to be able to have several views of my graph to see connections, and right now its a bit too busy for me to get much from it, but some alternate views and good filtering could really help in that regard. So much promise in this function!

1 Like

You can already do this from inside Obsidian if you want. Below are full instructions on how to save and load different groups and filters settings for Graph View.

Here is a working demo vault you can download which will let you test a live demonstration of it, with further documentation:

:floppy_disk: Download demo vault

This is the easiest way to get started, as you can live-test the settings in the demo vault and already see them working.


How to save and load Graph View groups

I’m using Dataview here because it’s a super easy way to view and modify Obsidian settings. Equally you could use any plugin which let you run arbitrary Javascript in Obsidian - for example the Buttons plugin.

Getting your current groups

Put this code into a note to retrieve your current group settings:

```dataviewjs
const settings = await app.internalPlugins.plugins.graph.loadData()
dv.paragraph('```json\n' + JSON.stringify(settings, null, 2) + '\n```')
```

It will show you something like this:

{
  "collapse-filter": true,
  "search": "",
  "showTags": false,
  "showAttachments": false,
  "hideUnresolved": false,
  "showOrphans": true,
  "collapse-color-groups": false,
  "colorGroups": [
    {
      "query": "tag:#is-tagged",
      "color": {
        "a": 1,
        "rgb": 4468453
      }
    },
    {
      "query": "-tag:#is-tagged",
      "color": {
        "a": 1,
        "rgb": 14684176
      }
    }
  ],
  "collapse-display": true,
  "showArrow": false,
  "textFadeMultiplier": 0,
  "nodeSizeMultiplier": 1,
  "lineSizeMultiplier": 1,
  "collapse-forces": true,
  "centerStrength": 0.518713248970312,
  "repelStrength": 10,
  "linkStrength": 1,
  "linkDistance": 250,
  "scale": 1,
  "close": false
}

TAKE A COPY OF WHAT IT SHOWS YOU - these are your current saved settings. You don’t want to lose them and have to re-set them up.

You can change any of the settings here. For our demo, we’re just going to be updating the groups, which are in the colorGroups property.

Updating the groups

Take the code below and put it into a note. It will update all your graph groups to be the two groups specified, #this-is-the-new-query and #another-new-query.

```dataviewjs
const graph = app.internalPlugins.plugins.graph
const settings = await graph.loadData()
settings.colorGroups = [
  {
    "query": "#this-is-the-new-query",
    "color": {
      "a": 1,
      "rgb": 16185856
    }
  },
  {
    "query": "#another-new-query",
    "color": {
      "a": 1,
      "rgb": 16187906
    }
  }
]
app.workspace.detachLeavesOfType('graph')
await graph.saveData(settings)
await graph.disable()
await graph.enable()
```

If you follow the structure inside the settings.colorGroups section, you can update the groups as you wish.

To change between different groups profiles, you just need to launch the Javascript code above. You could:

  • Create a couple of different notes with the groups that you want, and just load one of the notes to change all your groups.
  • Put the code in a Templater script and launch it from a hotkey.
  • Or one of the many other plugins which let you run arbitrary Javascript in Obsidian.
2 Likes

My thoughts exactly! I wonder if there is workaround using the current URI syntax that could bring this to life with advanced URI?

1 Like

I created a plugin that allows saving and loading graph view settings.
link: https://github.com/ycnmhd/obsidian-graph-presets

9 Likes

Firstly, great job with this plugin. It’s a relatively simple implementation but has already done wonders in how I interact with my large obsidian graph. ‘Workspaces’ is one of my favorite plugins and this plugin provides me with similar functionality for the obsidian graph view.

Do you have any plans to implement a better UI for the plugin? One where there are collapsable menus similar to what can be found on the official graph view?

I would love to see a roadmap so that I can try to contribute in some way.

1 Like

I’m glad the plugin is of help to you.
I’m currently working on storing graph settings in markdown. I believe this approach solves many of the pain points using native obsidian features and lowers the footprint of the plugin.
Given how new it is, there is no roadmap yet.
2022-12-28_19-27-48

3 Likes

Use case or problem

It would be very efficient if I can have multiple Graph Views that persist…say one Graph View for Ideas, one for #thoughts, etc. Similar to how you have a Database View.

Proposed solution

Provide the ability to have persistent Graph Views you can save so that you don’t have to reconfigure the view each time for a specific purpose

Current workaround (optional)

I’m new to Obsidian (I love it btw!) so I’m not sure

Related feature requests (optional)

1 Like

Hello.
I know, know that this request already posted many times…but it’s HIGHLY needed, especially for wide graph trees. Quick switching between views in a graph activates a creative look at the whole mind-data.

Please, add, maybe just in a same vault-folder in *.xml format. It’s a true way for effectiveness. Saving and loading with just 2-3 clicks. Switching between structured views with 2-3 clicks - easy way. Thanks for reading.

1 Like

Absolutely +1 to this idea. I use my obsidian vault for organizing multiple areas of my life, with the main goal of making it an all-in-one reference space for everything (i.e. second brain vibes). It’s turning out that essentially means I’m housing multiple databases in one, so having a preset for the graph views of these databases would be game changing for me.

Right now I’m keeping a note with a list of my filter settings for each database for me to copy and paste when I need them.

1 Like

+1 from me as well! I desperately need to be able to store multiple settings of the graph view as I use it extensively in the planning and strategic parts of my research group.

Actually, it would be very simple to just write a plugin to do this IF there was a “reload graph from graph.json” function exposed in the API (a function that has to exist somewhere since it does that operation at start).

The new bookmarks core plugin can be used to save different graph view presets:

7 Likes

+1
<3

I think this issue can be closed now. Bookmarking a graph saves all of its settings — filters, aesthetics, etc.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.