Neo4j - set node captions to labels in web interface
Asked Answered
S

1

6

When I created my graph database in Neo4j, I thought the node label was the same thing as what the node caption would be in the web browser visualizer. Instead, the node captions are set to the first property of the node by default. Is there a way to set the node captions to be the same string as the node labels? I see that there is the graph style sheet where I can change the node captions manually, but I don't know how to set the caption variable equal to the label.

Semasiology answered 6/2, 2016 at 20:22 Comment(0)
C
7

There is a way to use a node label as a caption in the neo4j browser, but there is a caveat (see below).

You can modify the Graph Style Sheet to hard-code the caption for the node. (Click the star in the leftmost vertical panel, click the "Graph Style Sheet" button to see the sheet in a pop-up window, export the sheet to a file, make your changes, and drag-and-drop your edited file onto the "Drop a grass-file here to import" line at the bottom of the pop-up window).

For example, if your node label of interest is Person and its caption is currently the name property, then your style sheet may currently contain something like this:

node.Person {
  color: #FFD86E;
  border-color: #EDBA39;
  text-color-internal: #604A0E;
  caption: '{name}';
}

You can change the caption to hardcode the label to "Person", as in:

node.Person {
  color: #FFD86E;
  border-color: #EDBA39;
  text-color-internal: #604A0E;
  caption: 'Person';
}

That is all fine; but, in general, a node can have multiple labels -- and the above approach will only display one of those labels for a node. Doing a little experimentation, it seems like the label displayed is the first label that was added to the node.

Carlottacarlovingian answered 6/2, 2016 at 22:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.