Skip to contents

Output and render functions for using treemap() within Shiny applications and interactive R Markdown / Quarto documents.

Usage

treemapOutput(output_id, width = "100%", height = "480px")

renderTreemap(expr, env = parent.frame(), quoted = FALSE)

Arguments

output_id

Output variable to read from.

width, height

Element size, passed to htmlwidgets::shinyWidgetOutput().

expr

An expression that generates a treemap() widget.

env

The environment in which to evaluate expr.

quoted

Is expr already quoted? Defaults to FALSE.

Value

treemapOutput() returns a Shiny output UI element; renderTreemap() returns a Shiny render function.

Examples

if (interactive() && requireNamespace("shiny", quietly = TRUE)) {
  ui <- fluidPage(treemapOutput("tm"))
  server <- function(input, output) {
    output$tm <- renderTreemap({
      treemap(id = c("root", "A", "B"), parent = c(NA, "root", "root"),
              value = c(NA, 3, 7))
    })
  }
  shinyApp(ui, server)
}