Description Usage Arguments Value Examples
Output and render functions for using rnvd3
widgets
within Shiny applications and interactive Rmd documents.
1 2 3 | rnvd3Output(outputId, width = "100%", height = "400px")
renderRnvd3(expr, env = parent.frame(), quoted = FALSE)
|
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 |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.