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
)

Arguments

outputId

Output variable to read from.

width

If not NULL, must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.

...

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 grillade.

n_col

Number of columns, default to NULL and automatically display element with equal size in the grid.

max_n_col

Maximum number of columns, used if n_col = NULL and number of elements is unknown.

cols_width

Numeric vector, numbers of columns taken by each elements, can be a single number or a vector of same length as elements number.

gutter

Add a gutter between columns, can be TRUE/FALSE, or "l" or "xl".

output_height

Height to use for output(s), this apply to htmlwidgets and ggplot2.

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

Value

An HTML output element that can be included in Shiny UI.

Examples

# 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)