Integrating the js code in R to make the visNetwork edges curved

前端 未结 1 1161
北海茫月
北海茫月 2020-12-22 10:38

the script below creates the visNetwork as shown in the visualization below. I want a functionality to make the edge \"1\" and edge \"3\" curved. I am attaching the js code

相关标签:
1条回答
  • 2020-12-22 10:59

    Updated code with listed paramaters of smooth:

    library(visNetwork)
    nodes <- data.frame(id = 1:4)
    edges <- data.frame(from = c(2,4,3,2), to = c(1,2,4,3), label = 1:4, smooth = list(enabled = F, type ='curvedCW', roundness = 0.2))
    edges <- data.frame(edges,edges$from)
    
    #enable smooth for the edges you like
    
    edges$smooth.enabled[edges$label==1] = T
    edges$smooth.enabled[edges$label==3] = T
    visNetwork(nodes, edges, width = "100%") %>% 
      visEdges(arrows =list(to = list(enabled = TRUE, scaleFactor = 2)),
               color = list(color = "lightblue", highlight = "red")) %>% 
      visHierarchicalLayout()
    

    Screenshot:

    0 讨论(0)
提交回复
热议问题