Reputation: 1446
I am starting to learn about interactive graphs in R, and I found the library visNetwork
very helpful.
However, I don't find on the vignettes how to display a pop-up with more information than the value
and title
when the mouse is moved over the edge.
Using one of the examples in the documentation
# data used in visNetwork vignette
nb <- 10
nodes <- data.frame(id = 1:nb, label = paste("Label", 1:nb),
group = sample(LETTERS[1:3], nb, replace = TRUE), value = 1:nb,
title = paste0("<p>", 1:nb,"<br>Tooltip !</p>"), stringsAsFactors = FALSE)
edges <- data.frame(from = c(8,2,7,6,1,8,9,4,6,2),
to = c(3,7,2,7,9,1,5,3,2,9),
value = rnorm(nb, 10), label = paste("Edge", 1:nb),
title = paste0("<p>", 1:nb,"<br>Edge Tooltip !</p>"))
visNetwork(nodes, edges, height = "500px", width = "100%")
How could I add more information to the pop-up, such as, different parameters related to the edge (width, frequency, ..)?
Upvotes: 1
Views: 2011
Reputation: 544
you have to paste all the information into the title column.
# data used in visNetwork vignette
nb <- 10
nodes <- data.frame(id = 1:nb, label = paste("Label", 1:nb),
group = sample(LETTERS[1:3], nb, replace = TRUE), value = 1:nb,
title = paste0("<p>", 1:nb,"<br>Tooltip !</p>"), stringsAsFactors = FALSE)
edges <- data.frame(from = c(8,2,7,6,1,8,9,4,6,2),
to = c(3,7,2,7,9,1,5,3,2,9),
value = rnorm(nb, 10), label = paste("Edge", 1:nb))
edges$title <- paste0(edges$label, "<br> value : ", round(edges$value, 2))
visNetwork(nodes, edges, height = "500px", width = "100%")
Upvotes: 4