3

リンクをクリックすると、2 つのノード間のリンクの詳細が表示されるように、このサンキー ダイアグラムに onClick を実装したいと考えています。それは plotly_click 関数のようなものです

library(networkD3)
nodes = data.frame("name" = 
                 c("r1", # Node 0
                   "r2", # Node 1
                   "r3", # Node 2
                   "r4", # Node 3
                   "r5", # Node 4
                   "r6", # Node 5
                   "r7", # Node 6
                   "Blood Test", # Node 7
                   "Check Out", # Node 8
                   "Discuss Results", # Node 9
                   "MRI Scan", # Node 10
                   "Registration", # Node 11
                   "Triage and Assessment", # Node 12
                   "X-ray"))# Node 13
links = as.data.frame(matrix(c(
0, 11, 500, # Each row represents a link. The first number
1, 12, 500, # represents the node being conntected from. 
2, 7, 237, # the second number represents the node connected to.
3, 10, 236,
4, 13, 261,
5, 9, 495,
6, 8, 492),# The third number is the value of the node

byrow = TRUE, ncol = 3))
names(links) = c("source", "target", "value")
sankeyNetwork(Links = links, Nodes = nodes,
          Source = "source", Target = "target",
          Value = "value", NodeID = "name",
          fontSize= 12, nodeWidth = 30)

サンキースナップ

4

2 に答える 2