How to get different colors for different labels when having multiple labels for a node

MERGE (a : Bus : GenBus {type: 'GenBus', gencapacity:630, name:'NCTPS', bus_no:1, available_generation:630,status:'Not Connected'})
MERGE (c : Bus : LoadBus {type:'LoadBus', load:285, name:'TONDAIYARPET', bus_no:3, status:'Not Connected'})
MERGE (a) - [ :TRANSMISSION_LINE {line_no:2, length:9, available_cap:1000, status:'Not Connected'}] -> (c)

Above are some lines of my cypher.
All i have is 19 nodes. Every node has common label :Bus
Among those 14 are labeled :LoadBus and 5 are labeled :GenBus.
It means every node has 2 labels. Bus is common to all and 2nd label is either LoadBus or GenBus
When i return all the nodes, all the nodes are in same color. I want to change the LoadBus to green color and GenBus to red color. They are in same color even after changing their color.
How to do it?
In the below photo big ones are GenBus es and small ones are LoadBus es

Because your nodes are all of the type Bus as a broad category you're not going to be able to shift their colors based on a sub type. You need to create separate nodes for each bus type that you want to represent. Then your color scheme will work as desired. It's also much more explicit.

What you can do if you have multiple labels on a node is to "prioritize" the colouring within the style.grass file. So, basically you can give the styling of nodes with the labels "LoadBus" and "GenBus" a higher priority than nodes with the label Bus.

How to:

  1. type ":style" into the Neo4j Browser.
  2. Save the output in a file with the ending ".grass".
  3. Edit the file in a text editor (move entries up and down). The entries that are further down are "more important".
  4. Insert the file back in the Neo4j browser (click on the star in the left bar ("Favorites" and drag and drop into the Import box.)

From my experience you will then get, what you asked for.

10 Likes

It works well sir.
Today i learn something from you. Thank you so much sir... :heart:

First what i did is, i saved the file with extension .grass.
But it shows some error. In that error GraSS is there. Then i saved the file with .GraSS extension.
Then it worked.

Also see:

1 Like