Provide tags as graph CSS classes/attributes to allow coloring of graph nodes

Within Obsidian I work a lot with tags, to differentiate between different types of notes.
0.9.0 graph view already allows us to use different colors for tag nodes and attachment nodes.
But what would be really amazing in my opinion is, if we could assign different colors to note-nodes according to their tags (in graph view).

I donā€™t know how complicated (or even possible) the CSS -> WebGL conversion would be, but I could imagine the following methods:

a) Make tags accessible through a tag attribute. The tags attribute would contain a whitespace separated list of all tags on this node.
This would allow styling the nodes similar to the Tag Pills (Common CSS hacks) by using something like:

.graph-view.color-fill[tag~=idea] {
  color: blue;
}

This would also allow other fancy tricks as described in HTML attribute selectors.

b) Make tags available as classes so that we can access them like:

.graph-view.color-fill.idea {
  color: blue;
}

or maybe:

.graph-view.color-fill.tag-idea {
  color: blue;
}

I saw a bunch of other threads talking about similar ideas (coloring/highlighting graph nodes).
But exposing them for CSS would be the most flexible option.

33 Likes

This would also (partly) solve this feature request to some extent and address this comment.

3 Likes

I would also love this! I used this a lot in Neo4J Bloom and itā€™s so pretty and useful :slight_smile:

3 Likes

This would also also make it easier to use notes as tags on other notes, instead of making pages for all tags as requested here. (I promise that sentence is coherent in context. Cf. the discussion on that request.)

Another approach would be to support this through YAML metadata on a note.

1 Like

This would be super cool. Allowing for additional layer of usefulness to the graph.

One thing Iā€™m wondering is if a note has multiple tags, what will happen then? Colors mix, or one of the colors takes over?

1 Like

Iā€™ve implemented graph styling, including coloring by tags, in the Neo4j Graph View Plugin:

2 Likes

According to the CSS specification id multiple rules (with same specificity) apply to the same element. The last rule inside the css file is applied.

So if we got

.graph-view.color-fill[tag~=idea] {
    color: blue;
}
.graph-view.color-fill[tag~=todo] {
    color: red;
}

And the node is tagged with #todo and #idea the node would show red (because this rule is later in the css file).

Altough mixed colours would be pretty amazing :star_struck: but you could do that with a third css rule manually:

.graph-view.color-fill[tag~=todo].color-fill[tag~=idea] {
    color: purple;
}

Which should have higher specificity if I understand it correctly.

1 Like

I want this too! Is there a way to change the color of the nodes in graph view?

I would love to use this - mainly some notes function as hubs within my graph and it would be nice to highlight them

1 Like

I also would like to have this feature. However, I would already be very happy if could cluster tags under a certain class and exclude or include them in my search.

The way my Obsidian vault is set up is that I have different classes of tags and which have different colors. I have type tags that are grey and which tell me that a note is literature note or concept note or an author note. I have discipline tags which are red and tell me within which disciplines a note falls for example history, economics or philosophy. These are colored red. I also have status tags which tell me the status of certain note, those are purple. And finally I have keyword tags which are the standard color.

I donā€™t know if there is already a way to cluster tags in these way, without manually having to type every tag which falls under the cluster. I would be nice if you could you add a tag once to a certain cluster when you start using it and then never have to worry about it.

I just realized that V0.11.0 adds the possibility to define groups via queries and assign a color to them :heart_eyes:.

Screenshot 2021-02-16 at 22.58.05

This basically solves my request. BUT the problem is that groups are cleared in new local graphs (in the global graph they persist).

It would be great if we could define default groups for all newly opened local graphs or an option so that the groups persist when the local graph is closed and opened again.

8 Likes

Not sure if it might be better to open this as a new feature-request so it doesnt get lost. Anyway - now that we have the color-groups for graphs i would like to request predefined groups that i can switch between.

Why? I love the coloring to easy spot different things in the graph, depending on what i am after i use completely different search-phrases for the colors.

I.e. : i color all my MOCs, the status of notes (seed, fleeting, permanent etcā€¦) and can get an idea of the overall ā€œhealthā€ and state of my pkm
Then i filter only atomic notes and links between and color them to see what overall Themes they fit in - here i can see what Themes are bad linked (lots of orphans) or if there are themes often intersecting ā€¦

This goes onā€¦ To do it right now, i have to setup the coloring each time i change what i want to look at.

Goal: I would like to be able to define color-groups (maybe elsewhere, in a file or in another menu), name the whole group and just tell the graph to use a certain pre-defined ā€œcolor-groupā€ then.

2 Likes

If this is not already up as a feature request, I second it!

Iā€™m about a week into Obsidian and was over the moon to see I could colour-group my graph view by tags (#people, #books, #songs, concepts etc). However when messing with other graph settings later, I hit ā€˜restore defaultsā€™ and it deleted the beautiful colour schemes I had set! Not a huge deal to fix a few days in, but I can only imagine the anguish if I had been a month in and accidentally deleted the colour-tagged groups.

1 Like

My input is that expanding tag and interactive tag related graph functionality in general would make obsidian much more useful and differentiated for use with real world projects and content management workflows.

In addition to supporting graph color options ā€• I would request and suggest adding shape-icon, and graph visualization options and functionality that support how tags are used, visualized and navigated to provides a more generalized and complete solution for managing and interacting visually with our knowledge graph and use of tags.

Below are an image and explanation to help communicate these points:

IMAGE

EXPLANATION:

 A. On the left is an example panel for (1) selecting tags by pre-configured types, classes, etc. and (2) selecting graph visualization by types (just 2 here, but there are several other types commonly used by mind-mapping type apps)
 B. On the main graph in the center are examples of how these visualizations might look by example. Note they are imagined as foldable visualizations and iconic on the main graph to reduce clutter.  This would allow fast visual confirmation of the type of tag organization type or class is being used by the underlying content
 C. On the right is an example of the pane showing the iconic visualization un-folded in the main graph showing it in full detail, color matched when the node is expanded in the main graph.
 D. To provide maximum flexibility is it would be best if these selections are FILTER type selections, which could stored as views, to give the underlying content and tags and visualizations maximum flexibility depending on how the user wants to slice and dice their content in different ways to match different workflow needs. And, perhaps subsets locked into a particular style differently for each particular stored view.  NOTION does this multi-view store quite well.

SAMPLE USE CASE EXAMPLES

Vault contains CONTENT user wants to partly organize and at times visualize as structured and part unstructured.

  • One part or at one time visualizing KBASE to discover related concepts as a result of tagging over time
  • Managing the same content but visualizing it based on different projects within the whole KBASE GRAPH or graph subsets larger than themselves see and manage: (1) hierarchies of pages, categories, tags and content for a website, (2) book, chapter, pages of a book ā€• and for these providing a way to (3) turning on and off different types of tags that would show concepts linked to nodes in (1), (2) while they remain visualized in a their structured form.

This type of approach might enable a very high degree of visualization and content management capability and flexibility, while being easy to use.

6 Likes

This is great! Do you know if itā€™s also possible to use groups or CSS to selectively colour nodes in Obsidian Publish?

1 Like

Thank you for all these great tips! Iā€™m wondering if thereā€™s a way to use CSS to change the color of neighbor links. Any advice would be most appreciated. Thanks!

just giving my +1. Iā€™ve got a vault Iā€™m using for complicated task dependency tracking, and this would be super handy to help me instantly comprehend the task situation.

1 Like

+1

I really need it.

It would be so simple to implement it. I think Obsidian would just have to add a dynamic css class to nodes according to its tag or tags.
Then, they tell us how class works and then we would be able to target them with custom css.
Am i right ?

Graph view is the major feature of Obsidian. Why do they keep it such basic in obsidian publish ?

:slightly_smiling_face:

1 Like

Thereā€™s a graph nowadays which (allegedly) allows to sync global graph settings to new local graphs

1 Like