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

Is it possible to force edge length to be 0, permanently? #475

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

Is it possible to force edge length to be 0, permanently? #475

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

Comments

@salk-law
Copy link

salk-law commented Oct 9, 2024

Is it possible to make edges lengths zero such that two nodes are immediately adjacent, and this arrangement is maintained while moving nodes? I'm imagining clicking and dragging one node and the node with which is shares an edge of zero length moves with it. Is this possible, and if so, how can it be done?

I tried setting length to zero but it doesn't seem to have any effect:

# 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,
  length = 200
)

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

# Render graph
visNetwork(nodes = nodes, edges = edges) %>%
  visNodes(physics = F) %>%
  visEdges(physics = F)
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