Open TimothyEbert opened 3 months ago
The following is a minimally reproducible example where I have removed all of the code that converts the raw data into node and edges. I have also left out code that adjusts the physics.
library(visNetwork)
nodes <- data.frame( id=c("C", "G", "NP", "D", "E1", "E2"), label=c("C", "G", "NP", "D", "E1", "E2"), size = c(45.095856, 37.859089, 116.437705, 1.546333, 1.373999, 23.07729), color.background = c("cyan", "blue", "brown4", "lightgreen", "lightgreen", "lightgreen") )
edges <- data.frame( to = c('C', 'C', 'C', 'D', 'D', 'E1', 'E1', 'E2', 'E2', 'G', 'G', 'NP'), from = c('D', 'G', 'NP', 'C', 'E1', 'C', 'E2', 'C', 'E1', 'C', 'NP', 'C'), width = c(5.135724, 5.629823, 13.597379, 12.25, 12.4, 15.97265, 6.712251, 10, 13.333333, 19.62963, 6.666667, 20), arrows = "to", font_multi = "html", color = c('lightgreen', 'blue', 'brown4', 'cyan', 'lightgreen', 'cyan', 'lightgreen', 'cyan', 'lightgreen', 'cyan', 'brown4', 'cyan') ) visNetwork(nodes, edges)
nodes <- data.frame( id=c("C", "G", "NP", "D", "E1", "E2"), label=c("C", "G", "NP", "D", "E1", "E2"), size = c(45.095856, 37.859089, 116.437705, 1.546333, 1.373999, 23.07729), color.background = c("cyan", "blue", "brown", "lightgreen", "lightgreen", "lightgreen") )
edges <- data.frame( to = c('C', 'C', 'C', 'D', 'D', 'E1', 'E1', 'E2', 'E2', 'G', 'G', 'NP'), from = c('D', 'G', 'NP', 'C', 'E1', 'C', 'E2', 'C', 'E1', 'C', 'NP', 'C'), width = c(5.135724, 5.629823, 13.597379, 12.25, 12.4, 15.97265, 6.712251, 10, 13.333333, 19.62963, 6.666667, 20), arrows = "to", font_multi = "html", color = c('lightgreen', 'blue', 'brown', 'cyan', 'lightgreen', 'cyan', 'lightgreen', 'cyan', 'lightgreen', 'cyan', 'brown', 'cyan') ) visNetwork(nodes, edges)
In simple html brown4 gives /!\Invalid Property Value
in F12/debug of a browser.
They works:
htmltools::browsable(tags$html( span("salut",style="color: red; font-style: italic;")))
<html><head><meta charset="utf-8"></head><body> <span style="color: red; font-style: italic;">salut</span></body></html>
Their color doesn't work:
htmltools::browsable(tags$html( span("salut",style="color: brown4; font-style: italic;")))
<html><head><meta charset="utf-8"></head><body> <span style="color: brown4; font-style: italic;">salut</span></body></html>
brown4 doesn't seem exist in in https://www.w3.org/wiki/CSS/Properties/color/keywords
I am using RStudio running on a PC (DELL Latitude 7440) using R 4.4.1 and RStudio version 2024.4.2.764. I am making network plots with 6 nodes. I assign custom colors to the nodes and edges.
The problem is that some colors appear to cause problems where some edges and nodes to not appear with the right color. I check the edges data frame, and the colors are correct but an edge with one color in the data frame will print as a different color. This graph is good: If I change to "brown4" then I get this:
Is there a pallet that does not have problems, or what is causing this issue?