How can we assign different colors to links based on their weight using the networkD3::forceNetwork
function in R? For example, using the color Blue
for links with a weight greater than 1 and dark
for links with a weight less than 1.
Here is an example code snippet from the networkD3 website (specifically the forceNetwork
section):
library(networkD3)
# Load data
data(MisLinks)
data(MisNodes)
# Plot
forceNetwork(Links = MisLinks, Nodes = MisNodes,
Source = "source", Target = "target",
Value = "value", NodeID = "name",
Group = "group", opacity = 0.8)
I came across a d3-js related question here (I currently have no knowledge of JavaScript).