neo4j-contrib / neovis.js

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

No labels or titles for relationships #378

Open nielsjansendk opened 7 months ago

nielsjansendk commented 7 months ago

Expected Behavior (Mandatory)

When I have a config file with this:

MY_CONNECTION: {
        label: 'MY_CONNECTION',
        value: 'weight',
        [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
          function: {
            title: NeoVis.objectToTitleHtml
          },
          static: {
            color: '#8DCC93'
          }
        }
      },

I expect to see a label on the relationship and to see a title when I hover over it.

Actual Behavior (Mandatory)

Neither title or label shows up. I have tried this:

     MY_CONNECTION: {
        label: 'MY_CONNECTION',
        [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
          function: {
            title: function (edge) {
              console.log(edge);
            },
          }
        }
      },

And it logs edge to be undefined. When I try the same with a node title it returns information about the node.

How to Reproduce the Problem

Set a label or a title on a relationship and check if it shows up.

Specifications (Mandatory)

I am using neovis.js version 2.10 and I am using datafunctions to connect to an api. The relationships are drawn, they are just not labelled.

Currently used versions

Versions

thebestnom commented 7 months ago

I have to debug it and I need sample data if you can send it But I guess I would not have any time to test it in the following months

I suggest to try to debug it yourself for the time being shouldn't be too hard...

Sorry that I can't help...

exoup commented 7 months ago

@nielsjansendk It seems like the label property for relationships expect to be a property that relationship has. So if MY_CONNECTION has a property called databus with a value of 100BIT then the configuration would look like:

MY_CONNECTION: {
        label: 'databus',
        value: 'weight',
        ...otherProps
      }

and you'd see relationship labels that say 100BIT

I would expect to just be able to set a string for this, or have a property to use the relationship type from Neo4j, but I couldn't find it.

Instead you can set the label using an advanced config like so:

     MY_CONNECTION: {
        label: 'MY_CONNECTION',
        [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
          function: {
            label: (edge) => edge.type
          }
        }
      }

I expect your title function isn't working because it's malformed. objectToTitleHtml expects a neo4jObject (the edge), and an array of properties.

You should be able to get all of your relationship properties in a title like so:

     MY_CONNECTION: {
        label: 'MY_CONNECTION',
        [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
          function: {
            title: (edge) => objectToTitleHtml(edge, Object.keys(edge.properties)),
//OR        title: (edge) => objectToTitleHtml(edge, ["databus", ...])
            label: (edge) => edge.type
          }
        }
      }