Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show label of each edge #315

Closed
XinyeYang opened this issue Dec 24, 2022 · 6 comments
Closed

How to show label of each edge #315

XinyeYang opened this issue Dec 24, 2022 · 6 comments

Comments

@XinyeYang
Copy link

XinyeYang commented Dec 24, 2022

image

visConfig: {
                    nodes: {
                        shape: 'dot',
                        size: 20
                    },
                    edges: {
                        arrows: {
                            to: { enabled: true }
                        },
                        selectionWidth: 10,  //边选中时的宽度
                        color: {
                            color: "#00ffff",
                            highlight: "#ff0000",
                        },
                        label: "xxxx"
                    },
                    physics: {
                        // barnesHut: {
                        //     "avoidOverlap": 1
                        // },
                        repulsion: {
                            "nodeDistance": 100
                        }
                    },
                },

I set a fixed attribute “xxxx” for the edge label 😭
Can you show me a detailed case about the way of setting edge labels dynamically?

@XinyeYang XinyeYang changed the title How to modify the content in DOM by objectToTitleHtml function How to show label of each edge Dec 24, 2022
@thebestnom
Copy link
Collaborator

Please check examples, if you are still stuck please reach again, but I won't have time to help in the current time 😅

@liyiche
Copy link

liyiche commented Mar 30, 2023

Hi dear,I am facing the same problem. Have you found a solution yet?

@XinyeYang
Copy link
Author

XinyeYang commented Mar 30, 2023

Yep, this is my code snippet. Pay attention to the relationships, hope to help you.

async function draw() {
  const config = {
    visConfig: {
    },
    labels: {
    },
    relationships: {
      YOUR Relationship in Neo4j: {
        [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
          static: {
            label: "XXXXXX",     //content on edge
            color: "#ffffff",   //edge color
            font: {
              "background": "none",
              "strokeWidth": "0",
              "size": 20,
              "color": "#f9dc73"  //font color on edge
            }
          }
        }
      }
    }
  }
}

@liyiche
Copy link

liyiche commented Mar 30, 2023

Sorry to bother you again! Fixed code according to your guide, but edge label ("ACTED_IN") still missing. I'm confused about this.
Here is my code and chart. The Neo4j dashboard query response and table structure are as follows.
Looking forward to your reply. 比心.

    async draw(){
      let viz;
      var config = {
        containerId: "viz",
        neo4j: {
          serverUrl: neo4j_url,
          serverUser: neo4j_user,
          serverPassword: neo4j_password,
        },
        visConfig: {
	   nodes: {
            shape: 'circle',
            size: 20,
            font: {
              color: '#343434',
              size: 14, // px
            }
	},
	edges: {
	  arrows: {
	    to: {enabled: true}
	     }
	   }
	},
        labels: {
            Movie:{
              label: "title"
            },
            Person:{
              label: "name"
            }
        },
        relationships: {
          ACTED_IN: {
            value: 'weight',
            [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
              static: {
                label: "ACTED_IN_AA",     //content on edge
                color: "#674ea7",   //edge color
                font: {
                  "background": "none",
                  "strokeWidth": "0",
                  "size": 20,
                  "color": "#f9dc73"  //font color on edge
                }
              }
            }
          }
        },

        initialCypher: "MATCH p=(:Person {name: 'Tom Hanks'})-[r:ACTED_IN]->(k) RETURN p,r,k"
      };

      viz = new NeoVis(config);
      viz.render();
    }

neo4j dashboard

neo4j response table

vuepage

@XinyeYang
Copy link
Author

I'm not sure where the problem is. Do you use the latest neovis.js version(2.0.2)?
I use viz = new NeoVis.default(config); before render().
I can't run withnew NeoVis(config);.

Here is my page.

@XinyeYang
Copy link
Author

I have tried your code and it does work and I guess the problem is initialCypher.
I use MATCH (n:标签)-[r]->(m) RETURN * LIMIT 100
You can have a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants