可能であれば、いくつかhtmltools
の方法で からの助けを借りることができます。
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)
library(htmltools)
# don't like using the !important modifier
# but without script not sure there is another way
# to override the default white background
browsable(
tagList(
tags$head(
tags$style('body{background-color: #DAE3F9 !important}')
),
forceNetwork(Links = MisLinks, Nodes = MisNodes,
Source = "source", Target = "target",
Value = "value", NodeID = "name",
Group = "group", opacity = 0.8)
)
)
# if you want to limit the background-color to
# the htmlwidget, we could wrap in tags$div
browsable(
tags$div(
style = "background-color:#DAE3F9;",
forceNetwork(Links = MisLinks, Nodes = MisNodes,
Source = "source", Target = "target",
Value = "value", NodeID = "name",
Group = "group", opacity = 0.8)
)
)
# if you are ok with script then we
# we could do something like this
browsable(
tagList(
forceNetwork(Links = MisLinks, Nodes = MisNodes,
Source = "source", Target = "target",
Value = "value", NodeID = "name",
Group = "group", opacity = 0.8),
tags$script(
'
document.body.style.backgroundColor = "#DAE3F9"
'
)
)
)