我希望在单击节点时突出整个路径,以了解特定节点的整个故事,以下是一个示例- http://bl.ocks.org/git-ashish/8959771。
请检查此链接,您将找到突出显示路径的JavaScript函数,请注意,此函数不执行我想要的操作,它突出显示与单击节点相关的链接以及目标节点相关的链接。我想要的是突出显示与单击节点相关的所有链接。
这是我所需要的一个示例,
这是整个图形,我需要的是,当我单击曼谷时,它会突出显示与数据框中曼谷在同一行的所有节点,例如突出显示到ClimateChange和EnergyShortage的链接,然后突出Infrastructure&Ecosystems和Leadership&strategy等。
这就是我想要的。
这里是另一张使用shiny分析与曼谷相关的节点的图片。
![enter image description here](https://istack.dev59.com/BzjD9.webp)
structure(list(City = c("Bangkok", "Bangkok", "Bangkok", "Bangkok",
"Bangkok", "Bangkok", "Bangkok", "Bangkok", "Bangkok", "Bangkok",
"Bangkok", "Bangkok", "Bangkok", "Bangkok", "Bangkok", "Bangkok"
), ResiliencyChallenge = c("ClimateChange", "ClimateChange",
"ClimateChange", "ClimateChange", "ClimateChange", "InfrastructureFaliure",
"EnergyShortage", "Pollution", "Pollution", "Pollution", "TransportationSystemFailure",
"TransportationSystemFailure", "TransportationSystemFailure",
"TransportationSystemFailure", "TransportationSystemFailure",
"TransportationSystemFailure"), CRI.Dimesnsion.1 = c("Infrastructure & Ecosystems",
"Infrastructure & Ecosystems", "Infrastructure & Ecosystems",
"Infrastructure & Ecosystems", "Infrastructure & Ecosystems",
"Infrastructure & Ecosystems", "Infrastructure & Ecosystems",
"Leadership & Strategy", "Leadership & Strategy", "Infrastructure & Ecosystems",
"Infrastructure & Ecosystems", "Infrastructure & Ecosystems",
"Infrastructure & Ecosystems", "Infrastructure & Ecosystems",
"Infrastructure & Ecosystems", "Leadership & Strategy"), Implementation.time.frame = c("Short-term",
"Short-term", "Short-term", "Short-term", "Short-term", "Mid-term",
"Long-term", "Short-term", "Short-term", "Mid-term", "Mid-term",
"Short-term", "Short-term", "Short-term", "Short-term", "Short-term"
), Goal = c("Goal13", "Goal13", "Goal13", "Goal13", "Goal13",
"Goal12", "Goal12", "Goal11", "Goal11", "Goal11", "Goal11", "Goal11",
"Goal11", "Goal11", "Goal11", "Goal11")), .Names = c("City",
"ResiliencyChallenge", "CRI.Dimesnsion.1", "Implementation.time.frame",
"Goal"), class = "data.frame", row.names = c(NA, -16L))
networkD3
中的R语言?你复制粘贴的代码是使用networkD3
的R语言...在该代码的结果中,当你悬停在一个节点上时,它已经实现了你想要的功能,突出显示与该节点相关的所有链接。你希望它在单击时起作用吗?或者你正在寻找一个JavaScript实现networkD3
输出的方法,在悬停时突出显示节点的链接? - CJ YetmannetworkD3
中时,发现必须使用htmlwidget中的onRender。但是我无法成功,当我尝试通过操作sankeyNetwork
小部件手动更改networkD3的内容时,我成功了。但是我发现上面链接中的Javascript函数highlight_node_links
是错误的,它不能实现我想要的效果,请帮帮我。 - Omar Abd El-Naser