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

Highlight Edges with Color Column #462

Open
ramadatta opened this issue Jul 7, 2023 · 1 comment
Open

Highlight Edges with Color Column #462

ramadatta opened this issue Jul 7, 2023 · 1 comment

Comments

@ramadatta
Copy link

ramadatta commented Jul 7, 2023

Hi,

In the following code, when you have color column in the edges dataframe, the options hover and highlight does not seems work. Is there anyway to highlight the edges when you have color column in edges do this?

nodes <- data.frame(id = 1:15, label = paste("Label", 1:15),
                    group = sample(LETTERS[1:3], 15, replace = TRUE))

edges <- data.frame(id = 1:15, from = trunc(runif(15)*(15-1))+1,
                    to = trunc(runif(15)*(15-1))+1)

#edges$color <- rainbow(15)

visNetwork(nodes, edges) %>% 
  visIgraphLayout(layout = "layout_in_circle") %>% 
  visEdges(color = list(color = "blue",highlight ="red",hover = "red")) %>% #Hover and Highlight parameters work!
  visInteraction(hover = T)

edges$color <- rainbow(15)

visNetwork(nodes, edges) %>% 
  visIgraphLayout(layout = "layout_in_circle") %>% 
  visEdges(color = list(highlight ="red",hover = "red")) %>% #Hover and Highlight parameters does not work!
  visInteraction(hover = T)

Many thanks in advance!

@BioLaoXu
Copy link

BioLaoXu commented Jul 4, 2024

This solution can also work:

nodes <- data.frame(id = 1:15, label = paste("Label", 1:15),
                    group = sample(LETTERS[1:3], 15, replace = TRUE))

edges <- data.frame(id = 1:15, from = trunc(runif(15)*(15-1))+1,
                    to = trunc(runif(15)*(15-1))+1)

net <- igraph::graph_from_data_frame(d=edges,vertices=nodes,directed = F)
visNetwork::visIgraph(net,layout = "layout_in_circle",type = "full") %>%
  visIgraphLayout(layout = "layout_in_circle") %>% 
  visEdges(color = list(highlight ="red",hover = "red")) %>% 
  visInteraction(hover = T)

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

2 participants