添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
稳重的皮带  ·  vue---element ...·  1 年前    · 
安静的油条  ·  超简单,用Python ...·  1 年前    · 
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.

    Thx Andreas, I'm a super big fan of Neo4j.. woot woot! The new label support is great and multiple labels will be popular so having this small issue addressed will probably help quite a few people. :) – Brian Wylie Mar 1, 2014 at 21:24 Thanks for Info! Does Neo4J have a bug tracker and is this issue added already? Would be great to be able to follow the progress of this. – John Mar 10, 2014 at 10:02 Hey, we were tracking this internally on the backlog of a trello wall. I've hoisted it out to a github issue so further comments and suggestions can occur there -- github.com/neo4j/neo4j/issues/2112. Also, this is an area where I'd love someone who loves javascript and CSS hacking to get involved. Ping me if that's you. – akollegger Mar 12, 2014 at 20:00 So there is an order for labels of nodes in Neo4j? How do you reorder labels via Cypher? Do you remove them all and add them again in the order you want? – George Birbilis Apr 18, 2015 at 16:53 The order is only for the CSS-style application of styling in the graph visualization, not within the property graph model itself. – akollegger Apr 20, 2015 at 3:56

    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.