# NOT RUN {
library(Rnvd3)
# in this example we use the tooltip formatters for styling only; we could
# achieve the same result with the help of CSS
dat <- reshape2::melt(
apply(HairEyeColor, c(1, 2), sum), value.name = "Count"
)
multiBarChart(
dat, Count ~ Eye, "Hair",
tooltipFormatters = list(
value = JS(
"function(x){",
" return '<span style=\"color:red;\">' + x + '</span>';",
"}"
),
header = JS(
"function(x){",
" return '<span style=\"color:green;\">' + x + '</span>';",
"}"
),
key = JS(
"function(x){",
" return '<i style=\"color:blue;\">' + x + '</i>';",
"}"
)
)
)
# style axis titles with CSS ####
library(htmltools)
CSS <- HTML(
".nvd3 .nv-axis.nv-x text.nv-axislabel,
.nvd3 .nv-axis.nv-y text.nv-axislabel {
font-size: 2rem;
fill: red;
}"
)
widget <- multiBarChart(
dat, Count ~ Eye, "Hair", palette = "turbo"
)
prependContent(
widget,
tags$style(CSS)
)
# }
Run the code above in your browser using DataLab