rnvd3-shiny {Rnvd3} | R Documentation |
Shiny bindings for rnvd3
Description
Output and render functions for using rnvd3
widgets
within Shiny applications and interactive Rmd documents.
Usage
rnvd3Output(outputId, width = "100%", height = "400px")
renderRnvd3(expr, env = parent.frame(), quoted = FALSE)
Arguments
outputId |
output variable to read from |
width , height |
must be a valid CSS unit (like |
expr |
an expression that generates a |
env |
the environment in which to evaluate |
quoted |
is |
Value
rnvd3Output
returns an output element that can be included
in a Shiny UI definition, and renderRnvd3
returns a
shiny.render.function
object that can be included in a Shiny server
definition.
Examples
library(Rnvd3)
library(shiny)
dat <- reshape2::melt(
apply(HairEyeColor, c(1, 2), sum), value.name = "Count"
)
CSS <- HTML(
"body {
overflow: overlay;
}
/* style axis titles */
.nvd3 .nv-axis.nv-x text.nv-axislabel,
.nvd3 .nv-axis.nv-y text.nv-axislabel {
font-size: 3rem;
fill: red;
}
/* style the tooltip */
.nvtooltip .value {
color: red;
}
.nvtooltip .x-value {
color: green;
}
.nvtooltip .key {
color: blue;
font-style: italic;
}
"
)
ui <- fluidPage(
tags$head(tags$style(CSS)),
br(),
fluidRow(
column(
9,
rnvd3Output("mychart", width = "100%", height = "500px")
),
column(
3,
tags$h3("Chart state:"),
verbatimTextOutput("state")
)
)
)
server <- function(input, output, session){
output[["mychart"]] <- renderRnvd3({
multiBarChart(
dat, Count ~ Eye, "Hair", palette = "viridis",
xLabelsFontSize = "2rem", yLabelsFontSize = "2rem"
)
})
output[["state"]] <- renderPrint({
input[["mychart_state"]]
})
}
if(interactive()){
shinyApp(ui, server)
}
[Package Rnvd3 version 1.0.0 Index]