Description Usage Arguments Value Examples
Display a plot on the client and allow to download it.
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 | ggplot_output(
id,
width = "100%",
height = "400px",
downloads = downloads_labels(),
...
)
downloads_labels(
label = icon("download"),
png = tagList(icon("file-image-o"), "PNG"),
pdf = tagList(icon("file-pdf-o"), "PDF"),
svg = tagList(icon("chrome"), "SVG"),
jpeg = tagList(icon("file-image-o"), "JPEG"),
pptx = tagList(icon("file-powerpoint-o"), "PPTX"),
more = tagList(icon("gear"), "More options")
)
render_ggplot(
id,
expr,
...,
env = parent.frame(),
quoted = FALSE,
filename = "export-ggplot"
)
|
id |
Module ID. |
width |
Width of the plot. |
height |
Height of the plot. |
downloads |
Labels for export options, use |
... |
Parameters passed to |
label |
Main label for export button |
png, pdf, svg, jpeg, pptx |
Labels to display in
export menu, use |
more |
Label for "more" button, allowing to launch export modal. |
expr |
An expression that generates a |
env |
The environment in which to evaluate expression. |
quoted |
Is |
filename |
A string of the filename to export WITHOUT extension, it will be added according to type of export. |
Server-side, a reactiveValues
with the plot.
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 | library(shiny)
library(ggplot2)
library(esquisse)
ui <- fluidPage(
tags$h2("ggplot output"),
selectInput("var", "Variable:", names(economics)[-1]),
ggplot_output("MYID", width = "600px")
)
server <- function(input, output, session) {
render_ggplot("MYID", {
ggplot(economics) +
geom_line(aes(date, !!sym(input$var))) +
theme_minimal() +
labs(
title = "A cool chart made with ggplot2",
subtitle = "that you can export in various format"
)
})
}
if (interactive())
shinyApp(ui, server)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.