Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Expect disruption to service on Thursday, Feb. 9!

Documentation of :style?

Node Clone

The styles in Neo4j Browser (I use Mac) seem to have changed over time, and old training materials and documentation don't seem to be accurate anymore. Where is it currently documented? It does not seem to be in the Operations Guide, the Cypher guide, or anywhere else I have looked. Here are some of the issues and questions I would like to understand:

  1. In the past there was a place to drag a .grass file into the popup of a node. That doesn't exist anymore. There is an area to chose node size, color etc. manually. Any way to import into that? Any way to copy styles between nodes?

  2. In a recent upgrade the colors one can pick changed... colors I used in the past went away. Yet nodes I had previously colored kept their old colors. So now I have a mish-mash and no way to fix it other than changing all old node types to use the new colors.

  3. The :style keyword displays all the current styles. I can save that as a .grass file. If I edit that file, I do not see how to import it. Someone said to drag it into the top browser window. That pastes it there, but when I run it I get a syntax error.

  4. I've also tried entering small parts of a .grass file into the window, and always get syntax error.

  5. I tried prefacing all the .grass info with ":style " and entering it in the window but that doesn't help.

  6. Someone said you can import it from a URL. They had put a .grass file on a web server. Not wanting to do that, I tried a local URL like "file://~/Downloads/my.grass" but that got the same error. Should that work?

  7. ":style rest" clears out all the styles. :style then says "No style generated or set yet. Run a query and return a few nodes and relationships to generate some styling." After running a basic query there are indeed some default styles loaded. Where is it getting the defaults? Are they in a file somewhere that I can influence?

  8. Where are custom styles I set persisted? Obviously they are saved from session to session. I'm not finding a .grass file saved somewhere. All this experimenting has lost the styles I had set. I could restore them from backups... if I knew where they were.


Node Clone

The "one line hack" method does not seem to be working. I can get :style to execute a minimal command:

:style node.EFSDirectory { defaultCaption: ""}

but not any structures with multiple options (I tried various deliimters):

:style node.EFSDirectory { defaultCaption: ""; text-color-internal: #604A0E;}

And since :style seems to do a total replacement, I don't see how to load a custom set of styles... all I can do is :style reset, and then manual styling by hand with the mouse.

What am I missing?

Node Clone

OK, I found where to import .grass files: in the Favorites tab, Import window. Odd place, but OK, that works.

Now where does the Browser persist what I imported? If I know that, maybe I can restore that data from my backup from before it got damaged.

I found neo4j.grass in my localStorage (in Chrome it's underneath Application).

To be able to copy-paste the relevant style info, I used the console to do JSON.parse(JSON.stringify(localStorage))['neo4j.grass']

Graph Voyager

Note this has changed. You can now import directly from your computer .grass and .cypher files by dragging and dropping anywhere onto the Browser. As seen here:

This feature seems to have vanished with upgrade to Neo4j Browser version: 4.0.3

The drag and drop option is gone.

How can we customize the style.grass settings now?

Disregard ... can now drag and drop the style.grass file ANYWHERE in the app ... neat ... but not well documented ...

Although it's possible to link to the .grass file on the localhost (having set it up in the Neo4J Desktop configuration for the database :-

browser.post_connect_cmd=style http://localhost/~username/Neo4j/myneo4jdatabase_styles.grass

I found that this wasn't sufficient because the browser has to be authorised otherwise a Access-Control-Allow-Origin (CORS) error occurs preventing the browser loading the .grass file. In the end I solved this by modifying the Apache httpd.conf file adding:

# Modification to allow Neo4J .grass file to be loaded
# To prevent error: Failed to load resource: Origin http://localhost:7474 is not allowed by Access-   Control-Allow-Origin.
<FilesMatch "\.(grass)$">
    <IfModule mod_headers.c>
	 SetEnvIf Origin "http(s)?://(localhost)$" AccessControlAllowOrigin=$0
         Header Set Access-Control-Allow-Origin "*"
# End of modification

It still suffers the same problem as the file-drop method wrt to the older method of dropping onto the specific .grass file area in the Favourites tab - the browser seems to cache the styles so simply changing the .grass file isn't enough to change the style returned - the browser has to be refreshed losing the earlier query results.