Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm having a hard time setting properties for nodes with multiple labels.
My graphstyle.grass file looks like this:
node {
diameter: 40px;
color: #aaaaaa;
border-color: #888888;
border-width: 1.5px;
text-color-internal: #000000;
caption: '{name}';
font-size: 12px;
node.foo {
color: #aaaaff;
node.bar {
color: #aaffaa;
node.bar.a {
border-color: #ff0000;
node.bar.b {
border-color: #0000ff;
So the intention here is that if you have a label of 'bar' the node is colored a certain way, if you also have an additional label of 'a' or 'b' your border is colored appropriately. My CSS knowledge is weak but I think this is traditionally how multiple class selectors are done.
The behavior I'm seeing in the Neo 2.0.1 browser graph display is that if a node has multiple labels, it picks the first label, tries to find a node.first_label selector in the grass file, if it doesn't find it it just adds a new selector for it. So two concrete examples:
If there's a node with labels ['bar','a'] (in that order) then Neo4j will find the node.bar selector above and use it, not doing anything with the second class.. i.e. the 'node.bar.a' attributes won't be applied.
If the node has the labels ['a','bar'] (in that order) then Neo4j will look for a selector of the form 'node.a' and not invoke any of the selectors above but instead create a new selector with a set of default parameters.
Any guidance or suggestions are greatly appreciated.
That's a perfectly sensible approach, which would be correct. As of Neo4j 2.0.1, the graph stylesheets aren't yet clever enough to handle chained class selectors. The order of selection is (as you've observed) also broken.
update:
As of 2.2, multiple class selectors are supported, as long as you edit the grass definition by hand.
–
–
–
–
–
Maybe use Alchemy's SVG+CSS support for dataviz instead? (sending data to it via GraphJSON) - http://neo4j.com/developer/guide-data-visualization/#_library_alchemy_js_open_source_graph_visualization
http://graphalchemist.github.io/Alchemy/#/docs
is says:
"Styling through CSS tends to be inflexible, as it's not related to the data in any way. However, some people may want to use an obscure feature offered by SVG/CSS, and we've made sure that that is easy to do. The svg elements of the nodes and edges receive classes that correspond to the types defined in the configuration options edgeTypes and nodeTypes. To create the same graph with css you can assign css styles based on those classes. Based on our data and this example we can use this css to generate the graph that follows"
Although it calls CSS inflexible, if SVG does support such CSS concepts like the ones you seek, I feel it's more flexible than the default way alchemy proposes you do the styling
I wonder if Alchemy supports images (bitmap and SVG ones) btw for nodes. I would also like to see multiple images (each for a label of the node) overlaid somehow (ordered based on label order if there's a label order concept indeed in Neo4j). Probably if one uses code similar to Popoto.js (http://www.popotojs.com/) which also uses D3
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.