grillade-shiny.Rd
Grillade Output in Shiny
grilladeOutput(outputId, width = "100%", ...) renderGrillade( expr, n_col = NULL, max_n_col = NULL, cols_width = NULL, gutter = FALSE, output_height = "400px", env = parent.frame(), quoted = FALSE )
outputId | Output variable to read from. |
---|---|
width | If not |
... | Other arguments to pass to the container tag function. This is useful for providing additional classes for the tag. |
expr | An expression that generates a |
n_col | Number of columns, default to |
max_n_col | Maximum number of columns, used if |
cols_width | Numeric vector, numbers of columns taken by each elements,
can be a single number or a |
gutter | Add a gutter between columns, can be |
output_height | Height to use for output(s),
this apply to |
env | The environment in which to evaluate |
quoted | Is |
An HTML output element that can be included in Shiny UI.
# Generate a grillade from the server ------------------------- library(grillade) library(shiny) ui <- fluidPage( tags$h2("Grillade from server"), sliderInput( inputId = "n", label = "Number of elements :", value = 3, min = 1, max = 24 ), grilladeOutput("out") ) server <- function(input, output, session) { output$out <- renderGrillade({ lapply( X = seq_len(input$n), FUN = function(i) { wellPanel( paste("Column", i), style = "text-align: center;" ) } ) }) } if (interactive()) shinyApp(ui, server) # Matrix of htmlwidgets --------------------------------------- library(shiny) library(apexcharter) library(grillade) data("economics", package = "ggplot2") ui <- fluidPage( tags$h2("Htmlwidgets matrix example with grillade"), grilladeOutput("charts") ) server <- function(input, output, session) { make_chart <- function(data, variable) { apex( data = data, mapping = aes(x = date, y = !!sym(variable)), type = "line" ) } output$charts <- renderGrillade({ chart1 <- make_chart(economics, "pce") chart2 <- make_chart(economics, "psavert") chart3 <- make_chart(economics, "uempmed") grillade(chart1, chart2, chart3) }) } if (interactive()) shinyApp(ui, server) # Generate a matrix of plots from server ---------------------- library(grillade) library(shiny) library(ggplot2) ui <- fluidPage( tags$h2("Matrix of plots with grillade"), sliderInput( inputId = "n", label = "Number of plots :", value = 3, min = 1, max = 15 ), grilladeOutput("out") ) server <- function(input, output, session) { output$out <- renderGrillade({ lapply( X = seq_len(input$n), FUN = function(i) { ggplot() + geom_text(aes(1, 1, label = i), size = 50) } ) }, max_n_col = 5) } if (interactive()) shinyApp(ui, server)