Making the edges curved in visNetwork in R by giving roundness factor

狂风中的少年 提交于 2019-12-24 02:21:37

问题


The following R script creates a visNetwork diagram as shown. How to manually change the straight edges to curved edges by giving a curved factor?

One approach that I tried here using the roundness attribute with "smooth" label. However, not able to achieve it.

library(visNetwork)
nodes <- data.frame(id = 1:3,color = c(rep("blue",1), rep("red",1), 
rep("green",1)))
edges <- data.frame(from = c(1,2,3), to = c(2,3,1))
nodes = data.frame(nodes, level = edges$from)
visNetwork(nodes, edges, height = "500px", width = "100%") %>% 
visOptions(highlightNearest = list(enabled = T, degree = 2, hover = T)) %>%
visOptions(highlightNearest = F, nodesIdSelection = F, width = 500, height = 
500,autoResize = F) %>%
visHierarchicalLayout() %>% 
visEdges(shadow = TRUE,
       arrows =list(to = list(enabled = TRUE, scaleFactor = 2)),
       color = list(color = "black", highlight = "red"),
       smooth = list(roundness = 0.3)) 

来源:https://stackoverflow.com/questions/48150685/making-the-edges-curved-in-visnetwork-in-r-by-giving-roundness-factor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!