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 make duplicate edges not overlap when physics is off #474

Open
salk-law opened this issue Oct 9, 2024 · 0 comments
Open

How to make duplicate edges not overlap when physics is off #474

salk-law opened this issue Oct 9, 2024 · 0 comments

Comments

@salk-law
Copy link

salk-law commented Oct 9, 2024

Here is a summary of my problem:

  1. My network has duplicate edges
  2. Duplicate edges are not easily visibly separable because they overlap perfectly
  3. I want no animation upon movement of nodes

I found #95 to contain a working solution when physics is enabled by using barnesHut settings:.

Example of my situation:

# Reproducible example of problem
library(visNetwork)
library(data.table)
library(magrittr)
# For reproducibility
set.seed(1)

# Declare nodes
nodes = data.table(
  id = letters[1:10], 
  label = letters[1:10]
)

# Declare edges
edges = data.table(
  from = sample(letters[1:10], 10, replace = T), 
  to = sample(letters[1:10], 10, replace = T),
  color = "blue",
  dashes = T
)

# Add duplicate edges
edges.dupl = edges[rep(1:3, 1)][, `:=`(color = "red", dashes = F)]
edges = rbind(edges.dupl, edges)

# Render graph
visNetwork(nodes = nodes, edges = edges) %>%
  visNodes(physics = F) %>%
  visEdges(physics = F)
@salk-law salk-law changed the title How to make duplicate edges not overlap with physics off How to make duplicate edges not overlap when physics is off Oct 9, 2024
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

1 participant