cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

NEODASH - node colour

guido
Graph Buddy

I have created the following representation:

MATCH (p:Producer)-[r:HAS_NAME_VARIANT]->(n:Name)-[r2:FOUND_IN]->(s:Source)
WHERE n.text = $neodash_name_text
MATCH (p)-[r3:HAS_NAME_VARIANT]->(n2)-[r4:FOUND_IN]->(s2:Source)
MATCH path=(p)-[r]-(n)-[r2]-(s)
RETURN s2.title, p, n, r, r2, n2, s, s2, r3, r4

I want the node n to have a different colour when the relationship property r.qualification has the value "preferred".
Currently nodes can only be coloured in function of node properties. 
Is there a workaround? Thanks!

1 ACCEPTED SOLUTION

Indeed, you can only apply rules to nodes.

The only way right now is to set a new property on your nodes to be able to change the color.

The workaround is to set a property on relationships with HTML color values then use the property name in the settings for the parameter: Relationship Color Property.

Regards,
Cobra

View solution in original post

8 REPLIES 8

Hello @guido 🙂

I think it's possible if you go in the settings then click on the button set rule-based styling. More information here.

Regards,
Cobra

Hi @Cobra ,

Thanks for the reply. 

Only properties of the node and related nodes are listed in the rule-based styling window, but not relationship properties...

The manual states that also "simple fields (text, number)" can do the job. Does that mean that I can create such a field in the code (e.g. 1 if node property = "preferred")? If so, can you please show me because this transcends my limited knowledge of Cypher (30+ years of experience in relational databases but only 6 months in graphs 😉).

Indeed, you can only apply rules to nodes.

The only way right now is to set a new property on your nodes to be able to change the color.

The workaround is to set a property on relationships with HTML color values then use the property name in the settings for the parameter: Relationship Color Property.

Regards,
Cobra

Thanks.
Adding a property to the node only works for 1:1 relationships, but not for 1:n...
I'll try and figure out how to set up the workaround.

bennu_neo
Neo4j
Neo4j

Hi @guido !

I'm interested on your use case and I would like to understand it better (so I can help providing a fix if needed). How does your query results look? Are you planning to change the color of a node based on what condition on the subset of relationshipS? If there's always one relationship, why isn't that property part of the node?

Regards

Oh, y’all wanted a twist, ey?

guido
Graph Buddy

Hi @bennu_neo 
Thanks for you reply.
I have solved the issue in the meantime (see Cobra ).
To answer your questions: I want to change the color of lines in a table, based on a property of the relationship. It is a 1:n relationship, so the content of the same node n2 in (p)-[r3:HAS_NAME_VARIANT]->(n2) can be "preferred" for one p and "alternative" for another.
But, as I said, problem fixed. Thanks for your interest!
(could you maybe have a look at my recent question: https://community.neo4j.com/t5/neo4j-graph-platform/data-importer-how-to-import-null-values/m-p/5847...)

Hi Guido,

Can you please tell me how can I show the different path having different color  from node A to node B in map. See there are more than one path form  node A to node B, So I want to show that paths in different color in map. How can I do that? Can you please tell me?

Thank you!

Thanks and Regards

Rohit Kumar

@rohit_kumar01 
Hi Rohit,
i am using NeoDash to represent the data. It has pre-formatted field settings in which I can indicate conditional colours. So I wouldn't know how to do it in code.... sorry!

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online