neo4j-contrib / neovis.js

Neo4j + vis.js = neovis.js. Graph visualizations in the browser with data from Neo4j.
Apache License 2.0
1.62k stars 324 forks source link

[2.0.0] Node scaling not working #197

Open aguinaldoabbj opened 3 years ago

aguinaldoabbj commented 3 years ago

Hi again, @thebestnom !

In my vis app I was trying to use the automatic scaling of vis.js by setting the "value" attribute instead of the "size" attribute.

However, if I try to map the value attribute to a property of a node it doesn't work. All the nodes stay with the same size:

download (1)

The nodes in red and blue have a "inDegree" attribute in Neo4j. I can map the label though. Am I doing something wrong ?

{
  "container_id": "viz",
  "neo4j": {
    "server_url": "neo4j://1.1.1.1:7687",
    "server_user": "",
    "server_password": ""
  },
  "labels": {
    "E": {
      "value": "inDegree",
      "label": "node_id",
      "[NeoVis.NEOVIS_ADVANCED_CONFIG]": {
        "static": {
          "color": "lightblue",
          "shape": "dot",
          "font": {
            "color": "black",
            "background": "none",
            "strokeWidth": "0",
            "size": "20"
          }
        },
        "function": {
          "color": "(node) => {if (node.properties['Type'] == 'info') return 'lightblue'; else return 'tomato';}"
        }
      }
    }
  },
  "initial_cypher": "MATCH p=(:E)-[]-() RETURN p LIMIT 100"
}
thebestnom commented 3 years ago

This is really weird... It should just work 😅 Maybe they all have the same value? If the shape is dot which you did the value should just scale...

aguinaldoabbj commented 3 years ago

This is really weird... It should just work Maybe they all have the same value? If the shape is dot which you did the value should just scale...

Yep, this is weird.

The nodes have different values for this inDegree attribute, as you can see if I access the viz object in the console: Screenshot_20210912_142442

Do you know where could I find out if the "value" attribute is indeed being mapped?

aguinaldoabbj commented 3 years ago

This is really weird... It should just work Maybe they all have the same value? If the shape is dot which you did the value should just scale...

Yep, this is weird.

The nodes have different values for this inDegree attribute, as you can see if I access the viz object in the console: Screenshot_20210912_142442

Do you know where could I find out if the "value" attribute is indeed being mapped?

Another strange thing: if I use value approach for just one of the labels, every node configured in Neovis gets the same size, for all labels...

thebestnom commented 3 years ago

just tested on data from https://github.com/neo4j-contrib/neovis.js/issues/198#issuecomment-919372724 with same configuration (except the value is mapped instead of cypher) and it's just works...

CinderD commented 2 years ago

cypher: { value: "MATCH (n) WHERE id(n) = $id RETURN n.pagerank", label: "MATCH (n) WHERE id(n) = $id RETURN n.name" }, I tried. Both the label and the value could only be extracted from the cypher statements.

sergiivolchkov commented 2 years ago

@aguinaldoabbj try moving your definition of node shape from [NeoVis.NEOVIS_ADVANCED_CONFIG].static to config.visConfig.nodes, e.g.:

{
    "container_id": "viz",
    "neo4j": {
        "server_url": "neo4j://1.1.1.1:7687",
        "server_user": "",
        "server_password": ""
    },
    visConfig: {
        nodes: {
            shape: 'dot'
        }
    },
    "labels": {
        // ...
    },
    "initial_cypher": "MATCH p=(:E)-[]-() RETURN p LIMIT 100"
}

The example that @thebestnom referenced uses that style of config. For me it also worked with the visConfig option.